Package mgui.geometry.util
Class GeometryFunctions
java.lang.Object
mgui.interfaces.Utility
mgui.geometry.util.GeometryFunctions
public class GeometryFunctions extends Utility
Utility class providing a library of common geometric functions. All functions in this class are blocking,
meaning that if they need to run in a worker thread, they should be called from that thread.
TODO: All functions should use double
for calculations, to minimize rounding errors.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Andrew Reid
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
GeometryFunctions.AnglePoint2D
static class
GeometryFunctions.Point3fComp
-
Field Summary
Fields Modifier and Type Field Description static double
error
Acceptable margin of error -
Constructor Summary
Constructors Constructor Description GeometryFunctions()
-
Method Summary
Modifier and Type Method Description static int
compareDouble(double a, double b)
Returns -1 if a < b, 0 if a = b, +1 if a > b, within the limits oferror
.static int
compareDouble(double a, double b, double error)
Returns -1 if a < b, 0 if a = b, +1 if a > b, within the limits oferror
.static int
compareFloat(float a, float b)
Returns -1 if a < b, 0 if a = b, +1 if a > b, within the limits oferror
.static int
compareFloat(float a, float b, double error)
Returns -1 if a < b, 0 if a = b, +1 if a > b, within the limits oferror
.static int
compareToPlane(org.jogamp.vecmath.Point3d pt, Plane3D plane)
Determines the position ofpt
with respect toplane
.static int
compareToPlane(org.jogamp.vecmath.Point3f pt, Plane3D plane)
Determines the position ofpt
with respect toplane
.static boolean
crosses(Box3D box1, Box3D box2)
Determines whether the spaces defined by these boxes intersect.static boolean
crosses(LineSegment2D l1, LineSegment2D l2)
Determines whether the line segmentsl1
andl2
cross.static boolean
crosses(LineSegment2D segment, Rect2D rect)
static boolean
crosses(Rect2D rect1, Rect2D rect2)
static boolean
crosses(Vector2D vector, Rect2D rect)
Determines whethervector
crossesrect
.static boolean
crosses(Vector2D vector, Rect2D rect, boolean is_infinite)
Determines whethervector
crossesrect
.static boolean
crossesPlane(Shape3D b, Plane3D p)
Determines whether planep
crosses boxb
.static org.jogamp.vecmath.Vector3f
flipVector(org.jogamp.vecmath.Vector3f v)
Flipsv
.static double
getAngle(org.jogamp.vecmath.Point2d p1, org.jogamp.vecmath.Point2d p2)
static double
getAngle(org.jogamp.vecmath.Point2f p1, org.jogamp.vecmath.Point2f p2)
static double
getAngle(org.jogamp.vecmath.Point2f A, org.jogamp.vecmath.Point2f B, org.jogamp.vecmath.Point2f C)
Determines the angle between vectors AB and BC.static double
getAngle(org.jogamp.vecmath.Point3f A, org.jogamp.vecmath.Point3f B, org.jogamp.vecmath.Point3f C, org.jogamp.vecmath.Point3f D)
Returns the angle between two triangular faces, defined such that AB is a common edge.static double
getAngleDiff(double a1, double a2)
static double
getAngleDiffCW(double a1, double a2)
static double
getAngleTangent(double a1, double a2)
Returns an angle tangent to the given node angles in a polygonstatic float
getArea(Polygon2D thisPoly)
Determines the area ofthisPoly
.static float
getArea(Triangle3D tri)
Determines the area of triangletri
.static float
getArea(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2, org.jogamp.vecmath.Point3f p3)
Determines the area of triangle defined by three points.static org.jogamp.vecmath.Vector4f
getAveragePlane(java.util.ArrayList<org.jogamp.vecmath.Point3f> nodes)
Return a plane representing the average plane of a set of nodes note, in the degenerative case the average cross product will be zero; thus no plane will be defined.static Box3D
getBoundingBox(java.util.ArrayList<org.jogamp.vecmath.Point3f> nodes)
Returns the box (having standard axes) that bounds this set of points.static Box3D
getBox3D(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2)
Returns a Box3D defined by two pointsstatic org.jogamp.vecmath.Point3f
getCenterOfGravity(java.util.ArrayList<org.jogamp.vecmath.Point3f> nodes)
Returns the center of gravity of this shape, which is the mean of its coordinates.static org.jogamp.vecmath.Point3d
getCenterOfGravity(Cube3D thisCube)
Returns the center of gravity of this shape, which is the mean of its coordinates.static org.jogamp.vecmath.Point2f
getCenterOfGravity(Shape2D s)
static int
getClosestVertex(Shape2D shape, org.jogamp.vecmath.Point2f point)
Returns the vertex ofshape
which is closest topoint
.static int
getClosestVertex(Shape3D shape, org.jogamp.vecmath.Point3f point)
Returns the vertex ofshape
which is closest topoint
.static Polygon2D
getConvexHull(java.util.ArrayList<org.jogamp.vecmath.Point2d> points)
Returns the convex hull ofpoints
.static Polygon2D
getConvexHull2f(java.util.ArrayList<org.jogamp.vecmath.Point2f> points)
Returns the convex hull ofpoints
.static org.jogamp.vecmath.Vector3f
getCrossProduct(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2, org.jogamp.vecmath.Point3f p3)
static org.jogamp.vecmath.Vector3d
getCrossProduct(org.jogamp.vecmath.Vector3d v1, org.jogamp.vecmath.Vector3d v2)
static org.jogamp.vecmath.Vector3f
getCrossProduct(org.jogamp.vecmath.Vector3f v1, org.jogamp.vecmath.Vector3f v2)
static double
getCrossProductDist(org.jogamp.vecmath.Point2f pt1, org.jogamp.vecmath.Point2f pt2, org.jogamp.vecmath.Point2f pt3)
static java.util.ArrayList<MguiFloat>
getCrossProducts(Polygon2D thisPoly)
Returns a list of cross-products corresponding the the vertices ofthisPoly
.static org.jogamp.vecmath.Point2f
getCubicSplinePt(org.jogamp.vecmath.Point2f N1, org.jogamp.vecmath.Point2f C1, org.jogamp.vecmath.Point2f N2, org.jogamp.vecmath.Point2f C2, double t)
Given two nodes N1 and N2 and their control points C1, C2, return a point along the cubic spline function defined by these points, at distance t (where t = 0 at N1 and t = 1 at N2) along the curve.static double
getDegToRad(double degAngle)
Converts degrees to radians.static double
getDistance(org.jogamp.vecmath.Point2f pt1, org.jogamp.vecmath.Point2f pt2)
static double
getDistance(org.jogamp.vecmath.Point3d pt, Plane3D plane)
Calculates the distance frompt
toplane
, signed with respect to its normal.static float
getDistance(org.jogamp.vecmath.Point3f pt, Plane3D plane)
Calculates the absolute distance frompt
toplane
static double
getDotProduct(org.jogamp.vecmath.Point2f pt1, org.jogamp.vecmath.Point2f pt2, org.jogamp.vecmath.Point2f pt3)
static org.jogamp.vecmath.Point2f
getEndpoint(org.jogamp.vecmath.Point2f startPt, double angle, double length)
static org.jogamp.vecmath.Point3f
getGeometricCenter(java.util.ArrayList<org.jogamp.vecmath.Point3f> nodes)
Returns the geometric center of this list of points, which is the center of its bounding box.static org.jogamp.vecmath.Point3f
getGeometricCenter(Shape3D shape)
Returns the geometric center of this list of points, which is the center of its bounding box.static org.jogamp.vecmath.Point2f[]
getIntersectionEdge(Triangle3D tri, Plane3D p)
Returns the edge of intersection for triangle tri with plane p.static int[]
getIntersectionEdge(Triangle3D tri, Plane3D p, org.jogamp.vecmath.Point2f[] edge)
Sets the edge of intersection for triangle tri with plane p.static double
getIntersectionEdgeRatio(org.jogamp.vecmath.Point3d pt1, org.jogamp.vecmath.Point3d pt2, Plane3D plane)
Determines the ratio along the line segmentpt1-pt2
at which it intersectsplane
.static float
getIntersectionEdgeRatio(org.jogamp.vecmath.Point3f pt1, org.jogamp.vecmath.Point3f pt2, Plane3D plane)
Determines the ratio along the line segmentpt1-pt2
at which it intersectsplane
.static float
getIntersectionEdgeRatio(org.jogamp.vecmath.Point3f pt, org.jogamp.vecmath.Vector3f v, Plane3D p)
static Vector2D
getIntersectionLine(Plane3D plane1, Plane3D plane2)
Determines the line of intersection between two planes, and returns the result in the 2D coordinate system ofplane2
.static org.jogamp.vecmath.Point2f
getIntersectionPoint(LineSegment2D l1, LineSegment2D l2)
static org.jogamp.vecmath.Point2f
getIntersectionPoint(LineSegment2D l1, LineSegment2D l2, boolean test_crossing, boolean is_infinite)
Returns the intersection point between two lines or line segments.static org.jogamp.vecmath.Point2d
getIntersectionPoint(org.jogamp.vecmath.Point3d p1, org.jogamp.vecmath.Point3d p2, Plane3D plane)
Determine the point at which the line segment described byp1
andp2
intersectsplane
.static org.jogamp.vecmath.Point2d
getIntersectionPoint(org.jogamp.vecmath.Point3d pt, org.jogamp.vecmath.Vector3d v, Plane3D p)
Determine the point at which the line segment described by pt and v intersects plane p.static org.jogamp.vecmath.Point2f
getIntersectionPoint(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2, Plane3D plane)
Determine the point at which the line segment described byp1
andp2
intersectsplane
.static org.jogamp.vecmath.Point2f
getIntersectionPoint(org.jogamp.vecmath.Point3f pt, org.jogamp.vecmath.Vector3f vector, Plane3D plane)
Determine the point at which the line segment described by pt and v intersects plane p.static org.jogamp.vecmath.Point3d
getIntersectionPoint3D(org.jogamp.vecmath.Point3d pt1, org.jogamp.vecmath.Point3d pt2, Plane3D plane)
Returns point at which the line segmentpt1
-pt2
intersectsplane
.static org.jogamp.vecmath.Point3f
getIntersectionPoint3D(org.jogamp.vecmath.Point3f pt1, org.jogamp.vecmath.Point3f pt2, Plane3D plane)
Returns point at which the line segmentpt1
-pt2
intersectsplane
.static org.jogamp.vecmath.Point3f
getIntersectionPoint3D(org.jogamp.vecmath.Point3f pt, org.jogamp.vecmath.Vector3f v, Plane3D plane)
Returns point at which the line segment defined bypt1
andv
intersectsplane
.static org.jogamp.vecmath.Point3f
getIntersectionPoint3D(org.jogamp.vecmath.Point3f pt, org.jogamp.vecmath.Vector3f v, Triangle3D tri)
Determines the point at which the line segment defined bypt
andv
intersects triangletri
.static org.jogamp.vecmath.Point3f[]
getIntersectionPoints(Triangle3D tri, Plane3D plane)
Determines the points at whichtri
intersectsplane
.static org.jogamp.vecmath.Point3f[]
getIntersectionPoints(Triangle3D tri, Plane3D plane, boolean include_kiss)
Determines the points at whichtri
intersectsplane
.static org.jogamp.vecmath.Point3f[]
getIntersectionSegment(Triangle3D tri1, Triangle3D tri2)
Determines the line segment defining the seam of wheretri1
andtri2
intersect.static LineSegment2D
getIntersectionSegment(Vector2D vector, Rect2D rect)
Calculates a line segment wherevector
crossesrect
.static Polygon2D
getIsInternalConcavePoly(Polygon2D poly, org.jogamp.vecmath.Point2f pt)
static org.jogamp.vecmath.Matrix4d
getJamaMatrixAsMatrix4d(Jama.Matrix matrix)
static org.jogamp.vecmath.Vector3f
getMatrixProduct(org.jogamp.vecmath.Vector3f v, org.jogamp.vecmath.Matrix4f M)
Multipliesv
byM
, using only the first 3 x 3 subset ofM
.static org.jogamp.vecmath.Point3f
getMaxPt(Shape3D shape)
Determines a maximum point max_x, max_y, max_z fromshape
.static org.jogamp.vecmath.Point3f
getMaxPt(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2)
Determines a maximum point max_x, max_y, max_z from two points.static org.jogamp.vecmath.Point2f
getMidPoint(org.jogamp.vecmath.Point2f pt1, org.jogamp.vecmath.Point2f pt2, double pos)
Determines the mid-point of the line segment defined bypt1
andpt2
, at the positionpos
, which must range from 0.0 (i.e., atpt1
to 1.0 (i.e., at
pt2
).static org.jogamp.vecmath.Point3f
getMidPt(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2)
Computes the mid-point of the line segment defined byp1
andp2
.static double
getMinimalAngle(double thisAngle)
static org.jogamp.vecmath.Point3f
getMinPt(Shape3D shape)
Determines a minimum point min_x, min_y, min_z fromshape
.static org.jogamp.vecmath.Point3f
getMinPt(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2)
Determines a minimum point min_x, min_y, min_z from two points.static int
getNearestNeighbour(org.jogamp.vecmath.Point2f p, java.util.ArrayList<org.jogamp.vecmath.Point2f> nodes)
Determines the nearest neighbour ofp
in the listnodes
.static float[]
getNodeAngles(Polygon2D polygon)
Returns an array of angles made by each node ofpolygon
static java.util.ArrayList<java.lang.Integer>
getNodesInsideProjectionLimits(java.util.ArrayList<org.jogamp.vecmath.Point3f> nodes, Plane3D plane, float above_limit, float below_limit)
Determines which points innodes
lie within the projection limits specified byplane
,above_limit
, andbelow_limit
.static org.jogamp.vecmath.Vector2d
getNormal(org.jogamp.vecmath.Point2d p0, org.jogamp.vecmath.Point2d p, org.jogamp.vecmath.Point2d p1, boolean CW)
Determines the vector normal to the 2D curve at pointp
, wherep0
andp1
are the point before and afterp
, respectively.static org.jogamp.vecmath.Vector2f
getNormal(org.jogamp.vecmath.Point2f p0, org.jogamp.vecmath.Point2f p, org.jogamp.vecmath.Point2f p1, boolean CW)
Determines the vector normal to the 2D curve at pointp
, wherep0
andp1
are the point before and afterp
, respectively.static java.util.ArrayList<org.jogamp.vecmath.Vector2f>
getNormals(Polygon2D polygon, boolean CW)
Returns a list of vectors which are the normals to the nodes ofpolygon
, given a direction of normal, indicated byCW
(clockwise iftrue
, counterclockwise iffalse
).Plane3D
getOrthogonalPlane(Plane3D plane, LineSegment3D line)
Returns a plane which is orthogonal toplane
, with a y-axis defined byline
.static Plane3D
getOrthogonalRegressionPlane(java.util.ArrayList<org.jogamp.vecmath.Point3f> points)
Calculates and returns the orthogonal distance regression ("best-fit") plane for a set of points in R3.static Plane3D
getPlane(Triangle3D tri)
Returns a plane containingtri
.static org.jogamp.vecmath.Vector4f
getPlaneEquation(org.jogamp.vecmath.Point3f p, org.jogamp.vecmath.Vector3f normal)
Returns a plane equation as a vector {a, b, c, d}, givenp
, a point in the plane, andnormal
, its normal vector.static GeometryFunctions.Point3fComp
getPoint3fComp()
static org.jogamp.vecmath.Point3f
getPointFromPlane(org.jogamp.vecmath.Point2f point, Plane3D plane)
Return a 3D Cartesian coordinate for the specified 2D point in a plane parallel toplane
.static org.jogamp.vecmath.Point3f
getPointFromSection(Plane3D refPlane, float dist, org.jogamp.vecmath.Point2f point)
Return a 3D Cartesian coordinate for the specified 2D point in a plane parallel to refPlane, and separated from it byalong its normal vector. static org.jogamp.vecmath.Point3f
getPointFromSection(org.jogamp.vecmath.Point2f point, Plane3D plane)
Deprecated.Use getPointFromPlanestatic java.util.ArrayList<org.jogamp.vecmath.Point3f>
getPointsFromPlane(java.util.ArrayList<org.jogamp.vecmath.Point2f> points, Plane3D plane)
Return a set of 3D Cartesian coordinates for the specified 2D points in a plane parallel toplane
.static Polygon3D
getPolygonFromPlane(Polygon2D poly2d, Plane3D plane)
Returns a 3D polygon which is the representation of a 2D polygon expressed on the given plane.static org.jogamp.vecmath.Point2d
getProjectedPoint(org.jogamp.vecmath.Point3d pt, Plane3D plane)
Project pointpt
onto planeplane
, alongplane
's normal vector.static org.jogamp.vecmath.Point2f
getProjectedPoint(org.jogamp.vecmath.Point3f pt, Plane3D plane)
Project pointpt
onto planeplane
, alongplane
's normal vector.static org.jogamp.vecmath.Point2f
getProjectedPoint(org.jogamp.vecmath.Point3f pt, org.jogamp.vecmath.Vector3f proj, Plane3D plane)
Project pointpt
onto planeplane
, alongplane
's normal vector.static org.jogamp.vecmath.Point3f
getProjectedPoint3D(org.jogamp.vecmath.Point3f pt, Plane3D plane)
Project pointpt
onto planeplane
, alongplane
's normal vector.static org.jogamp.vecmath.Point3f
getProjectedPoint3D(org.jogamp.vecmath.Point3f pt, org.jogamp.vecmath.Vector3f v, Plane3D plane)
Project pointpt
onto planeplane
, along vectorv
.static java.util.ArrayList<org.jogamp.vecmath.Point2f>
getProjectedToPlane(java.util.ArrayList<org.jogamp.vecmath.Point3f> nodes, Plane3D plane)
Projectsnodes
ontoplane
and returns the 2D points.static Triangle2D
getProjectedToPlane(Triangle3D tri, Plane3D plane)
Projectstri
ontoplane
and returns the 2D triangle.static org.jogamp.vecmath.Vector3f
getProjectedToPlane(org.jogamp.vecmath.Vector3f vector, org.jogamp.vecmath.Vector3f normal)
Projectsvector
onto a plane with normalnormal
.static org.jogamp.vecmath.Vector2f
getProjectedToPlane2D(org.jogamp.vecmath.Vector3f vector, Plane3D plane)
Projectsvector
onto planeplane
along its normal.static org.jogamp.vecmath.Vector2f
getProjectedToPlane2D(org.jogamp.vecmath.Vector3f vector, org.jogamp.vecmath.Vector3f proj, Plane3D plane)
Projectsvector
onto planeplane
along its normal.static org.jogamp.vecmath.Vector3f
getProjectedVector(org.jogamp.vecmath.Vector3f v, org.jogamp.vecmath.Vector3f u)
Returns the projection of v onto u.static org.jogamp.vecmath.Quat4d
getQuaternion(org.jogamp.vecmath.Vector3d axis, double angle)
static double
getRadToDeg(double radAngle)
Converts radians to degrees.static Polygon2D
getReversePolygon(Polygon2D thisPoly)
Reverses the direction of this polygon (CW -> CCW or vice versa)static org.jogamp.vecmath.Vector2d
getRotatedVector2D(org.jogamp.vecmath.Vector2d vector, double angle)
Rotatesvector
byangle
, specified in radians.static org.jogamp.vecmath.Vector2f
getRotatedVector2D(org.jogamp.vecmath.Vector2f vector, double angle)
Rotatesvector
byangle
, specified in radians.static org.jogamp.vecmath.Matrix4d
getRotationTransform(org.jogamp.vecmath.Vector3d axis, double angle)
Creates a transformation matrix representing a rotation aboutaxis
byangle
radians.static Rect2D
getScaledShape(org.jogamp.vecmath.Point2f scalePt, Rect2D thisRect, double scaleVal)
static float[]
getSegmentLengths(Polygon2D polygon)
Returns a list of the lengths of each segment inpolygon
.static boolean
getSegmentsIntersect(LineSegment2D l1, LineSegment2D l2)
Determines whether line segmentsl1
andl2
intersect.static boolean[][]
getSegmentsIntersect(Polygon2D poly1, Polygon2D poly2)
static double
getSignedAngle(org.jogamp.vecmath.Vector3d v1, org.jogamp.vecmath.Vector3d v2)
Determines the signed angle thatv1
makes withv2
.static double
getSignedDistance(org.jogamp.vecmath.Point3d pt, Plane3D plane)
Determines distance from pointpt
to planeplane
.static float
getSignedDistance(org.jogamp.vecmath.Point3f pt, Plane3D plane)
Determines distance from pointpt
to planeplane
.static Box3D
getUnionBounds(Box3D b1, Box3D b2)
static Rect2D
getUnionBounds(Rect2D r1, Rect2D r2)
static Sphere3D
getUnionSphere(Sphere3D s1, Sphere3D s2)
Returns a sphere that is the union of the two spheres s1 and s2static org.jogamp.vecmath.Vector2f
getVector(org.jogamp.vecmath.Point2f p1, org.jogamp.vecmath.Point2f p2)
static float
getVectorAngle(org.jogamp.vecmath.Vector2f vector)
Returns the angle that a 2D vector makes with the x-axis.static org.jogamp.vecmath.Point2f
getVectorEndpoint(org.jogamp.vecmath.Point2f startPt, org.jogamp.vecmath.Vector2f vector)
Returns the endpoint of a vector starting atstartPt
.static org.jogamp.vecmath.Vector3d
getVectorFromAngles(double angleX, double angleY)
static org.jogamp.java3d.Transform3D
getVectorRotation(Vector3D vector)
Determines the rotation that converts [1, 0, 0] tovector
.static void
getVectorTransform(org.jogamp.vecmath.Matrix4d M, org.jogamp.vecmath.Vector3d v)
static java.util.ArrayList<org.jogamp.vecmath.Point3f>
getVerticesFromSection(java.util.ArrayList<org.jogamp.vecmath.Point2f> vertices, Plane3D plane)
static double
getXAngle(org.jogamp.vecmath.Vector3d v)
static float
getXAngle(org.jogamp.vecmath.Vector3f vector)
Returns angle ofvector
with x-axis.static org.jogamp.vecmath.Vector4f
getXRotation(org.jogamp.vecmath.Vector4f plane, float r)
static double
getYAngle(org.jogamp.vecmath.Vector3d v)
static float
getYAngle(org.jogamp.vecmath.Vector3f vector)
Returns angle ofvector
with y-axis.static org.jogamp.vecmath.Vector4f
getYRotation(org.jogamp.vecmath.Vector4f plane)
Rotate this plane about the Y axisstatic org.jogamp.vecmath.Vector4f
getYRotation(org.jogamp.vecmath.Vector4f plane, float r)
static double
getZAngle(org.jogamp.vecmath.Vector3d v)
static float
getZAngle(org.jogamp.vecmath.Vector3f vector)
Returns angle ofvector
with z-axis.static org.jogamp.vecmath.Vector4f
getZRotation(org.jogamp.vecmath.Vector4f plane)
Rotate this plane about the Z axisstatic org.jogamp.vecmath.Vector4f
getZRotation(org.jogamp.vecmath.Vector4f plane, float r)
static boolean
intersects(Triangle3D tri, Plane3D plane)
Determines whether triangle intersects planestatic boolean
intersects(Triangle3D tri1, Triangle3D tri2)
Determines whethertri1
andtri2
intersect.static boolean
intersects(Vector3D vector, org.jogamp.vecmath.Point3f p)
Determines whetherp
intersectsvector
, within the tolerance set for this session instance (GeometryFunctions.error
).static boolean
intersects(Vector3D vector, org.jogamp.vecmath.Point3f p, double tolerance)
Determines whetherp
intersectsvector
, within the given tolerance.static boolean
intersects(org.jogamp.vecmath.Point3f p, org.jogamp.vecmath.Vector3f v, Triangle3D tri)
static boolean
isAbovePlane(org.jogamp.vecmath.Point3f pt, Plane3D p)
Deprecated.use compareToPlanestatic boolean
isClockwise(java.util.ArrayList<MguiFloat> crossProducts)
Determines from a list of vertex-wise cross-products whether a polygon is clockwise or not (i.e., counter-clockwise).static boolean
isClockwise(Polygon2D thisPoly)
Determines whether a polygon is clockwise or not (i.e., counter-clockwise).static boolean
isClockwise(org.jogamp.vecmath.Point2f p1, org.jogamp.vecmath.Point2f p2, org.jogamp.vecmath.Point2f p3)
Determines whether a triangle defined by three 2D points is clockwise or not (i.e., counter-clockwise).static boolean
isClockwise(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2, org.jogamp.vecmath.Point3f p3)
Determines whether a triangle defined by three 3D points is clockwise or not (i.e., counter-clockwise).static boolean
isCoincident(org.jogamp.vecmath.Point2f p1, org.jogamp.vecmath.Point2f p2)
Determines whetherp1
and p2 coincide, within the default tolerance distanceGeometryFunctions.error
.static boolean
isCoincident(org.jogamp.vecmath.Point2f p1, org.jogamp.vecmath.Point2f p2, float tolerance)
Determines whetherp1
and p2 coincide, within the given tolerance distance.static boolean
isCoincident(org.jogamp.vecmath.Point3d p1, org.jogamp.vecmath.Point3d p2)
Determines whetherp1
and p2 coincide, within the default tolerance distanceGeometryFunctions.error
.static boolean
isCoincident(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2)
Determines whetherp1
and p2 coincide, within the default tolerance distanceGeometryFunctions.error
.static boolean
isConvex(java.util.ArrayList<MguiFloat> crossProducts)
Determines from a list of vertex-wise cross-products whether a polygon is convex or not (i.e., concave).static boolean
isInPlane(Shape3D s, Plane3D p)
Determines whether shape s lies in plane pstatic boolean
isInPlane(org.jogamp.vecmath.Point3d pt, Plane3D plane)
Determines whether pointpt
lies inplane
static boolean
isInPlane(org.jogamp.vecmath.Point3d pt, org.jogamp.vecmath.Vector3d v, Plane3D plane)
Determines whether the given line segment lies inplane
.static boolean
isInPlane(org.jogamp.vecmath.Point3f pt, Plane3D plane)
Determines whether pointpt
lies in planeplane
static boolean
isInPlane(org.jogamp.vecmath.Point3f pt, org.jogamp.vecmath.Vector3f v, Plane3D plane)
Determines whether the given line segment lies inplane
.static boolean
isIntermediateAngleCW(double a_i, double a_1, double a_2)
static boolean
isInternalConcave(Polygon2D poly, org.jogamp.vecmath.Point2f pt)
Tests whether a point pt is contained within the boundary of a polygon poly.static boolean
isInternalConvex(Polygon2D poly, org.jogamp.vecmath.Point2f pt)
Tests whether a point pt is contained within the boundary of a convex polygon poly.static boolean
isNonZeroVector(org.jogamp.vecmath.Vector3d v)
static boolean
isNonZeroVector(org.jogamp.vecmath.Vector3f v)
static boolean
isOblique(double thisAngle)
static boolean
isObtuse(Triangle3D tri)
Determines whethertri
is an obtuse triangle.static boolean
isParallel(Plane3D plane1, Plane3D plane2)
Determines whether the two planes are parallel.static boolean
isValidPoint(org.jogamp.vecmath.Point2f p)
static boolean
isValidPoint(org.jogamp.vecmath.Point3f p)
static boolean
isValidSphere(Sphere3D s)
static boolean
isValidTriangle(Triangle3D t)
static boolean
isValidVector(org.jogamp.vecmath.Vector2f v)
static boolean
isValidVector(org.jogamp.vecmath.Vector3d v)
static boolean
isValidVector(org.jogamp.vecmath.Vector3f v)
static boolean
isZero(org.jogamp.vecmath.Tuple3f tuple)
Determines whethertuple
is of length zero.static void
rotate(Shape2D shape, org.jogamp.vecmath.Point2d base_point, double angle)
Rotatesshape
aboutbase_point
byangle
radians.static void
rotate(Shape2D shape, org.jogamp.vecmath.Point2f base_point, double angle)
Rotatesshape
aboutbase_point
byangle
radians.static void
rotate(Shape3D shape, org.jogamp.vecmath.Point3d base_point, org.jogamp.vecmath.Vector3d axis, double angle)
Rotates this shape about a base pointbase_point
and an axisaxis
byangle
radians.static void
rotate(Shape3D shape, org.jogamp.vecmath.Point3f base_point, org.jogamp.vecmath.Vector3f axis, double angle)
Rotates this shape about a base pointbase_point
and an axisaxis
byangle
radians.static boolean
transform(Shape shape, Jama.Matrix matrix)
Transformsshape
with the given affine transformation Jama matrixmatrix
.static boolean
transform(Shape shape, Jama.Matrix matrix, ProgressUpdater progress)
Transformsshape
with the given affine transformation Jama matrixmatrix
.static boolean
transform(Shape shape, org.jogamp.vecmath.Matrix4d matrix)
Transformsshape
with the given affine transformation matrixmatrix
.static boolean
transform(Shape shape, org.jogamp.vecmath.Matrix4d matrix, ProgressUpdater progress)
Transformsshape
with the given affine transformation matrixmatrix
.static boolean
transform(Shape shape, org.jogamp.vecmath.Matrix4f matrix)
Transformsshape
with the given affine transformation matrixmatrix
.static boolean
transform(Shape shape, org.jogamp.vecmath.Matrix4f matrix, ProgressUpdater progress)
Transformsshape
with the given affine transformation matrixmatrix
.static org.jogamp.vecmath.Vector3d
transform(org.jogamp.vecmath.Tuple3d vector, org.jogamp.vecmath.Matrix4d matrix)
Transformsvector
with the given affine transformation matrixmatrix
.static org.jogamp.vecmath.Vector3f
transform(org.jogamp.vecmath.Tuple3f tuple, org.jogamp.vecmath.Matrix4d matrix)
Transformsvector
with the given affine transformation matrixmatrix
.static org.jogamp.vecmath.Vector3f
transform(org.jogamp.vecmath.Tuple3f vector, org.jogamp.vecmath.Matrix4f matrix)
Transformsvector
with the given affine transformation matrixmatrix
.static void
translate(Shape3D shape, double x, double y, double z)
Translatesshape
by the specified x, y, and z distances.static void
translate(Shape3D shape, org.jogamp.vecmath.Vector3d v)
Translatesshape
by the specified vector.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
error
public static double errorAcceptable margin of error
-
-
Constructor Details
-
GeometryFunctions
public GeometryFunctions()
-
-
Method Details
-
transform
public static org.jogamp.vecmath.Vector3d transform(org.jogamp.vecmath.Tuple3d vector, org.jogamp.vecmath.Matrix4d matrix)Transformsvector
with the given affine transformation matrixmatrix
. Ignores the last column.- Parameters:
vector
-matrix
-- Returns:
- the result
-
transform
public static org.jogamp.vecmath.Vector3f transform(org.jogamp.vecmath.Tuple3f tuple, org.jogamp.vecmath.Matrix4d matrix)Transformsvector
with the given affine transformation matrixmatrix
.- Parameters:
vector
-matrix
-- Returns:
- the result
-
transform
public static org.jogamp.vecmath.Vector3f transform(org.jogamp.vecmath.Tuple3f vector, org.jogamp.vecmath.Matrix4f matrix)Transformsvector
with the given affine transformation matrixmatrix
.- Parameters:
vector
-matrix
-- Returns:
- the result
-
transform
Transformsshape
with the given affine transformation matrixmatrix
.- Parameters:
shape
-matrix
-- Returns:
-
transform
Transformsshape
with the given affine transformation matrixmatrix
.- Parameters:
shape
-matrix
-- Returns:
-
transform
public static boolean transform(Shape shape, org.jogamp.vecmath.Matrix4f matrix, ProgressUpdater progress)Transformsshape
with the given affine transformation matrixmatrix
. Updatesprogress_bar
with its progress.- Parameters:
shape
-matrix
-progress_bar
-- Returns:
-
transform
public static boolean transform(Shape shape, org.jogamp.vecmath.Matrix4d matrix, ProgressUpdater progress)Transformsshape
with the given affine transformation matrixmatrix
. Updatesprogress_bar
with its progress.- Parameters:
shape
-matrix
-progress_bar
-- Returns:
-
transform
Transformsshape
with the given affine transformation Jama matrixmatrix
.- Parameters:
shape
-matrix
-- Returns:
-
transform
Transformsshape
with the given affine transformation Jama matrixmatrix
. Updatesprogress_bar
with its progress.- Parameters:
shape
-matrix
-progress_bar
-- Returns:
-
getJamaMatrixAsMatrix4d
public static org.jogamp.vecmath.Matrix4d getJamaMatrixAsMatrix4d(Jama.Matrix matrix) -
isZero
public static boolean isZero(org.jogamp.vecmath.Tuple3f tuple)Determines whethertuple
is of length zero.- Parameters:
tuple
-- Returns:
-
getVectorAngle
public static float getVectorAngle(org.jogamp.vecmath.Vector2f vector)Returns the angle that a 2D vector makes with the x-axis. Angle will be expressed on the range [0, 2Pi].- Parameters:
vector
- - 2D vector to test- Returns:
- the angle that
vector
makes with the x-axis
-
getProjectedToPlane2D
public static org.jogamp.vecmath.Vector2f getProjectedToPlane2D(org.jogamp.vecmath.Vector3f vector, Plane3D plane)Projectsvector
onto planeplane
along its normal. Returns a 2D point in the coordinate system ofplane
. See http://www.euclideanspace.com/maths/geometry/elements/plane/lineOnPlane/index.htm- Parameters:
vector
-normal
-- Returns:
- the resulting projected vector 2D
-
getProjectedToPlane2D
public static org.jogamp.vecmath.Vector2f getProjectedToPlane2D(org.jogamp.vecmath.Vector3f vector, org.jogamp.vecmath.Vector3f proj, Plane3D plane)Projectsvector
onto planeplane
along its normal. Returns a 2D point in the coordinate system ofplane
. See http://www.euclideanspace.com/maths/geometry/elements/plane/lineOnPlane/index.htm- Parameters:
vector
-normal
-- Returns:
- the resulting projected vector 2D
-
getProjectedToPlane
public static org.jogamp.vecmath.Vector3f getProjectedToPlane(org.jogamp.vecmath.Vector3f vector, org.jogamp.vecmath.Vector3f normal)Projectsvector
onto a plane with normalnormal
. See http://www.euclideanspace.com/maths/geometry/elements/plane/lineOnPlane/index.htm- Parameters:
vector
-normal
-- Returns:
- the resulting projection
-
getProjectedToPlane
public static java.util.ArrayList<org.jogamp.vecmath.Point2f> getProjectedToPlane(java.util.ArrayList<org.jogamp.vecmath.Point3f> nodes, Plane3D plane)Projectsnodes
ontoplane
and returns the 2D points. -
getProjectedToPlane
Projectstri
ontoplane
and returns the 2D triangle. -
getMidPt
public static org.jogamp.vecmath.Point3f getMidPt(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2)Computes the mid-point of the line segment defined byp1
andp2
.- Parameters:
p1
-p2
-- Returns:
- the mid-point
-
isObtuse
Determines whethertri
is an obtuse triangle.- Parameters:
tri
-- Returns:
true
iftri
is obtuse,false
otherwise.
-
translate
Translatesshape
by the specified vector.- Parameters:
shape
-x
-y
-z
-
-
translate
Translatesshape
by the specified x, y, and z distances.- Parameters:
shape
-x
-y
-z
-
-
rotate
public static void rotate(Shape3D shape, org.jogamp.vecmath.Point3f base_point, org.jogamp.vecmath.Vector3f axis, double angle)Rotates this shape about a base pointbase_point
and an axisaxis
byangle
radians.- Parameters:
shape
- Shape to rotatebase_point
- Point about which to rotateaxis
- Rotation axisangle
- Angle, in radians
-
rotate
public static void rotate(Shape3D shape, org.jogamp.vecmath.Point3d base_point, org.jogamp.vecmath.Vector3d axis, double angle)Rotates this shape about a base pointbase_point
and an axisaxis
byangle
radians.- Parameters:
shape
- Shape to rotatebase_point
- Point about which to rotateaxis
- Rotation axisangle
- Angle, in radians
-
rotate
Rotatesshape
aboutbase_point
byangle
radians.- Parameters:
shape
-base_point
-angle
-
-
rotate
Rotatesshape
aboutbase_point
byangle
radians.- Parameters:
shape
-base_point
-angle
-
-
getVectorEndpoint
public static org.jogamp.vecmath.Point2f getVectorEndpoint(org.jogamp.vecmath.Point2f startPt, org.jogamp.vecmath.Vector2f vector)Returns the endpoint of a vector starting atstartPt
.- Parameters:
startPt
-vector
-- Returns:
- the calculated endpoint.
-
flipVector
public static org.jogamp.vecmath.Vector3f flipVector(org.jogamp.vecmath.Vector3f v)Flipsv
.- Parameters:
v
-- Returns:
- the flipped vector
-
getSignedAngle
public static double getSignedAngle(org.jogamp.vecmath.Vector3d v1, org.jogamp.vecmath.Vector3d v2)Determines the signed angle thatv1
makes withv2
.- Parameters:
v1
-v2
-- Returns:
- the signed angle.
-
getQuaternion
public static org.jogamp.vecmath.Quat4d getQuaternion(org.jogamp.vecmath.Vector3d axis, double angle) -
getCrossProducts
Returns a list of cross-products corresponding the the vertices ofthisPoly
.- Parameters:
thisPoly
-- Returns:
- list of cross-products
-
getProjectedVector
public static org.jogamp.vecmath.Vector3f getProjectedVector(org.jogamp.vecmath.Vector3f v, org.jogamp.vecmath.Vector3f u)Returns the projection of v onto u. Result is a scalar multiple of u.See http://everything2.com/index.pl?node_id=1390247
- Parameters:
u
-v
-- Returns:
- the projected vector.
-
getMaxPt
Determines a maximum point max_x, max_y, max_z fromshape
.- Parameters:
shape
-- Returns:
- the maximum point
-
getMinPt
Determines a minimum point min_x, min_y, min_z fromshape
.- Parameters:
shape
-- Returns:
- the minimum point
-
getMinPt
public static org.jogamp.vecmath.Point3f getMinPt(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2)Determines a minimum point min_x, min_y, min_z from two points.- Parameters:
p1
-p2
-- Returns:
- the minimum point
-
getMaxPt
public static org.jogamp.vecmath.Point3f getMaxPt(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2)Determines a maximum point max_x, max_y, max_z from two points.- Parameters:
p1
-p2
-- Returns:
- the maximum point
-
getArea
Determines the area of triangletri
.- Parameters:
tri
-- Returns:
- the computed area.
-
getArea
public static float getArea(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2, org.jogamp.vecmath.Point3f p3)Determines the area of triangle defined by three points.- Parameters:
p1
-p2
-p3
-- Returns:
- the computed area.
-
isConvex
Determines from a list of vertex-wise cross-products whether a polygon is convex or not (i.e., concave).- Parameters:
experimental
-crossProducts
-- Returns:
true
if polygon is convex,false
if it is concave.
-
isClockwise
Determines from a list of vertex-wise cross-products whether a polygon is clockwise or not (i.e., counter-clockwise).- Parameters:
crossProducts
-- Returns:
true
if polygon is clockwise,false
if it is counter-clockwise.
-
isClockwise
Determines whether a polygon is clockwise or not (i.e., counter-clockwise).- Parameters:
thisPoly
-- Returns:
true
if polygon is clockwise,false
if it is counter-clockwise.
-
isClockwise
public static boolean isClockwise(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2, org.jogamp.vecmath.Point3f p3)Determines whether a triangle defined by three 3D points is clockwise or not (i.e., counter-clockwise).NB --NOT YET IMPLEMENTED--
- Parameters:
p1
-p2
-p3
-- Returns:
true
if polygon is clockwise,false
if it is counter-clockwise.
-
isClockwise
public static boolean isClockwise(org.jogamp.vecmath.Point2f p1, org.jogamp.vecmath.Point2f p2, org.jogamp.vecmath.Point2f p3)Determines whether a triangle defined by three 2D points is clockwise or not (i.e., counter-clockwise).- Parameters:
p1
-p2
-p3
-- Returns:
true
if polygon is clockwise,false
if it is counter-clockwise.
-
getArea
Determines the area ofthisPoly
. Area will be signed, depending on whether polygon is clockwise or not.- Parameters:
thisPoly
-- Returns:
- the signed area of polygon
-
getReversePolygon
Reverses the direction of this polygon (CW -> CCW or vice versa)- Parameters:
thisPoly
- polygon to reverse- Returns:
- new Polygon2D object which is the reversed version of thisPoly
-
getNearestNeighbour
public static int getNearestNeighbour(org.jogamp.vecmath.Point2f p, java.util.ArrayList<org.jogamp.vecmath.Point2f> nodes)Determines the nearest neighbour ofp
in the listnodes
.- Parameters:
p
-nodes
-- Returns:
- the index of the nearest neighbour
-
getDistance
public static double getDistance(org.jogamp.vecmath.Point2f pt1, org.jogamp.vecmath.Point2f pt2) -
getAngle
public static double getAngle(org.jogamp.vecmath.Point2f A, org.jogamp.vecmath.Point2f B, org.jogamp.vecmath.Point2f C)Determines the angle between vectors AB and BC.- Parameters:
approved
-A
-B
-C
-- Returns:
- the calculated angle
-
getCrossProductDist
public static double getCrossProductDist(org.jogamp.vecmath.Point2f pt1, org.jogamp.vecmath.Point2f pt2, org.jogamp.vecmath.Point2f pt3) -
getDotProduct
public static double getDotProduct(org.jogamp.vecmath.Point2f pt1, org.jogamp.vecmath.Point2f pt2, org.jogamp.vecmath.Point2f pt3) -
isOblique
public static boolean isOblique(double thisAngle) -
getMinimalAngle
public static double getMinimalAngle(double thisAngle) -
getCrossProduct
public static org.jogamp.vecmath.Vector3d getCrossProduct(org.jogamp.vecmath.Vector3d v1, org.jogamp.vecmath.Vector3d v2) -
getCrossProduct
public static org.jogamp.vecmath.Vector3f getCrossProduct(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2, org.jogamp.vecmath.Point3f p3) -
getCrossProduct
public static org.jogamp.vecmath.Vector3f getCrossProduct(org.jogamp.vecmath.Vector3f v1, org.jogamp.vecmath.Vector3f v2) -
getScaledShape
-
getAngleDiff
public static double getAngleDiff(double a1, double a2) -
getCenterOfGravity
-
getAngleTangent
public static double getAngleTangent(double a1, double a2)Returns an angle tangent to the given node angles in a polygon- Parameters:
a1
- angle at previous nodea2
- angle at this node- Returns:
- tangential angle
-
getMidPoint
public static org.jogamp.vecmath.Point2f getMidPoint(org.jogamp.vecmath.Point2f pt1, org.jogamp.vecmath.Point2f pt2, double pos)Determines the mid-point of the line segment defined bypt1
andpt2
, at the positionpos
, which must range from 0.0 (i.e., atpt1
to 1.0 (i.e., at
pt2
).- Parameters:
pt1
-pt2
-pos
-- Returns:
null
ifpos
is not in the range [0,1]; the mid-point otherwise.
-
getEndpoint
public static org.jogamp.vecmath.Point2f getEndpoint(org.jogamp.vecmath.Point2f startPt, double angle, double length) -
getCubicSplinePt
public static org.jogamp.vecmath.Point2f getCubicSplinePt(org.jogamp.vecmath.Point2f N1, org.jogamp.vecmath.Point2f C1, org.jogamp.vecmath.Point2f N2, org.jogamp.vecmath.Point2f C2, double t)Given two nodes N1 and N2 and their control points C1, C2, return a point along the cubic spline function defined by these points, at distance t (where t = 0 at N1 and t = 1 at N2) along the curve.- Parameters:
N1
- first nodeC1
- first control pointN2
- second nodeC2
- second control pointt
- distance parameter- Returns:
- Point2f representing the point on the cubic spline curve defined by these parameters.
-
getAngle
public static double getAngle(org.jogamp.vecmath.Point2f p1, org.jogamp.vecmath.Point2f p2) -
getAngle
public static double getAngle(org.jogamp.vecmath.Point3f A, org.jogamp.vecmath.Point3f B, org.jogamp.vecmath.Point3f C, org.jogamp.vecmath.Point3f D)Returns the angle between two triangular faces, defined such that AB is a common edge.- Parameters:
A
-B
-C
-D
-- Returns:
- angle between faces ABC and ABD
-
getVectorFromAngles
public static org.jogamp.vecmath.Vector3d getVectorFromAngles(double angleX, double angleY) -
getXAngle
public static double getXAngle(org.jogamp.vecmath.Vector3d v) -
getYAngle
public static double getYAngle(org.jogamp.vecmath.Vector3d v) -
getZAngle
public static double getZAngle(org.jogamp.vecmath.Vector3d v) -
getXAngle
public static float getXAngle(org.jogamp.vecmath.Vector3f vector)Returns angle ofvector
with x-axis.- Parameters:
vector
-- Returns:
-
getYAngle
public static float getYAngle(org.jogamp.vecmath.Vector3f vector)Returns angle ofvector
with y-axis.- Parameters:
vector
-- Returns:
-
getZAngle
public static float getZAngle(org.jogamp.vecmath.Vector3f vector)Returns angle ofvector
with z-axis.- Parameters:
vector
-- Returns:
-
getSegmentLengths
Returns a list of the lengths of each segment inpolygon
.- Parameters:
polygon
-- Returns:
- a list of segment lengths, starting with segment [0,1]
-
getVectorTransform
public static void getVectorTransform(org.jogamp.vecmath.Matrix4d M, org.jogamp.vecmath.Vector3d v) -
getRotationTransform
public static org.jogamp.vecmath.Matrix4d getRotationTransform(org.jogamp.vecmath.Vector3d axis, double angle)Creates a transformation matrix representing a rotation aboutaxis
byangle
radians.- Parameters:
axis
-angle
-- Returns:
-
getVectorRotation
Determines the rotation that converts [1, 0, 0] tovector
.- Parameters:
v
-- Returns:
-
getNodeAngles
Returns an array of angles made by each node ofpolygon
- Parameters:
polygon
- The polygon for which to determine angles- Returns:
- a list of angles, starting at the angle made for node 0
-
getSegmentsIntersect
Determines whether line segmentsl1
andl2
intersect.- Parameters:
l1
-l2
-- Returns:
true
if they intersect, false if not.
-
getDegToRad
public static double getDegToRad(double degAngle)Converts degrees to radians.- Parameters:
degAngle
-- Returns:
- the converted value.
-
getRadToDeg
public static double getRadToDeg(double radAngle)Converts radians to degrees.- Parameters:
radAngle
-- Returns:
- the converted value.
-
getRotatedVector2D
public static org.jogamp.vecmath.Vector2f getRotatedVector2D(org.jogamp.vecmath.Vector2f vector, double angle)Rotatesvector
byangle
, specified in radians.- Parameters:
vector
- vector to rotateangle
- in radians- Returns:
- rotated vector
-
getRotatedVector2D
public static org.jogamp.vecmath.Vector2d getRotatedVector2D(org.jogamp.vecmath.Vector2d vector, double angle)Rotatesvector
byangle
, specified in radians.- Parameters:
vector
- vector to rotateangle
- in radians- Returns:
- rotated vector
-
isCoincident
public static boolean isCoincident(org.jogamp.vecmath.Point2f p1, org.jogamp.vecmath.Point2f p2, float tolerance)Determines whetherp1
and p2 coincide, within the given tolerance distance.- Parameters:
p1
-p2
-tolerance
-- Returns:
-
isCoincident
public static boolean isCoincident(org.jogamp.vecmath.Point2f p1, org.jogamp.vecmath.Point2f p2)Determines whetherp1
and p2 coincide, within the default tolerance distanceGeometryFunctions.error
.- Parameters:
p1
-p2
-tolerance
-- Returns:
-
isCoincident
public static boolean isCoincident(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2)Determines whetherp1
and p2 coincide, within the default tolerance distanceGeometryFunctions.error
.- Parameters:
p1
-p2
-tolerance
-- Returns:
-
isCoincident
public static boolean isCoincident(org.jogamp.vecmath.Point3d p1, org.jogamp.vecmath.Point3d p2)Determines whetherp1
and p2 coincide, within the default tolerance distanceGeometryFunctions.error
.- Parameters:
p1
-p2
-tolerance
-- Returns:
-
isIntermediateAngleCW
public static boolean isIntermediateAngleCW(double a_i, double a_1, double a_2) -
getAngleDiffCW
public static double getAngleDiffCW(double a1, double a2) -
getUnionBounds
-
getUnionBounds
-
getPointFromSection
public static org.jogamp.vecmath.Point3f getPointFromSection(Plane3D refPlane, float dist, org.jogamp.vecmath.Point2f point)Return a 3D Cartesian coordinate for the specified 2D point in a plane parallel to refPlane, and separated from it byalong its normal vector. - Parameters:
refPlane
- reference planedist
- distance of this point's plane from reference planepoint
- 2D point to determine 3D coordinates for- Returns:
- Point3d representing the location of this 2D point in 3D space
-
getPointFromSection
@Deprecated public static org.jogamp.vecmath.Point3f getPointFromSection(org.jogamp.vecmath.Point2f point, Plane3D plane)Deprecated.Use getPointFromPlane- Parameters:
point
-plane
-- Returns:
-
getPointsFromPlane
public static java.util.ArrayList<org.jogamp.vecmath.Point3f> getPointsFromPlane(java.util.ArrayList<org.jogamp.vecmath.Point2f> points, Plane3D plane)Return a set of 3D Cartesian coordinates for the specified 2D points in a plane parallel toplane
.- Parameters:
plane
- reference planepoints
- 2D points to determine 3D coordinates for- Returns:
- array of
Point3f
representing the location of this 2D point in R3
-
getPolygonFromPlane
Returns a 3D polygon which is the representation of a 2D polygon expressed on the given plane.- Parameters:
poly2d
-plane
-- Returns:
-
getPointFromPlane
public static org.jogamp.vecmath.Point3f getPointFromPlane(org.jogamp.vecmath.Point2f point, Plane3D plane)Return a 3D Cartesian coordinate for the specified 2D point in a plane parallel toplane
.- Parameters:
plane
- reference planepoint
- 2D point to determine 3D coordinates for- Returns:
Point3f
representing the location of this 2D point in R3
-
getVerticesFromSection
public static java.util.ArrayList<org.jogamp.vecmath.Point3f> getVerticesFromSection(java.util.ArrayList<org.jogamp.vecmath.Point2f> vertices, Plane3D plane) -
getCenterOfGravity
Returns the center of gravity of this shape, which is the mean of its coordinates. Compare togetGeometricCenter(java.util.ArrayList<org.jogamp.vecmath.Point3f>)
.- Parameters:
vertices
-- Returns:
-
getCenterOfGravity
public static org.jogamp.vecmath.Point3f getCenterOfGravity(java.util.ArrayList<org.jogamp.vecmath.Point3f> nodes)Returns the center of gravity of this shape, which is the mean of its coordinates. Compare togetGeometricCenter(java.util.ArrayList<org.jogamp.vecmath.Point3f>)
.- Parameters:
nodes
-- Returns:
-
getGeometricCenter
public static org.jogamp.vecmath.Point3f getGeometricCenter(java.util.ArrayList<org.jogamp.vecmath.Point3f> nodes)Returns the geometric center of this list of points, which is the center of its bounding box.- Parameters:
nodes
-- Returns:
-
getGeometricCenter
Returns the geometric center of this list of points, which is the center of its bounding box.- Parameters:
shape
-- Returns:
-
getBoundingBox
Returns the box (having standard axes) that bounds this set of points.- Parameters:
nodes
-- Returns:
- the box, or
null
ifnodes
has less than two nodes.
-
getUnionSphere
Returns a sphere that is the union of the two spheres s1 and s2- Parameters:
s1
-s2
-- Returns:
-
isValidPoint
public static boolean isValidPoint(org.jogamp.vecmath.Point3f p) -
isValidPoint
public static boolean isValidPoint(org.jogamp.vecmath.Point2f p) -
isValidVector
public static boolean isValidVector(org.jogamp.vecmath.Vector3d v) -
isValidVector
public static boolean isValidVector(org.jogamp.vecmath.Vector3f v) -
isValidVector
public static boolean isValidVector(org.jogamp.vecmath.Vector2f v) -
isNonZeroVector
public static boolean isNonZeroVector(org.jogamp.vecmath.Vector3d v) -
isNonZeroVector
public static boolean isNonZeroVector(org.jogamp.vecmath.Vector3f v) -
isValidSphere
-
isValidTriangle
-
getAveragePlane
public static org.jogamp.vecmath.Vector4f getAveragePlane(java.util.ArrayList<org.jogamp.vecmath.Point3f> nodes)Return a plane representing the average plane of a set of nodes note, in the degenerative case the average cross product will be zero; thus no plane will be defined. This should be handled.- Parameters:
nodes
- an ArrayList of Point3f nodes for which to calculate the plane- Returns:
- the average plane specified as a Vector4f
-
getZRotation
public static org.jogamp.vecmath.Vector4f getZRotation(org.jogamp.vecmath.Vector4f plane)Rotate this plane about the Z axis- Parameters:
plane
- to be rotated- Returns:
- Vector4f representing rotated plane
-
getYRotation
public static org.jogamp.vecmath.Vector4f getYRotation(org.jogamp.vecmath.Vector4f plane)Rotate this plane about the Y axis- Parameters:
plane
- to be rotated- Returns:
- Vector4f representing rotated plane
-
getYRotation
public static org.jogamp.vecmath.Vector4f getYRotation(org.jogamp.vecmath.Vector4f plane, float r) -
getXRotation
public static org.jogamp.vecmath.Vector4f getXRotation(org.jogamp.vecmath.Vector4f plane, float r) -
getZRotation
public static org.jogamp.vecmath.Vector4f getZRotation(org.jogamp.vecmath.Vector4f plane, float r) -
crossesPlane
Determines whether planep
crosses boxb
.- Parameters:
s
-p
-- Returns:
true
if it crosses,false
otherwise
-
isAbovePlane
Deprecated.use compareToPlaneDetermines whether point pt is located above plane p.- Parameters:
pt
-p
-- Returns:
-
compareToPlane
Determines the position ofpt
with respect toplane
.- Parameters:
pt
-plane
-- Returns:
- -1 if
pt
is below plane, 0 if it is on plane (within the error limits), and 1 if it is above plane
-
compareToPlane
Determines the position ofpt
with respect toplane
.- Parameters:
pt
-plane
-- Returns:
- -1 if
pt
is below plane, 0 if it is on plane, and 1 if it is above plane
-
getMatrixProduct
public static org.jogamp.vecmath.Vector3f getMatrixProduct(org.jogamp.vecmath.Vector3f v, org.jogamp.vecmath.Matrix4f M)Multipliesv
byM
, using only the first 3 x 3 subset ofM
.- Parameters:
v
-M
-- Returns:
-
getOrthogonalPlane
Returns a plane which is orthogonal toplane
, with a y-axis defined byline
.- Parameters:
plane
-line
-- Returns:
-
isInPlane
public static boolean isInPlane(org.jogamp.vecmath.Point3f pt, org.jogamp.vecmath.Vector3f v, Plane3D plane)Determines whether the given line segment lies inplane
.- Parameters:
pt
-v
-p
-- Returns:
-
isInPlane
public static boolean isInPlane(org.jogamp.vecmath.Point3d pt, org.jogamp.vecmath.Vector3d v, Plane3D plane)Determines whether the given line segment lies inplane
.- Parameters:
pt
-v
-p
-- Returns:
-
isInPlane
Determines whether pointpt
lies in planeplane
- Parameters:
pt
-plane
-- Returns:
true
ifpt
lies inplane
,false
otherwise.
-
isInPlane
Determines whether pointpt
lies inplane
- Parameters:
pt
-plane
-- Returns:
true
ifpt
lies inplane
,false
otherwise.
-
isInPlane
Determines whether shape s lies in plane p- Parameters:
pt
-p
-- Returns:
-
getSignedDistance
Determines distance from pointpt
to planeplane
. The sign of the result specifies on which side of the plane the point is located; i.e., with respect to the direction of its normal vector.- Parameters:
pt
-plane
-- Returns:
- the calculated distance.
-
getSignedDistance
Determines distance from pointpt
to planeplane
.- Parameters:
pt
-plane
-- Returns:
- the calculated distance.
-
getDistance
Calculates the absolute distance frompt
toplane
- Parameters:
pt
-plane
-- Returns:
-
getDistance
Calculates the distance frompt
toplane
, signed with respect to its normal.- Parameters:
pt
-plane
-- Returns:
-
getProjectedPoint
public static org.jogamp.vecmath.Point2f getProjectedPoint(org.jogamp.vecmath.Point3f pt, Plane3D plane)Project pointpt
onto planeplane
, alongplane
's normal vector. Return a Point2f whose coordinates are relative toplane
's base point and x- and y-axes.- Parameters:
pt
-plane
-- Returns:
-
getProjectedPoint
public static org.jogamp.vecmath.Point2d getProjectedPoint(org.jogamp.vecmath.Point3d pt, Plane3D plane)Project pointpt
onto planeplane
, alongplane
's normal vector. Return a Point2f whose coordinates are relative toplane
's base point and x- and y-axes.- Parameters:
pt
-plane
-- Returns:
-
getProjectedPoint
public static org.jogamp.vecmath.Point2f getProjectedPoint(org.jogamp.vecmath.Point3f pt, org.jogamp.vecmath.Vector3f proj, Plane3D plane)Project pointpt
onto planeplane
, alongplane
's normal vector. Return a Point2f whose coordinates are relative toplane
's base point and x- and y-axes.- Parameters:
pt
-plane
-- Returns:
-
getProjectedPoint3D
public static org.jogamp.vecmath.Point3f getProjectedPoint3D(org.jogamp.vecmath.Point3f pt, Plane3D plane)Project pointpt
onto planeplane
, alongplane
's normal vector.- Parameters:
pt
-plane
-- Returns:
- Point3f
-
getProjectedPoint3D
public static org.jogamp.vecmath.Point3f getProjectedPoint3D(org.jogamp.vecmath.Point3f pt, org.jogamp.vecmath.Vector3f v, Plane3D plane)Project pointpt
onto planeplane
, along vectorv
.- Parameters:
pt
-plane
-- Returns:
- Point3f
-
compareFloat
public static int compareFloat(float a, float b)Returns -1 if a < b, 0 if a = b, +1 if a > b, within the limits oferror
.- Parameters:
a
-b
-- Returns:
-
compareFloat
public static int compareFloat(float a, float b, double error)Returns -1 if a < b, 0 if a = b, +1 if a > b, within the limits oferror
.- Parameters:
a
-b
-- Returns:
-
compareDouble
public static int compareDouble(double a, double b)Returns -1 if a < b, 0 if a = b, +1 if a > b, within the limits oferror
.- Parameters:
a
-b
-- Returns:
-
compareDouble
public static int compareDouble(double a, double b, double error)Returns -1 if a < b, 0 if a = b, +1 if a > b, within the limits oferror
.- Parameters:
a
-b
-- Returns:
-
getSegmentsIntersect
-
getIntersectionSegment
Calculates a line segment wherevector
crossesrect
. Treatsvector
as an infinite line. Returnsnull
if vector does not crossrect
.- Parameters:
vector
-rect
-- Returns:
-
crosses
Determines whethervector
crossesrect
. Vector is treated as a line segment.- Parameters:
vector
-rect
-- Returns:
-
crosses
Determines whethervector
crossesrect
. Theis_infinite
flag indicates whethervector
should be treated as a line or a segment.- Parameters:
vector
-rect
-- Returns:
-
crosses
-
crosses
Determines whether the spaces defined by these boxes intersect.- Parameters:
box1
-box2
-- Returns:
-
isParallel
Determines whether the two planes are parallel.- Parameters:
plane1
-plane2
-- Returns:
-
getIntersectionLine
Determines the line of intersection between two planes, and returns the result in the 2D coordinate system ofplane2
. If the planes are parallel, returnsnull
.- Parameters:
plane1
-plane2
-- Returns:
-
getIntersectionPoint
-
getIntersectionPoint
public static org.jogamp.vecmath.Point2f getIntersectionPoint(LineSegment2D l1, LineSegment2D l2, boolean test_crossing, boolean is_infinite)Returns the intersection point between two lines or line segments.- Parameters:
l1
-l2
-test_crossing
-is_infinite
-- Returns:
-
getClosestVertex
Returns the vertex ofshape
which is closest topoint
.- Parameters:
shape
-point
-- Returns:
-
getClosestVertex
Returns the vertex ofshape
which is closest topoint
.- Parameters:
shape
-point
-- Returns:
-
getIntersectionPoint
public static org.jogamp.vecmath.Point2f getIntersectionPoint(org.jogamp.vecmath.Point3f pt, org.jogamp.vecmath.Vector3f vector, Plane3D plane)Determine the point at which the line segment described by pt and v intersects plane p. Return intersection point, or null if segment does not intersect plane.- Parameters:
pt
-v
-p
-- Returns:
-
getIntersectionPoint
public static org.jogamp.vecmath.Point2f getIntersectionPoint(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2, Plane3D plane)Determine the point at which the line segment described byp1
andp2
intersectsplane
. Returns intersection point in plane coordinates, ornull
if segment does not intersectplane
.- Parameters:
pt
-v
-p
-- Returns:
-
getIntersectionPoint
public static org.jogamp.vecmath.Point2d getIntersectionPoint(org.jogamp.vecmath.Point3d p1, org.jogamp.vecmath.Point3d p2, Plane3D plane)Determine the point at which the line segment described byp1
andp2
intersectsplane
. Returns intersection point in plane coordinates, ornull
if segment does not intersectplane
.- Parameters:
pt
-v
-p
-- Returns:
-
getIntersectionPoint
public static org.jogamp.vecmath.Point2d getIntersectionPoint(org.jogamp.vecmath.Point3d pt, org.jogamp.vecmath.Vector3d v, Plane3D p)Determine the point at which the line segment described by pt and v intersects plane p. Return intersection point, or null if segment does not intersect plane.- Parameters:
pt
-v
-p
-- Returns:
-
getIntersectionPoint3D
public static org.jogamp.vecmath.Point3f getIntersectionPoint3D(org.jogamp.vecmath.Point3f pt, org.jogamp.vecmath.Vector3f v, Triangle3D tri)Determines the point at which the line segment defined bypt
andv
intersects triangletri
. Returnsnull
if there is no intersection.- Parameters:
pt
-v
-tri
-- Returns:
- point of intersection, or
null
if there is no intersection
-
getIntersectionPoint3D
public static org.jogamp.vecmath.Point3f getIntersectionPoint3D(org.jogamp.vecmath.Point3f pt, org.jogamp.vecmath.Vector3f v, Plane3D plane)Returns point at which the line segment defined bypt1
andv
intersectsplane
. Returnsnull
if segment does not intersect the plane.- Parameters:
pt1
-pt2
-plane
-- Returns:
-
getIntersectionPoint3D
public static org.jogamp.vecmath.Point3f getIntersectionPoint3D(org.jogamp.vecmath.Point3f pt1, org.jogamp.vecmath.Point3f pt2, Plane3D plane)Returns point at which the line segmentpt1
-pt2
intersectsplane
. Returnsnull
if segment does not intersect the plane.- Parameters:
pt1
-pt2
-plane
-- Returns:
-
getIntersectionPoint3D
public static org.jogamp.vecmath.Point3d getIntersectionPoint3D(org.jogamp.vecmath.Point3d pt1, org.jogamp.vecmath.Point3d pt2, Plane3D plane)Returns point at which the line segmentpt1
-pt2
intersectsplane
. Returnsnull
if segment does not intersect the plane.- Parameters:
pt1
-pt2
-plane
-- Returns:
-
getIntersectionEdgeRatio
public static float getIntersectionEdgeRatio(org.jogamp.vecmath.Point3f pt, org.jogamp.vecmath.Vector3f v, Plane3D p) -
getIntersectionEdgeRatio
public static float getIntersectionEdgeRatio(org.jogamp.vecmath.Point3f pt1, org.jogamp.vecmath.Point3f pt2, Plane3D plane)Determines the ratio along the line segmentpt1-pt2
at which it intersectsplane
. Returns -1 if this segment does not crossplane
.- Parameters:
pt1
-pt2
-plane
-- Returns:
- the ratio along the line segment
pt1-pt2
at which it intersectsplane
. Returns -1 if this segment does not crossplane
.
-
getIntersectionEdgeRatio
public static double getIntersectionEdgeRatio(org.jogamp.vecmath.Point3d pt1, org.jogamp.vecmath.Point3d pt2, Plane3D plane)Determines the ratio along the line segmentpt1-pt2
at which it intersectsplane
. Returns -1 if this segment does not crossplane
.- Parameters:
pt1
-pt2
-plane
-- Returns:
- the ratio along the line segment
pt1-pt2
at which it intersectsplane
. Returns -1 if this segment does not crossplane
.
-
getIntersectionEdge
public static int[] getIntersectionEdge(Triangle3D tri, Plane3D p, org.jogamp.vecmath.Point2f[] edge)Sets the edge of intersection for triangle tri with plane p. Returns a two-element integer array indicating which sides intersected the plane, and sets theedge
parameter to the 2D planar coordinates of the intersection- Parameters:
tri
-p
-edge
-- Returns:
- two-element integer array indicating which sides intersected the plane
-
isInternalConvex
Tests whether a point pt is contained within the boundary of a convex polygon poly. If polygon is concave, or its concavity is unknown, the method isInternalConcave() should be used.- Parameters:
poly
-pt
-- Returns:
-
getVector
public static org.jogamp.vecmath.Vector2f getVector(org.jogamp.vecmath.Point2f p1, org.jogamp.vecmath.Point2f p2) -
isInternalConcave
Tests whether a point pt is contained within the boundary of a polygon poly. Polygon may be convex or concave; if it is known to be convex, the method isInternalConvex() should be used.- Parameters:
poly
-pt
-- Returns:
-
getIsInternalConcavePoly
-
getIntersectionEdge
Returns the edge of intersection for triangle tri with plane p. Returns null if triangle does not intersect the plane.- Parameters:
tri
-p
-- Returns:
- array of two Point2f objects representing the planar coordinates of the edge
-
getPoint3fComp
-
intersects
Determines whether triangle intersects plane- Parameters:
tri
-plane
-- Returns:
- true if it does, false otherwise
-
intersects
Determines whethertri1
andtri2
intersect.- Parameters:
tri1
-tri2
-- Returns:
-
getIntersectionSegment
public static org.jogamp.vecmath.Point3f[] getIntersectionSegment(Triangle3D tri1, Triangle3D tri2)Determines the line segment defining the seam of wheretri1
andtri2
intersect. Returns null if they do not intersect.- Parameters:
tri1
-tri2
-- Returns:
-
getBox3D
Returns a Box3D defined by two points- Parameters:
p1
-p2
-- Returns:
-
getIntersectionPoints
Determines the points at whichtri
intersectsplane
. Returnsnull
if it does not intersect; this includes the case where an edge of one triangle is exactly on the plane of (kissing) the other.- Parameters:
tri
-plane
-- Returns:
-
getIntersectionPoints
public static org.jogamp.vecmath.Point3f[] getIntersectionPoints(Triangle3D tri, Plane3D plane, boolean include_kiss)Determines the points at whichtri
intersectsplane
. Returnsnull
if it does not intersect;include_kiss
specifies whether to include the case where an edge of one triangle is exactly on the plane of (kissing) the other.- Parameters:
tri
-plane
-- Returns:
-
intersects
public static boolean intersects(org.jogamp.vecmath.Point3f p, org.jogamp.vecmath.Vector3f v, Triangle3D tri) -
intersects
Determines whetherp
intersectsvector
, within the tolerance set for this session instance (GeometryFunctions.error
).- Parameters:
vector
-p
-- Returns:
-
intersects
Determines whetherp
intersectsvector
, within the given tolerance.- Parameters:
vector
-p
-tolerance
-- Returns:
-
getPlaneEquation
public static org.jogamp.vecmath.Vector4f getPlaneEquation(org.jogamp.vecmath.Point3f p, org.jogamp.vecmath.Vector3f normal)Returns a plane equation as a vector {a, b, c, d}, givenp
, a point in the plane, andnormal
, its normal vector.See also the Wolfram definition.
- Parameters:
p
-normal
-- Returns:
-
getConvexHull2f
Returns the convex hull ofpoints
.- Parameters:
points
-- Returns:
-
getConvexHull
Returns the convex hull ofpoints
.- Parameters:
points
- the points from which to construct a convex hull- Returns:
- the 2D convex hull
-
getAngle
public static double getAngle(org.jogamp.vecmath.Point2d p1, org.jogamp.vecmath.Point2d p2) -
getPlane
Returns a plane containingtri
.- Parameters:
tri
-- Returns:
-
crosses
Determines whether the line segmentsl1
andl2
cross.- Parameters:
l1
-l2
-- Returns:
-
crosses
-
getOrthogonalRegressionPlane
public static Plane3D getOrthogonalRegressionPlane(java.util.ArrayList<org.jogamp.vecmath.Point3f> points)Calculates and returns the orthogonal distance regression ("best-fit") plane for a set of points in R3. See http://mathforum.org/library/drmath/view/63765.html for a description of this algorithm.- Parameters:
points
- Array of points, where n > 1 (otherwise returnsnull
)- Returns:
- Plane3D corresponding to the regression plane
-
getNodesInsideProjectionLimits
public static java.util.ArrayList<java.lang.Integer> getNodesInsideProjectionLimits(java.util.ArrayList<org.jogamp.vecmath.Point3f> nodes, Plane3D plane, float above_limit, float below_limit)Determines which points innodes
lie within the projection limits specified byplane
,above_limit
, andbelow_limit
. Vectors are normalized to unit vectors.- Parameters:
nodes
-plane
-above_limit
- distance along this plane's normalbelow_limit
- distance along the flipped normal- Returns:
- list of
Integer
s specifying which nodes are inside the limits (0), above the limits (1), or below the limits (-1)
-
getNormals
public static java.util.ArrayList<org.jogamp.vecmath.Vector2f> getNormals(Polygon2D polygon, boolean CW)Returns a list of vectors which are the normals to the nodes ofpolygon
, given a direction of normal, indicated byCW
(clockwise iftrue
, counterclockwise iffalse
). Vectors are normalized to unit vectors.- Parameters:
polygon
- polygon for which to determine normalsCW
- direction of normal (clockwise iftrue
, counterclockwise iffalse
)- Returns:
- list of normals
-
getNormal
public static org.jogamp.vecmath.Vector2f getNormal(org.jogamp.vecmath.Point2f p0, org.jogamp.vecmath.Point2f p, org.jogamp.vecmath.Point2f p1, boolean CW)Determines the vector normal to the 2D curve at pointp
, wherep0
andp1
are the point before and afterp
, respectively. One ofp0
orp1
(but not both) can benull
, indicating the start or end of a curve; the remaining point will be used to determine the normal. Vector is normalized to a unit vector.- Parameters:
p0
- point in curve beforep
p
- point in curve at which to determine normalp1
- point in curve afterp
CW
- indicates direction of normal (clockwise iftrue
, counterclockwise iffalse
)- Returns:
- the normal at
p
-
getNormal
public static org.jogamp.vecmath.Vector2d getNormal(org.jogamp.vecmath.Point2d p0, org.jogamp.vecmath.Point2d p, org.jogamp.vecmath.Point2d p1, boolean CW)Determines the vector normal to the 2D curve at pointp
, wherep0
andp1
are the point before and afterp
, respectively. One ofp0
orp1
(but not both) can benull
, indicating the start or end of a curve; the remaining point will be used to determine the normal. Vector is normalized to a unit vector.- Parameters:
p0
- point in curve beforep
p
- point in curve at which to determine normalp1
- point in curve afterp
CW
- indicates direction of normal (clockwise iftrue
, counterclockwise iffalse
)- Returns:
- the normal at
p
-