/** * Center a cloud of points. This means subtracting the {@lin * #centroid(Point3d[])} of the cloud to each point. * * @param x * array of points. Point objects will be modified */ public static void center(Point3d[] x) { Point3d center = centroid(x); center.negate(); translate(new Vector3d(center), x); }
@Override public Point3d[] getVertices() { Point3d[] icosahedron = new Point3d[12]; // see http://answers.yahoo.com/question/index?qid=20080108041441AAJCjEu double c = circumscribedRadius * 1 / Math.sqrt(5); double s = 2 * c; // golden ratio double c1 = Math.sqrt((3-Math.sqrt(5))/8); // cos(2Pi/5) double s1 = Math.sqrt((5+Math.sqrt(5))/8); // sin(2Pi/5) double c2 = Math.sqrt((3+Math.sqrt(5))/8); // cos(Pi/5) double s2 = Math.sqrt((5-Math.sqrt(5))/8); // sin(Pi/5) icosahedron[0] = new Point3d(0, 0, circumscribedRadius); icosahedron[1] = new Point3d(s, 0, c); icosahedron[2] = new Point3d(s*c1, s*s1, c); icosahedron[3] = new Point3d(-s*c2, s*s2, c); icosahedron[4] = new Point3d(-s*c2, -s*s2, c); icosahedron[5] = new Point3d(s*c1, -s*s1, c); for (int i = 0; i < 6; i++) { icosahedron[i+6] = new Point3d(icosahedron[i]); icosahedron[i+6].negate(); } Matrix3d m = new Matrix3d(); m.rotZ(Math.PI/10); for (Point3d p: icosahedron) { m.transform(p); } return icosahedron; };
private String drawInertiaAxes() { StringBuilder s = new StringBuilder(); Point3d centroid = rotationAxisAligner.getGeometricCenter(); Vector3d[] axes = rotationAxisAligner.getPrincipalAxesOfInertia(); for (int i = 0; i < axes.length; i++) { s.append("draw axesInertia"); s.append(name); s.append(i); s.append(" "); s.append("line"); Point3d v1 = new Point3d(axes[i]); if (i == 0) { v1.scale(AXIS_SCALE_FACTOR*rotationAxisAligner.getDimension().y); } else if (i == 1) { v1.scale(AXIS_SCALE_FACTOR*rotationAxisAligner.getDimension().x); } else if (i == 2) { v1.scale(AXIS_SCALE_FACTOR*rotationAxisAligner.getDimension().z); } Point3d v2 = new Point3d(v1); v2.negate(); v1.add(centroid); v2.add(centroid); s.append(getJmolPoint(v1)); s.append(getJmolPoint(v2)); s.append("width 0.5 "); s.append(" color white"); s.append(" off;"); } return s.toString(); };
v1.scale(AXIS_SCALE_FACTOR*(helixAxisAligner.getDimension().y + SIDE_CHAIN_EXTENSION)); Point3d v2 = new Point3d(v1); v2.negate(); v1.add(centroid); v2.add(centroid);
/** * Calculates the RMSD value for superposition of y onto x. This requires * the coordinates to be precentered. * * @param x * 3d points of reference coordinate set * @param y * 3d points of coordinate set for superposition */ private void calcRmsd(Point3d[] x, Point3d[] y) { if (centered) { innerProduct(y, x); } else { // translate to origin xref = CalcPoint.clonePoint3dArray(x); xtrans = CalcPoint.centroid(xref); logger.debug("x centroid: " + xtrans); xtrans.negate(); CalcPoint.translate(new Vector3d(xtrans), xref); yref = CalcPoint.clonePoint3dArray(y); ytrans = CalcPoint.centroid(yref); logger.debug("y centroid: " + ytrans); ytrans.negate(); CalcPoint.translate(new Vector3d(ytrans), yref); innerProduct(yref, xref); } calcRmsd(wsum); }
xtrans.negate();
/** * Superposition coords2 onto coords1 -- in other words, coords2 is rotated, * coords1 is held fixed */ private void calcTransformation() { // transformation.set(rotmat,new Vector3d(0,0,0), 1); transformation.set(rotmat); // long t2 = System.nanoTime(); // System.out.println("create transformation: " + (t2-t1)); // System.out.println("m3d -> m4d"); // System.out.println(transformation); // combine with x -> origin translation Matrix4d trans = new Matrix4d(); trans.setIdentity(); trans.setTranslation(new Vector3d(xtrans)); transformation.mul(transformation, trans); // System.out.println("setting xtrans"); // System.out.println(transformation); // combine with origin -> y translation ytrans.negate(); Matrix4d transInverse = new Matrix4d(); transInverse.setIdentity(); transInverse.setTranslation(new Vector3d(ytrans)); transformation.mul(transInverse, transformation); // System.out.println("setting ytrans"); // System.out.println(transformation); }
_vecteur.negate(); for (int i = 0; i < 6; i++) { lines[i].negate();