Java Code Examples for org.joml.Vector3d#rotate()
The following examples show how to use
org.joml.Vector3d#rotate() .
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: Rotate3d.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void compute(final Vector3d v, final Quaterniondc q, final Vector3d vDot) { vDot.set(v); vDot.rotate(q); }
Example 4
Source File: Rotate3dTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testAxisAngle() { final Vector3d xAxis = new Vector3d(1, 0, 0); final Vector3d in = new Vector3d(xAxis); final AxisAngle4d axisAngle = new AxisAngle4d(Math.PI / 2.0, 0, 0, 1); final Vector3d expected = xAxis.rotate(new Quaterniond(axisAngle)); final Vector3d result = ops.linalg().rotate(in, axisAngle); assertEquals("Rotation is incorrect", expected, result); }
Example 5
Source File: Rotate3dTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testMutate() { final Vector3d xAxis = new Vector3d(1, 0, 0); final Vector3d in = new Vector3d(xAxis); final Quaterniond q = new Quaterniond(new AxisAngle4d(Math.PI / 2.0, 0, 0, 1)); final Vector3d expected = xAxis.rotate(q); final Vector3d result = ops.linalg().rotate1(in, q); assertSame("Mutate should operate on the input object", in, result); assertEquals("Rotation is incorrect", expected, result); }
Example 6
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); } }
Example 7
Source File: Rotate3d.java From imagej-ops with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void mutate1(final Vector3d v, final Quaterniondc q) { v.rotate(q); }