Package javajs.util
Class Measure
java.lang.Object
javajs.util.Measure
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
calcAveragePoint
(P3 pointA, P3 pointB, P3 pointC) static void
calcAveragePointN
(P3[] points, int nPoints, P3 averagePoint) static void
calcBestAxisThroughPoints
(P3[] points, int nPoints, P3 axisA, V3 axisUnitVector, V3 vectorProjection, int nTriesMax) 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.static void
note that if vAB or vAC is dispensible, vNormNorm can be one of themstatic 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.static Quat
calculateQuaternionRotation
(P3[][] centerAndPoints, float[] retStddev) Closed-form solution of absolute orientation requiring 1:1 mapping of positions.static float
static float
computeAngleABC
(T3 pointA, T3 pointB, T3 pointC, boolean asDegrees) static T3[]
computeHelicalAxis
(P3 a, P3 b, Quat dq) This method calculates measures relating to two points in space with related quaternion frame difference.static float
computeTorsion
(T3 p1, T3 p2, T3 p3, T3 p4, boolean asDegrees) static float
directedDistanceToPlane
(P3 pt, P4 plane, P3 ptref) static float
distanceToPlane
(P4 plane, T3 pt) static float
distanceToPlaneD
(P4 plane, float d, P3 pt) static float
distanceToPlaneV
(V3 norm, float w, P3 pt) static float
static P3[]
getBestLineThroughPoints
(P3[] points, int nPoints) Get the endpoints of the best line through N points, where N >= 2static void
static P3[]
getCenterAndPoints
(Lst<P3> vPts) from a list of points, create an array that includes the center point as the first point.static float
static P3
Calculate the intersection of a line with a plane.getIntersectionPP
(P4 plane1, P4 plane2) Calculate the line that is the intersection of two planes.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.static boolean
static float
static void
getNormalToLine
(P3 pointA, P3 pointB, V3 vNormNorm) 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.static void
getPlaneThroughPoint
(T3 pt, V3 normal, P4 plane) static P4
getPointsOnPlane
(P3[] pts, P4 plane) Based on a set of centering points, returns the list of points on a given plane.static P3[]
getProjectedLineSegment
(P3[] points, int nPoints, P3 ptA, V3 unitVector, V3 vTemp) static float
static float
Fills a 4x4 matrix with rotation-translation of mapped points A to B.static boolean
isInTetrahedron
(P3 pt, P3 ptA, P3 ptB, P3 ptC, P3 ptD, P4 plane, V3 vTemp, V3 vTemp2, boolean fullyEnclosed) static boolean
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 vectorProjectionstatic void
test()
transformPoints
(Lst<P3> vPts, M4 m4, P3 center)
-
Field Details
-
radiansPerDegree
public static final float radiansPerDegree- See Also:
-
axisY
-
-
Constructor Details
-
Measure
public Measure()
-
-
Method Details
-
computeAngle
-
computeAngleABC
-
computeTorsion
-
getPlaneThroughPoints
-
getPlaneThroughPoint
-
distanceToPlane
-
directedDistanceToPlane
-
distanceToPlaneD
-
distanceToPlaneV
-
calcNormalizedNormal
note that if vAB or vAC is dispensible, vNormNorm can be one of them- Parameters:
pointA
-pointB
-pointC
-vNormNorm
-vAB
-
-
getDirectedNormalThroughPoints
-
getNormalThroughPoints
- Parameters:
pointA
-pointB
-pointC
-vNorm
-vTemp
-- Returns:
- w
-
getPlaneProjection
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 abdvTemp
-- Returns:
- true if winding is CCW; false if CW
-
getNormalToLine
-
getBisectingPlane
-
projectOntoAxis
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 projectedptA
- input point on lineaxisUnitVector
- input unit vectorvectorProjection
- 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
-
calcAveragePoint
-
calcAveragePointN
-
transformPoints
-
isInTetrahedron
-
getIntersectionPP
Calculate the line that is the intersection of two planes.- Parameters:
plane1
-plane2
-- Returns:
- [ point, vector ] or []
-
getIntersection
Calculate the intersection of a line with a plane.- Parameters:
pt1
- point on linev
- unit vector of lineplane
-ptRet
- point of intersection of line with planetempNorm
-vTemp
-- Returns:
- ptRtet
-
calculateQuaternionRotation
Closed-form solution of absolute orientation requiring 1:1 mapping of positions.- Parameters:
centerAndPoints
-retStddev
-- Returns:
- unit quaternion representation rotation
-
getTransformMatrix4
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 returnedcenterA
- return center of rotation; if null, then standard 4x4 matrix is returned- Returns:
- stdDev
-
getCenterAndPoints
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
-
getBestLineThroughPoints
Get the endpoints of the best line through N points, where N >= 2- Parameters:
points
-nPoints
-- Returns:
- end points
-
getProjectedLineSegment
-
isInTriangle
-
calcBestPlaneThroughPoints
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
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 planemode
-- Returns:
- rmsd
-
test
public static void test() -
getPointsOnPlane
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
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
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 };
-