Package javajs.util

Class Measure

java.lang.Object
javajs.util.Measure

public final class Measure extends Object
  • Field Details

    • radiansPerDegree

      public static final float radiansPerDegree
      See Also:
    • axisY

      public static final V3 axisY
  • Constructor Details

    • Measure

      public Measure()
  • Method Details

    • computeAngle

      public static float computeAngle(T3 pointA, T3 pointB, T3 pointC, V3 vectorBA, V3 vectorBC, boolean asDegrees)
    • computeAngleABC

      public static float computeAngleABC(T3 pointA, T3 pointB, T3 pointC, boolean asDegrees)
    • computeTorsion

      public static float computeTorsion(T3 p1, T3 p2, T3 p3, T3 p4, boolean asDegrees)
    • getPlaneThroughPoints

      public static P4 getPlaneThroughPoints(T3 pointA, T3 pointB, T3 pointC, V3 vNorm, V3 vAB, P4 plane)
    • getPlaneThroughPoint

      public static void getPlaneThroughPoint(T3 pt, V3 normal, P4 plane)
    • distanceToPlane

      public static float distanceToPlane(P4 plane, T3 pt)
    • directedDistanceToPlane

      public static float directedDistanceToPlane(P3 pt, P4 plane, P3 ptref)
    • distanceToPlaneD

      public static float distanceToPlaneD(P4 plane, float d, P3 pt)
    • distanceToPlaneV

      public static float distanceToPlaneV(V3 norm, float w, P3 pt)
    • calcNormalizedNormal

      public static void calcNormalizedNormal(T3 pointA, T3 pointB, T3 pointC, T3 vNormNorm, T3 vAB)
      note that if vAB or vAC is dispensible, vNormNorm can be one of them
      Parameters:
      pointA -
      pointB -
      pointC -
      vNormNorm -
      vAB -
    • getDirectedNormalThroughPoints

      public static float getDirectedNormalThroughPoints(T3 pointA, T3 pointB, T3 pointC, T3 ptRef, V3 vNorm, V3 vAB)
    • getNormalThroughPoints

      public static float getNormalThroughPoints(T3 pointA, T3 pointB, T3 pointC, T3 vNorm, T3 vTemp)
      Parameters:
      pointA -
      pointB -
      pointC -
      vNorm -
      vTemp -
      Returns:
      w
    • getPlaneProjection

      public static float getPlaneProjection(T3 pt, P4 plane, T3 retPtProj, V3 retNorm)
      Project a point onto a plane, also returning the normal vector and the directed distance to the plane.
      Parameters:
      pt -
      plane -
      retPtProj - returned pt (can be pt)
      retNorm - returned normal vector
      Returns:
      directed distance to plane
    • getNormalFromCenter

      public static boolean getNormalFromCenter(P3 ptCenter, P3 ptA, P3 ptB, P3 ptC, boolean isOutward, V3 normal, V3 vTemp)
      Parameters:
      ptCenter -
      ptA -
      ptB -
      ptC -
      isOutward -
      normal - set to be opposite to direction of ptCenter from abd
      vTemp -
      Returns:
      true if winding is CCW; false if CW
    • getNormalToLine

      public static void getNormalToLine(P3 pointA, P3 pointB, V3 vNormNorm)
    • getBisectingPlane

      public static void getBisectingPlane(P3 pointA, V3 vAB, T3 ptTemp, V3 vTemp, P4 plane)
    • projectOntoAxis

      public static float projectOntoAxis(P3 pt, P3 ptA, V3 axisUnitVector, V3 vectorProjection)
      project point onto a line containing ptA and having axis unitVector axisUnitVector, returning the result in point and a vector from ptA to pt in vectorProjection
      Parameters:
      pt - input pt to be projected, returns projected
      ptA - input point on line
      axisUnitVector - input unit vector
      vectorProjection - return for pt.sub(ptA)
      Returns:
      projected distance
    • calcBestAxisThroughPoints

      public static void calcBestAxisThroughPoints(P3[] points, int nPoints, P3 axisA, V3 axisUnitVector, V3 vectorProjection, int nTriesMax)
      Parameters:
      points -
      nPoints -
      axisA -
      axisUnitVector -
      vectorProjection -
      nTriesMax -
    • findAxis

      public static float findAxis(P3[] points, int nPoints, P3 axisA, V3 axisUnitVector, V3 vectorProjection)
    • calcAveragePoint

      public static void calcAveragePoint(P3 pointA, P3 pointB, P3 pointC)
    • calcAveragePointN

      public static void calcAveragePointN(P3[] points, int nPoints, P3 averagePoint)
    • transformPoints

      public static Lst<P3> transformPoints(Lst<P3> vPts, M4 m4, P3 center)
    • isInTetrahedron

      public static boolean isInTetrahedron(P3 pt, P3 ptA, P3 ptB, P3 ptC, P3 ptD, P4 plane, V3 vTemp, V3 vTemp2, boolean fullyEnclosed)
    • getIntersectionPP

      public static Lst<Object> getIntersectionPP(P4 plane1, P4 plane2)
      Calculate the line that is the intersection of two planes.
      Parameters:
      plane1 -
      plane2 -
      Returns:
      [ point, vector ] or []
    • getIntersection

      public static P3 getIntersection(P3 pt1, V3 v, P4 plane, P3 ptRet, V3 tempNorm, V3 vTemp)
      Calculate the intersection of a line with a plane.
      Parameters:
      pt1 - point on line
      v - unit vector of line
      plane -
      ptRet - point of intersection of line with plane
      tempNorm -
      vTemp -
      Returns:
      ptRtet
    • calculateQuaternionRotation

      public static Quat calculateQuaternionRotation(P3[][] centerAndPoints, float[] retStddev)
      Closed-form solution of absolute orientation requiring 1:1 mapping of positions.
      Parameters:
      centerAndPoints -
      retStddev -
      Returns:
      unit quaternion representation rotation
    • getTransformMatrix4

      public static float getTransformMatrix4(Lst<P3> ptsA, Lst<P3> ptsB, M4 m, P3 centerA)
      Fills a 4x4 matrix with rotation-translation of mapped points A to B. If centerA is null, this is a standard 4x4 rotation-translation matrix; otherwise, this 4x4 matrix is a rotation around a vector through the center of ptsA, and centerA is filled with that center; Prior to Jmol 14.3.12_2014.02.14, when used from the JmolScript compare() function, this method returned the second of these options instead of the first.
      Parameters:
      ptsA -
      ptsB -
      m - 4x4 matrix to be returned
      centerA - return center of rotation; if null, then standard 4x4 matrix is returned
      Returns:
      stdDev
    • getCenterAndPoints

      public static P3[] getCenterAndPoints(Lst<P3> vPts)
      from a list of points, create an array that includes the center point as the first point. This array is used as a starting point for a quaternion analysis of superposition.
      Parameters:
      vPts -
      Returns:
      array of points with first point center
    • getRmsd

      public static float getRmsd(P3[][] centerAndPoints, Quat q)
    • getBestLineThroughPoints

      public static P3[] getBestLineThroughPoints(P3[] points, int nPoints)
      Get the endpoints of the best line through N points, where N >= 2
      Parameters:
      points -
      nPoints -
      Returns:
      end points
    • getProjectedLineSegment

      public static P3[] getProjectedLineSegment(P3[] points, int nPoints, P3 ptA, V3 unitVector, V3 vTemp)
    • isInTriangle

      public static boolean isInTriangle(P3 p, P3 a, P3 b, P3 c, V3 v0, V3 v1, V3 v2)
    • calcBestPlaneThroughPoints

      public static float calcBestPlaneThroughPoints(P3[] points, int nPoints, P4 plane)
      Calculate the best ax + by + cz + d = 0 plane through a number of points using a three-step check for the best plane based on normal distance. this simple calculation isn't perfect, but it does the job quickly and with no need for a full singular value decomposition.
      Parameters:
      points -
      nPoints -
      plane -
      Returns:
      RMSD for the best plane along with filling the plane itself
    • calcPlaneForMode

      public static float calcPlaneForMode(P3[] points, int nPoints, P4 plane, char mode)
      Compact calculation of the best pane using a simple method discussed at https://stackoverflow.com/questions/12299540/plane-fitting-to-4-or-more-xyz-points (A^T A)^-1 A^T B run three times to ensure that at least one is not perpendicular.
      Parameters:
      points -
      nPoints -
      plane - filled with best plane
      mode -
      Returns:
      rmsd
    • test

      public static void test()
    • getPointsOnPlane

      public static Lst<P3> getPointsOnPlane(P3[] pts, P4 plane)
      Based on a set of centering points, returns the list of points on a given plane.
      Parameters:
      pts - initial list centering points such as {1/2 1/2 0}
      plane -
      Returns:
      non-null list
    • getLatticePoints

      public static Lst<P3> getLatticePoints(Lst<P3> cpts, int h, int k, int l)
      Based on a set of centering points, creates a list of lattice points in place.
      Parameters:
      cpts - centering points such as {1/2 1/2 0}
      h -
      k -
      l -
      Returns:
      non-null list
    • computeHelicalAxis

      public static T3[] computeHelicalAxis(P3 a, P3 b, Quat dq)
      This method calculates measures relating to two points in space with related quaternion frame difference. It is used in Jmol for calculating straightness and many other helical quantities.
      Parameters:
      a -
      b -
      dq -
      Returns:
      new T3[] { pt_a_prime, n, r, P3.new3(theta, pitch, residuesPerTurn), pt_b_prime };