/** * @cdk.dictref blue-obelisk:convertCartesianIntoNotionalCoordinates */ public static double[] cartesianToNotional(Vector3d aAxis, Vector3d bAxis, Vector3d cAxis) { double[] notionalCoords = new double[6]; notionalCoords[0] = aAxis.length(); notionalCoords[1] = bAxis.length(); notionalCoords[2] = cAxis.length(); notionalCoords[3] = bAxis.angle(cAxis) * 180.0 / Math.PI; notionalCoords[4] = aAxis.angle(cAxis) * 180.0 / Math.PI; notionalCoords[5] = aAxis.angle(bAxis) * 180.0 / Math.PI; return notionalCoords; }
/** * Gets the angle between two vectors * * @param a * an Atom object * @param b * an Atom object * @return Angle between a and b in degrees, in range [0,180]. If either * vector has length 0 then angle is not defined and NaN is returned */ public static final double angle(Atom a, Atom b){ Vector3d va = new Vector3d(a.getCoordsAsPoint3d()); Vector3d vb = new Vector3d(b.getCoordsAsPoint3d()); return Math.toDegrees(va.angle(vb)); }
private double calculateAngleBetweenTwoLines(Vector3d a, Vector3d b, Vector3d c, Vector3d d) { Vector3d firstLine = new Vector3d(); firstLine.sub(a, b); Vector3d secondLine = new Vector3d(); secondLine.sub(c, d); Vector3d firstVec = new Vector3d(firstLine); Vector3d secondVec = new Vector3d(secondLine); return firstVec.angle(secondVec); }
private double calculateAngleBetweenTwoLines(Vector3d a, Vector3d b, Vector3d c, Vector3d d) { Vector3d firstLine = new Vector3d(); firstLine.sub(a, b); Vector3d secondLine = new Vector3d(); secondLine.sub(c, d); Vector3d firstVec = new Vector3d(firstLine); Vector3d secondVec = new Vector3d(secondLine); return firstVec.angle(secondVec); }
private double calculateAngleBetweenTwoLines(Vector3d a, Vector3d b, Vector3d c, Vector3d d) { Vector3d firstLine = new Vector3d(); firstLine.sub(a, b); Vector3d secondLine = new Vector3d(); secondLine.sub(c, d); Vector3d firstVec = new Vector3d(firstLine); Vector3d secondVec = new Vector3d(secondLine); return firstVec.angle(secondVec); }
private double calculateAngleBetweenTwoLines(Vector3d a, Vector3d b, Vector3d c, Vector3d d) { Vector3d firstLine = new Vector3d(); firstLine.sub(a, b); Vector3d secondLine = new Vector3d(); secondLine.sub(c, d); Vector3d firstVec = new Vector3d(firstLine); Vector3d secondVec = new Vector3d(secondLine); return firstVec.angle(secondVec); }
private double calculateAngleBetweenTwoLines(Vector3d a, Vector3d b, Vector3d c, Vector3d d) { Vector3d firstLine = new Vector3d(); firstLine.sub(a, b); Vector3d secondLine = new Vector3d(); secondLine.sub(c, d); Vector3d firstVec = new Vector3d(firstLine); Vector3d secondVec = new Vector3d(secondLine); return firstVec.angle(secondVec); }
/** * This method tests the calculation of the angle between one axis * and itself, which should be zero by definition. */ @Test public void testCalcAngle3() { Vector3d b = new Vector3d(4.5, 3.1, 1.7); double angle = b.angle(b) * 180.0 / Math.PI; Assert.assertEquals(0.0, angle, 0.001); }
double biasMagnitude = zUpVector.angle(measurementNormalizedInWorld);
/** * This method tests the calculation of the angle between two axes too. */ @Test public void testCalcAngle2() { Vector3d b = new Vector3d(0.0, 1.0, 1.0); Vector3d c = new Vector3d(0.0, 0.0, 1.0); double angle = b.angle(c) * 180.0 / Math.PI; Assert.assertEquals(45.0, angle, 0.001); }
/** * This method tests the calculation of the angle between two axes. */ @Test public void testCalcAngle() { Vector3d b = new Vector3d(0.0, 2.0, 0.0); Vector3d c = new Vector3d(0.0, 0.0, 3.0); double angle = b.angle(c) * 180.0 / Math.PI; Assert.assertEquals(90.0, angle, 0.001); }
/** * Returns true if both given transform ids belong to the same crystallographic axis (a, b or c) * For two non-rotation transformations (i.e. identity operators) it returns true * @param tId1 * @param tId2 * @return */ public boolean areInSameAxis(int tId1, int tId2) { if (tId1==tId2) return true; if (axisAngles== null) calcRotAxesAndAngles(); if (getAxisFoldType(tId1)==1 && getAxisFoldType(tId2)==1) return true; // we can't deal yet with improper rotations: we return false whenever either of them is improper if (getAxisFoldType(tId1)<0 || getAxisFoldType(tId2)<0) return false; Vector3d axis1 = new Vector3d(axisAngles[tId1].x, axisAngles[tId1].y, axisAngles[tId1].z); Vector3d axis2 = new Vector3d(axisAngles[tId2].x, axisAngles[tId2].y, axisAngles[tId2].z); // TODO revise: we might need to consider that the 2 are in same direction but opposite senses // the method is not used at the moment anyway if (deltaComp(axis1.angle(axis2), 0.0, DELTA)) return true; return false; }
/** * Computes and sets the camera rotation for given camera position and a given point to focus on. * @param cameraPosition desired camera position. Not modified. * @param focusPoint desired focus position. Not modified. * @param cameraRoll desired camera roll. */ public void setRotationFromCameraAndFocusPositions(Point3d cameraPosition, Point3d focusPoint, double cameraRoll) { Vector3d fromFocusToCamera = new Vector3d(); fromFocusToCamera.sub(cameraPosition, focusPoint); fromFocusToCamera.normalize(); Vector3d fromCameraToFocus = new Vector3d(); fromCameraToFocus.negate(fromFocusToCamera); // We remove the component along up to be able to compute the longitude fromCameraToFocus.scaleAdd(-fromCameraToFocus.dot(up), up, fromCameraToFocus); double newLatitude = Math.PI / 2.0 - fromFocusToCamera.angle(up); double newLongitude = fromCameraToFocus.angle(forward); Vector3d cross = new Vector3d(); cross.cross(fromCameraToFocus, forward); if (cross.dot(up) > 0.0) newLongitude = -newLongitude; latitude.set(newLatitude); longitude.set(newLongitude); roll.set(cameraRoll); updateRotation(); }
private static double getAngle(IAtom atom1, IAtom atom2, IAtom atom3) { Vector3d centerAtom = new Vector3d(); centerAtom.x = atom1.getPoint3d().x; centerAtom.y = atom1.getPoint3d().y; centerAtom.z = atom1.getPoint3d().z; Vector3d firstAtom = new Vector3d(); Vector3d secondAtom = new Vector3d(); firstAtom.x = atom2.getPoint3d().x; firstAtom.y = atom2.getPoint3d().y; firstAtom.z = atom2.getPoint3d().z; secondAtom.x = atom3.getPoint3d().x; secondAtom.y = atom3.getPoint3d().y; secondAtom.z = atom3.getPoint3d().z; firstAtom.sub(centerAtom); secondAtom.sub(centerAtom); return firstAtom.angle(secondAtom); }
private static double getAngle(IAtom atom1, IAtom atom2, IAtom atom3) { Vector3d centerAtom = new Vector3d(); centerAtom.x = atom1.getPoint3d().x; centerAtom.y = atom1.getPoint3d().y; centerAtom.z = atom1.getPoint3d().z; Vector3d firstAtom = new Vector3d(); Vector3d secondAtom = new Vector3d(); firstAtom.x = atom2.getPoint3d().x; firstAtom.y = atom2.getPoint3d().y; firstAtom.z = atom2.getPoint3d().z; secondAtom.x = atom3.getPoint3d().x; secondAtom.y = atom3.getPoint3d().y; secondAtom.z = atom3.getPoint3d().z; firstAtom.sub(centerAtom); secondAtom.sub(centerAtom); return firstAtom.angle(secondAtom); }
Vector3d b = cardAxes[1]; Vector3d c = cardAxes[2]; Assert.assertEquals(69.043, Math.toDegrees(b.angle(c)), 0.001); Assert.assertEquals(74.441, Math.toDegrees(a.angle(c)), 0.001); Assert.assertEquals(77.821, Math.toDegrees(b.angle(a)), 0.001); Assert.assertEquals(9.3323, a.length(), 0.0001); Assert.assertEquals(10.1989, b.length(), 0.0001);
double theta = wrap180Radian(arrowMotion.angle(lookVec)); theta = clampAbs(theta, Math.PI / 2); // Dividing by higher numbers kills accuracy