Java Code Examples for org.joml.Vector3d#sub()
The following examples show how to use
org.joml.Vector3d#sub() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TranslationRotation.java From OSPREY3 with GNU General Public License v2.0 | 6 votes |
private void apply() { Vector3d pos = new Vector3d(); Quaterniond qPsi = new Quaterniond().rotationX(dofPsi.value); Quaterniond qTheta = new Quaterniond().rotationY(dofTheta.value); Quaterniond qPhi = new Quaterniond().rotationZ(dofPhi.value); Vector3d t = new Vector3d(dofX.value, dofY.value, dofZ.value); // transform each atom for (int atomi : atomIndices) { originalCoords.get(atomi, pos); pos.sub(desc.centroid); pos.rotate(qPsi); pos.rotate(qTheta); pos.rotate(qPhi); pos.add(desc.centroid); pos.add(t); coords.coords.set(atomi, pos); } }
Example 2
Source File: DihedralAngle.java From OSPREY3 with GNU General Public License v2.0 | 6 votes |
/** * Measures the dihedral angle in radians, using the usual a,b,c,d atom position convention. * * WARNING: this implementation overwrites the values of a, c, and d, * but it doesn't do any heap allocations. */ private static double measureAngleRadians(Vector3d a, Vector3d b, Vector3d c, Vector3d d) { // translate so b is at the origin a.sub(b); c.sub(b); d.sub(b); // rotate into a coordinate system where: // b->c is along the -z axis // b->a is in the yz plane Quaterniond q = new Quaterniond() .lookAlong(c, a); d.rotate(q); return Protractor.normalizeMinusPiToPi(Math.PI/2 - Math.atan2(d.y, d.x)); }
Example 3
Source File: GraphPruning.java From AnalyzeSkeleton with GNU General Public License v3.0 | 5 votes |
/** * Sets the length of the {@link Edge} to the calibrated euclidean distance * between its endpoints. * * @param e an edge of a graph. * @param voxelSize [x, y, z] voxel size in the skeleton image from which the * graph was created. */ private static void euclideanDistance(final Edge e, final double[] voxelSize) { final Vector3d centre = PointUtils.centroid(e.getV1().getPoints()); final Vector3d centre2 = PointUtils.centroid(e.getV2().getPoints()); centre.sub(centre2); final double l = length(centre, voxelSize); e.setLength(l); }
Example 4
Source File: VertexUtils.java From AnalyzeSkeleton with GNU General Public License v3.0 | 5 votes |
private static Vector3d getOppositeCentroid(final Vertex vertex, final Vector3d centroid, final Edge edge) { final List<Point> points = edge.getOppositeVertex(vertex).getPoints(); final Vector3d endPoint = PointUtils.centroid(points); return endPoint.sub(centroid); }
Example 5
Source File: DihedralAngle.java From OSPREY3 with GNU General Public License v2.0 | 4 votes |
public void setAngle(double angleRadians) { // TODO: profile and optimize this Vector3d temp = new Vector3d(); Quaterniond qIn = new Quaterniond(); Quaterniond qZ = new Quaterniond(); Quaterniond qOut = new Quaterniond(); Vector3d a = new Vector3d(); Vector3d b = new Vector3d(); Vector3d c = new Vector3d(); Vector3d d = new Vector3d(); // copy our a,b,c,d from the coords array coords.coords.get(ai, a); coords.coords.get(bi, b); coords.coords.get(ci, c); coords.coords.get(di, d); // translate so b is at the origin a.sub(b); c.sub(b); d.sub(b); // rotate into a coordinate system where: // b->c is along the -z axis // b->a is in the yz plane qIn.lookAlong(c, a); d.rotate(qIn); // rotate about z to set the desired dihedral angle qZ.rotationZ(Math.PI/2 - angleRadians - Math.atan2(d.y, d.x)); // rotate back into the world frame qOut.set(qIn) .conjugate(); // transform all the rotated atoms for (int i : ri) { coords.coords.get(i, temp); temp.sub(b); temp.rotate(qIn); temp.rotate(qZ); temp.rotate(qOut); temp.add(b); coords.coords.set(i, temp); } }