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 classGeometryFunctions.AnglePoint2Dstatic classGeometryFunctions.Point3fComp -
Field Summary
Fields Modifier and Type Field Description static doubleerrorAcceptable margin of error -
Constructor Summary
Constructors Constructor Description GeometryFunctions() -
Method Summary
Modifier and Type Method Description static intcompareDouble(double a, double b)Returns -1 if a < b, 0 if a = b, +1 if a > b, within the limits oferror.static intcompareDouble(double a, double b, double error)Returns -1 if a < b, 0 if a = b, +1 if a > b, within the limits oferror.static intcompareFloat(float a, float b)Returns -1 if a < b, 0 if a = b, +1 if a > b, within the limits oferror.static intcompareFloat(float a, float b, double error)Returns -1 if a < b, 0 if a = b, +1 if a > b, within the limits oferror.static intcompareToPlane(org.jogamp.vecmath.Point3d pt, Plane3D plane)Determines the position ofptwith respect toplane.static intcompareToPlane(org.jogamp.vecmath.Point3f pt, Plane3D plane)Determines the position ofptwith respect toplane.static booleancrosses(Box3D box1, Box3D box2)Determines whether the spaces defined by these boxes intersect.static booleancrosses(LineSegment2D l1, LineSegment2D l2)Determines whether the line segmentsl1andl2cross.static booleancrosses(LineSegment2D segment, Rect2D rect)static booleancrosses(Rect2D rect1, Rect2D rect2)static booleancrosses(Vector2D vector, Rect2D rect)Determines whethervectorcrossesrect.static booleancrosses(Vector2D vector, Rect2D rect, boolean is_infinite)Determines whethervectorcrossesrect.static booleancrossesPlane(Shape3D b, Plane3D p)Determines whether planepcrosses boxb.static org.jogamp.vecmath.Vector3fflipVector(org.jogamp.vecmath.Vector3f v)Flipsv.static doublegetAngle(org.jogamp.vecmath.Point2d p1, org.jogamp.vecmath.Point2d p2)static doublegetAngle(org.jogamp.vecmath.Point2f p1, org.jogamp.vecmath.Point2f p2)static doublegetAngle(org.jogamp.vecmath.Point2f A, org.jogamp.vecmath.Point2f B, org.jogamp.vecmath.Point2f C)Determines the angle between vectors AB and BC.static doublegetAngle(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 doublegetAngleDiff(double a1, double a2)static doublegetAngleDiffCW(double a1, double a2)static doublegetAngleTangent(double a1, double a2)Returns an angle tangent to the given node angles in a polygonstatic floatgetArea(Polygon2D thisPoly)Determines the area ofthisPoly.static floatgetArea(Triangle3D tri)Determines the area of triangletri.static floatgetArea(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.Vector4fgetAveragePlane(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 Box3DgetBoundingBox(java.util.ArrayList<org.jogamp.vecmath.Point3f> nodes)Returns the box (having standard axes) that bounds this set of points.static Box3DgetBox3D(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2)Returns a Box3D defined by two pointsstatic org.jogamp.vecmath.Point3fgetCenterOfGravity(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.Point3dgetCenterOfGravity(Cube3D thisCube)Returns the center of gravity of this shape, which is the mean of its coordinates.static org.jogamp.vecmath.Point2fgetCenterOfGravity(Shape2D s)static intgetClosestVertex(Shape2D shape, org.jogamp.vecmath.Point2f point)Returns the vertex ofshapewhich is closest topoint.static intgetClosestVertex(Shape3D shape, org.jogamp.vecmath.Point3f point)Returns the vertex ofshapewhich is closest topoint.static Polygon2DgetConvexHull(java.util.ArrayList<org.jogamp.vecmath.Point2d> points)Returns the convex hull ofpoints.static Polygon2DgetConvexHull2f(java.util.ArrayList<org.jogamp.vecmath.Point2f> points)Returns the convex hull ofpoints.static org.jogamp.vecmath.Vector3fgetCrossProduct(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2, org.jogamp.vecmath.Point3f p3)static org.jogamp.vecmath.Vector3dgetCrossProduct(org.jogamp.vecmath.Vector3d v1, org.jogamp.vecmath.Vector3d v2)static org.jogamp.vecmath.Vector3fgetCrossProduct(org.jogamp.vecmath.Vector3f v1, org.jogamp.vecmath.Vector3f v2)static doublegetCrossProductDist(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.Point2fgetCubicSplinePt(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 doublegetDegToRad(double degAngle)Converts degrees to radians.static doublegetDistance(org.jogamp.vecmath.Point2f pt1, org.jogamp.vecmath.Point2f pt2)static doublegetDistance(org.jogamp.vecmath.Point3d pt, Plane3D plane)Calculates the distance frompttoplane, signed with respect to its normal.static floatgetDistance(org.jogamp.vecmath.Point3f pt, Plane3D plane)Calculates the absolute distance frompttoplanestatic doublegetDotProduct(org.jogamp.vecmath.Point2f pt1, org.jogamp.vecmath.Point2f pt2, org.jogamp.vecmath.Point2f pt3)static org.jogamp.vecmath.Point2fgetEndpoint(org.jogamp.vecmath.Point2f startPt, double angle, double length)static org.jogamp.vecmath.Point3fgetGeometricCenter(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.Point3fgetGeometricCenter(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 doublegetIntersectionEdgeRatio(org.jogamp.vecmath.Point3d pt1, org.jogamp.vecmath.Point3d pt2, Plane3D plane)Determines the ratio along the line segmentpt1-pt2at which it intersectsplane.static floatgetIntersectionEdgeRatio(org.jogamp.vecmath.Point3f pt1, org.jogamp.vecmath.Point3f pt2, Plane3D plane)Determines the ratio along the line segmentpt1-pt2at which it intersectsplane.static floatgetIntersectionEdgeRatio(org.jogamp.vecmath.Point3f pt, org.jogamp.vecmath.Vector3f v, Plane3D p)static Vector2DgetIntersectionLine(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.Point2fgetIntersectionPoint(LineSegment2D l1, LineSegment2D l2)static org.jogamp.vecmath.Point2fgetIntersectionPoint(LineSegment2D l1, LineSegment2D l2, boolean test_crossing, boolean is_infinite)Returns the intersection point between two lines or line segments.static org.jogamp.vecmath.Point2dgetIntersectionPoint(org.jogamp.vecmath.Point3d p1, org.jogamp.vecmath.Point3d p2, Plane3D plane)Determine the point at which the line segment described byp1andp2intersectsplane.static org.jogamp.vecmath.Point2dgetIntersectionPoint(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.Point2fgetIntersectionPoint(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2, Plane3D plane)Determine the point at which the line segment described byp1andp2intersectsplane.static org.jogamp.vecmath.Point2fgetIntersectionPoint(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.Point3dgetIntersectionPoint3D(org.jogamp.vecmath.Point3d pt1, org.jogamp.vecmath.Point3d pt2, Plane3D plane)Returns point at which the line segmentpt1-pt2intersectsplane.static org.jogamp.vecmath.Point3fgetIntersectionPoint3D(org.jogamp.vecmath.Point3f pt1, org.jogamp.vecmath.Point3f pt2, Plane3D plane)Returns point at which the line segmentpt1-pt2intersectsplane.static org.jogamp.vecmath.Point3fgetIntersectionPoint3D(org.jogamp.vecmath.Point3f pt, org.jogamp.vecmath.Vector3f v, Plane3D plane)Returns point at which the line segment defined bypt1andvintersectsplane.static org.jogamp.vecmath.Point3fgetIntersectionPoint3D(org.jogamp.vecmath.Point3f pt, org.jogamp.vecmath.Vector3f v, Triangle3D tri)Determines the point at which the line segment defined byptandvintersects triangletri.static org.jogamp.vecmath.Point3f[]getIntersectionPoints(Triangle3D tri, Plane3D plane)Determines the points at whichtriintersectsplane.static org.jogamp.vecmath.Point3f[]getIntersectionPoints(Triangle3D tri, Plane3D plane, boolean include_kiss)Determines the points at whichtriintersectsplane.static org.jogamp.vecmath.Point3f[]getIntersectionSegment(Triangle3D tri1, Triangle3D tri2)Determines the line segment defining the seam of wheretri1andtri2intersect.static LineSegment2DgetIntersectionSegment(Vector2D vector, Rect2D rect)Calculates a line segment wherevectorcrossesrect.static Polygon2DgetIsInternalConcavePoly(Polygon2D poly, org.jogamp.vecmath.Point2f pt)static org.jogamp.vecmath.Matrix4dgetJamaMatrixAsMatrix4d(Jama.Matrix matrix)static org.jogamp.vecmath.Vector3fgetMatrixProduct(org.jogamp.vecmath.Vector3f v, org.jogamp.vecmath.Matrix4f M)MultipliesvbyM, using only the first 3 x 3 subset ofM.static org.jogamp.vecmath.Point3fgetMaxPt(Shape3D shape)Determines a maximum point max_x, max_y, max_z fromshape.static org.jogamp.vecmath.Point3fgetMaxPt(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.Point2fgetMidPoint(org.jogamp.vecmath.Point2f pt1, org.jogamp.vecmath.Point2f pt2, double pos)Determines the mid-point of the line segment defined bypt1andpt2, at the positionpos, which must range from 0.0 (i.e., atpt1to 1.0 (i.e., atpt2).static org.jogamp.vecmath.Point3fgetMidPt(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2)Computes the mid-point of the line segment defined byp1andp2.static doublegetMinimalAngle(double thisAngle)static org.jogamp.vecmath.Point3fgetMinPt(Shape3D shape)Determines a minimum point min_x, min_y, min_z fromshape.static org.jogamp.vecmath.Point3fgetMinPt(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2)Determines a minimum point min_x, min_y, min_z from two points.static intgetNearestNeighbour(org.jogamp.vecmath.Point2f p, java.util.ArrayList<org.jogamp.vecmath.Point2f> nodes)Determines the nearest neighbour ofpin the listnodes.static float[]getNodeAngles(Polygon2D polygon)Returns an array of angles made by each node ofpolygonstatic 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 innodeslie within the projection limits specified byplane,above_limit, andbelow_limit.static org.jogamp.vecmath.Vector2dgetNormal(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, wherep0andp1are the point before and afterp, respectively.static org.jogamp.vecmath.Vector2fgetNormal(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, wherep0andp1are 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).Plane3DgetOrthogonalPlane(Plane3D plane, LineSegment3D line)Returns a plane which is orthogonal toplane, with a y-axis defined byline.static Plane3DgetOrthogonalRegressionPlane(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 Plane3DgetPlane(Triangle3D tri)Returns a plane containingtri.static org.jogamp.vecmath.Vector4fgetPlaneEquation(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.Point3fCompgetPoint3fComp()static org.jogamp.vecmath.Point3fgetPointFromPlane(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.Point3fgetPointFromSection(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.Point3fgetPointFromSection(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 Polygon3DgetPolygonFromPlane(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.Point2dgetProjectedPoint(org.jogamp.vecmath.Point3d pt, Plane3D plane)Project pointptonto planeplane, alongplane's normal vector.static org.jogamp.vecmath.Point2fgetProjectedPoint(org.jogamp.vecmath.Point3f pt, Plane3D plane)Project pointptonto planeplane, alongplane's normal vector.static org.jogamp.vecmath.Point2fgetProjectedPoint(org.jogamp.vecmath.Point3f pt, org.jogamp.vecmath.Vector3f proj, Plane3D plane)Project pointptonto planeplane, alongplane's normal vector.static org.jogamp.vecmath.Point3fgetProjectedPoint3D(org.jogamp.vecmath.Point3f pt, Plane3D plane)Project pointptonto planeplane, alongplane's normal vector.static org.jogamp.vecmath.Point3fgetProjectedPoint3D(org.jogamp.vecmath.Point3f pt, org.jogamp.vecmath.Vector3f v, Plane3D plane)Project pointptonto planeplane, along vectorv.static java.util.ArrayList<org.jogamp.vecmath.Point2f>getProjectedToPlane(java.util.ArrayList<org.jogamp.vecmath.Point3f> nodes, Plane3D plane)Projectsnodesontoplaneand returns the 2D points.static Triangle2DgetProjectedToPlane(Triangle3D tri, Plane3D plane)Projectstriontoplaneand returns the 2D triangle.static org.jogamp.vecmath.Vector3fgetProjectedToPlane(org.jogamp.vecmath.Vector3f vector, org.jogamp.vecmath.Vector3f normal)Projectsvectoronto a plane with normalnormal.static org.jogamp.vecmath.Vector2fgetProjectedToPlane2D(org.jogamp.vecmath.Vector3f vector, Plane3D plane)Projectsvectoronto planeplanealong its normal.static org.jogamp.vecmath.Vector2fgetProjectedToPlane2D(org.jogamp.vecmath.Vector3f vector, org.jogamp.vecmath.Vector3f proj, Plane3D plane)Projectsvectoronto planeplanealong its normal.static org.jogamp.vecmath.Vector3fgetProjectedVector(org.jogamp.vecmath.Vector3f v, org.jogamp.vecmath.Vector3f u)Returns the projection of v onto u.static org.jogamp.vecmath.Quat4dgetQuaternion(org.jogamp.vecmath.Vector3d axis, double angle)static doublegetRadToDeg(double radAngle)Converts radians to degrees.static Polygon2DgetReversePolygon(Polygon2D thisPoly)Reverses the direction of this polygon (CW -> CCW or vice versa)static org.jogamp.vecmath.Vector2dgetRotatedVector2D(org.jogamp.vecmath.Vector2d vector, double angle)Rotatesvectorbyangle, specified in radians.static org.jogamp.vecmath.Vector2fgetRotatedVector2D(org.jogamp.vecmath.Vector2f vector, double angle)Rotatesvectorbyangle, specified in radians.static org.jogamp.vecmath.Matrix4dgetRotationTransform(org.jogamp.vecmath.Vector3d axis, double angle)Creates a transformation matrix representing a rotation aboutaxisbyangleradians.static Rect2DgetScaledShape(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 booleangetSegmentsIntersect(LineSegment2D l1, LineSegment2D l2)Determines whether line segmentsl1andl2intersect.static boolean[][]getSegmentsIntersect(Polygon2D poly1, Polygon2D poly2)static doublegetSignedAngle(org.jogamp.vecmath.Vector3d v1, org.jogamp.vecmath.Vector3d v2)Determines the signed angle thatv1makes withv2.static doublegetSignedDistance(org.jogamp.vecmath.Point3d pt, Plane3D plane)Determines distance from pointptto planeplane.static floatgetSignedDistance(org.jogamp.vecmath.Point3f pt, Plane3D plane)Determines distance from pointptto planeplane.static Box3DgetUnionBounds(Box3D b1, Box3D b2)static Rect2DgetUnionBounds(Rect2D r1, Rect2D r2)static Sphere3DgetUnionSphere(Sphere3D s1, Sphere3D s2)Returns a sphere that is the union of the two spheres s1 and s2static org.jogamp.vecmath.Vector2fgetVector(org.jogamp.vecmath.Point2f p1, org.jogamp.vecmath.Point2f p2)static floatgetVectorAngle(org.jogamp.vecmath.Vector2f vector)Returns the angle that a 2D vector makes with the x-axis.static org.jogamp.vecmath.Point2fgetVectorEndpoint(org.jogamp.vecmath.Point2f startPt, org.jogamp.vecmath.Vector2f vector)Returns the endpoint of a vector starting atstartPt.static org.jogamp.vecmath.Vector3dgetVectorFromAngles(double angleX, double angleY)static org.jogamp.java3d.Transform3DgetVectorRotation(Vector3D vector)Determines the rotation that converts [1, 0, 0] tovector.static voidgetVectorTransform(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 doublegetXAngle(org.jogamp.vecmath.Vector3d v)static floatgetXAngle(org.jogamp.vecmath.Vector3f vector)Returns angle ofvectorwith x-axis.static org.jogamp.vecmath.Vector4fgetXRotation(org.jogamp.vecmath.Vector4f plane, float r)static doublegetYAngle(org.jogamp.vecmath.Vector3d v)static floatgetYAngle(org.jogamp.vecmath.Vector3f vector)Returns angle ofvectorwith y-axis.static org.jogamp.vecmath.Vector4fgetYRotation(org.jogamp.vecmath.Vector4f plane)Rotate this plane about the Y axisstatic org.jogamp.vecmath.Vector4fgetYRotation(org.jogamp.vecmath.Vector4f plane, float r)static doublegetZAngle(org.jogamp.vecmath.Vector3d v)static floatgetZAngle(org.jogamp.vecmath.Vector3f vector)Returns angle ofvectorwith z-axis.static org.jogamp.vecmath.Vector4fgetZRotation(org.jogamp.vecmath.Vector4f plane)Rotate this plane about the Z axisstatic org.jogamp.vecmath.Vector4fgetZRotation(org.jogamp.vecmath.Vector4f plane, float r)static booleanintersects(Triangle3D tri, Plane3D plane)Determines whether triangle intersects planestatic booleanintersects(Triangle3D tri1, Triangle3D tri2)Determines whethertri1andtri2intersect.static booleanintersects(Vector3D vector, org.jogamp.vecmath.Point3f p)Determines whetherpintersectsvector, within the tolerance set for this session instance (GeometryFunctions.error).static booleanintersects(Vector3D vector, org.jogamp.vecmath.Point3f p, double tolerance)Determines whetherpintersectsvector, within the given tolerance.static booleanintersects(org.jogamp.vecmath.Point3f p, org.jogamp.vecmath.Vector3f v, Triangle3D tri)static booleanisAbovePlane(org.jogamp.vecmath.Point3f pt, Plane3D p)Deprecated.use compareToPlanestatic booleanisClockwise(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 booleanisClockwise(Polygon2D thisPoly)Determines whether a polygon is clockwise or not (i.e., counter-clockwise).static booleanisClockwise(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 booleanisClockwise(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 booleanisCoincident(org.jogamp.vecmath.Point2f p1, org.jogamp.vecmath.Point2f p2)Determines whetherp1and p2 coincide, within the default tolerance distanceGeometryFunctions.error.static booleanisCoincident(org.jogamp.vecmath.Point2f p1, org.jogamp.vecmath.Point2f p2, float tolerance)Determines whetherp1and p2 coincide, within the given tolerance distance.static booleanisCoincident(org.jogamp.vecmath.Point3d p1, org.jogamp.vecmath.Point3d p2)Determines whetherp1and p2 coincide, within the default tolerance distanceGeometryFunctions.error.static booleanisCoincident(org.jogamp.vecmath.Point3f p1, org.jogamp.vecmath.Point3f p2)Determines whetherp1and p2 coincide, within the default tolerance distanceGeometryFunctions.error.static booleanisConvex(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 booleanisInPlane(Shape3D s, Plane3D p)Determines whether shape s lies in plane pstatic booleanisInPlane(org.jogamp.vecmath.Point3d pt, Plane3D plane)Determines whether pointptlies inplanestatic booleanisInPlane(org.jogamp.vecmath.Point3d pt, org.jogamp.vecmath.Vector3d v, Plane3D plane)Determines whether the given line segment lies inplane.static booleanisInPlane(org.jogamp.vecmath.Point3f pt, Plane3D plane)Determines whether pointptlies in planeplanestatic booleanisInPlane(org.jogamp.vecmath.Point3f pt, org.jogamp.vecmath.Vector3f v, Plane3D plane)Determines whether the given line segment lies inplane.static booleanisIntermediateAngleCW(double a_i, double a_1, double a_2)static booleanisInternalConcave(Polygon2D poly, org.jogamp.vecmath.Point2f pt)Tests whether a point pt is contained within the boundary of a polygon poly.static booleanisInternalConvex(Polygon2D poly, org.jogamp.vecmath.Point2f pt)Tests whether a point pt is contained within the boundary of a convex polygon poly.static booleanisNonZeroVector(org.jogamp.vecmath.Vector3d v)static booleanisNonZeroVector(org.jogamp.vecmath.Vector3f v)static booleanisOblique(double thisAngle)static booleanisObtuse(Triangle3D tri)Determines whethertriis an obtuse triangle.static booleanisParallel(Plane3D plane1, Plane3D plane2)Determines whether the two planes are parallel.static booleanisValidPoint(org.jogamp.vecmath.Point2f p)static booleanisValidPoint(org.jogamp.vecmath.Point3f p)static booleanisValidSphere(Sphere3D s)static booleanisValidTriangle(Triangle3D t)static booleanisValidVector(org.jogamp.vecmath.Vector2f v)static booleanisValidVector(org.jogamp.vecmath.Vector3d v)static booleanisValidVector(org.jogamp.vecmath.Vector3f v)static booleanisZero(org.jogamp.vecmath.Tuple3f tuple)Determines whethertupleis of length zero.static voidrotate(Shape2D shape, org.jogamp.vecmath.Point2d base_point, double angle)Rotatesshapeaboutbase_pointbyangleradians.static voidrotate(Shape2D shape, org.jogamp.vecmath.Point2f base_point, double angle)Rotatesshapeaboutbase_pointbyangleradians.static voidrotate(Shape3D shape, org.jogamp.vecmath.Point3d base_point, org.jogamp.vecmath.Vector3d axis, double angle)Rotates this shape about a base pointbase_pointand an axisaxisbyangleradians.static voidrotate(Shape3D shape, org.jogamp.vecmath.Point3f base_point, org.jogamp.vecmath.Vector3f axis, double angle)Rotates this shape about a base pointbase_pointand an axisaxisbyangleradians.static booleantransform(Shape shape, Jama.Matrix matrix)Transformsshapewith the given affine transformation Jama matrixmatrix.static booleantransform(Shape shape, Jama.Matrix matrix, ProgressUpdater progress)Transformsshapewith the given affine transformation Jama matrixmatrix.static booleantransform(Shape shape, org.jogamp.vecmath.Matrix4d matrix)Transformsshapewith the given affine transformation matrixmatrix.static booleantransform(Shape shape, org.jogamp.vecmath.Matrix4d matrix, ProgressUpdater progress)Transformsshapewith the given affine transformation matrixmatrix.static booleantransform(Shape shape, org.jogamp.vecmath.Matrix4f matrix)Transformsshapewith the given affine transformation matrixmatrix.static booleantransform(Shape shape, org.jogamp.vecmath.Matrix4f matrix, ProgressUpdater progress)Transformsshapewith the given affine transformation matrixmatrix.static org.jogamp.vecmath.Vector3dtransform(org.jogamp.vecmath.Tuple3d vector, org.jogamp.vecmath.Matrix4d matrix)Transformsvectorwith the given affine transformation matrixmatrix.static org.jogamp.vecmath.Vector3ftransform(org.jogamp.vecmath.Tuple3f tuple, org.jogamp.vecmath.Matrix4d matrix)Transformsvectorwith the given affine transformation matrixmatrix.static org.jogamp.vecmath.Vector3ftransform(org.jogamp.vecmath.Tuple3f vector, org.jogamp.vecmath.Matrix4f matrix)Transformsvectorwith the given affine transformation matrixmatrix.static voidtranslate(Shape3D shape, double x, double y, double z)Translatesshapeby the specified x, y, and z distances.static voidtranslate(Shape3D shape, org.jogamp.vecmath.Vector3d v)Translatesshapeby 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)Transformsvectorwith 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)Transformsvectorwith 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)Transformsvectorwith the given affine transformation matrixmatrix.- Parameters:
vector-matrix-- Returns:
- the result
-
transform
Transformsshapewith the given affine transformation matrixmatrix.- Parameters:
shape-matrix-- Returns:
-
transform
Transformsshapewith the given affine transformation matrixmatrix.- Parameters:
shape-matrix-- Returns:
-
transform
public static boolean transform(Shape shape, org.jogamp.vecmath.Matrix4f matrix, ProgressUpdater progress)Transformsshapewith the given affine transformation matrixmatrix. Updatesprogress_barwith its progress.- Parameters:
shape-matrix-progress_bar-- Returns:
-
transform
public static boolean transform(Shape shape, org.jogamp.vecmath.Matrix4d matrix, ProgressUpdater progress)Transformsshapewith the given affine transformation matrixmatrix. Updatesprogress_barwith its progress.- Parameters:
shape-matrix-progress_bar-- Returns:
-
transform
Transformsshapewith the given affine transformation Jama matrixmatrix.- Parameters:
shape-matrix-- Returns:
-
transform
Transformsshapewith the given affine transformation Jama matrixmatrix. Updatesprogress_barwith 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 whethertupleis 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
vectormakes with the x-axis
-
getProjectedToPlane2D
public static org.jogamp.vecmath.Vector2f getProjectedToPlane2D(org.jogamp.vecmath.Vector3f vector, Plane3D plane)Projectsvectoronto planeplanealong 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)Projectsvectoronto planeplanealong 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)Projectsvectoronto 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)Projectsnodesontoplaneand returns the 2D points. -
getProjectedToPlane
Projectstriontoplaneand 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 byp1andp2.- Parameters:
p1-p2-- Returns:
- the mid-point
-
isObtuse
Determines whethertriis an obtuse triangle.- Parameters:
tri-- Returns:
trueiftriis obtuse,falseotherwise.
-
translate
Translatesshapeby the specified vector.- Parameters:
shape-x-y-z-
-
translate
Translatesshapeby 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_pointand an axisaxisbyangleradians.- 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_pointand an axisaxisbyangleradians.- Parameters:
shape- Shape to rotatebase_point- Point about which to rotateaxis- Rotation axisangle- Angle, in radians
-
rotate
Rotatesshapeaboutbase_pointbyangleradians.- Parameters:
shape-base_point-angle-
-
rotate
Rotatesshapeaboutbase_pointbyangleradians.- 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 thatv1makes 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:
trueif polygon is convex,falseif 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:
trueif polygon is clockwise,falseif it is counter-clockwise.
-
isClockwise
Determines whether a polygon is clockwise or not (i.e., counter-clockwise).- Parameters:
thisPoly-- Returns:
trueif polygon is clockwise,falseif 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:
trueif polygon is clockwise,falseif 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:
trueif polygon is clockwise,falseif 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 ofpin 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 bypt1andpt2, at the positionpos, which must range from 0.0 (i.e., atpt1to 1.0 (i.e., atpt2).- Parameters:
pt1-pt2-pos-- Returns:
nullifposis 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 ofvectorwith x-axis.- Parameters:
vector-- Returns:
-
getYAngle
public static float getYAngle(org.jogamp.vecmath.Vector3f vector)Returns angle ofvectorwith y-axis.- Parameters:
vector-- Returns:
-
getZAngle
public static float getZAngle(org.jogamp.vecmath.Vector3f vector)Returns angle ofvectorwith 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 aboutaxisbyangleradians.- 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 segmentsl1andl2intersect.- Parameters:
l1-l2-- Returns:
trueif 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)Rotatesvectorbyangle, 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)Rotatesvectorbyangle, 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 whetherp1and 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 whetherp1and 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 whetherp1and 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 whetherp1and 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
Point3frepresenting 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:
Point3frepresenting 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
nullifnodeshas 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 planepcrosses boxb.- Parameters:
s-p-- Returns:
trueif it crosses,falseotherwise
-
isAbovePlane
Deprecated.use compareToPlaneDetermines whether point pt is located above plane p.- Parameters:
pt-p-- Returns:
-
compareToPlane
Determines the position ofptwith respect toplane.- Parameters:
pt-plane-- Returns:
- -1 if
ptis below plane, 0 if it is on plane (within the error limits), and 1 if it is above plane
-
compareToPlane
Determines the position ofptwith respect toplane.- Parameters:
pt-plane-- Returns:
- -1 if
ptis 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)MultipliesvbyM, 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 pointptlies in planeplane- Parameters:
pt-plane-- Returns:
trueifptlies inplane,falseotherwise.
-
isInPlane
Determines whether pointptlies inplane- Parameters:
pt-plane-- Returns:
trueifptlies inplane,falseotherwise.
-
isInPlane
Determines whether shape s lies in plane p- Parameters:
pt-p-- Returns:
-
getSignedDistance
Determines distance from pointptto 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 pointptto planeplane.- Parameters:
pt-plane-- Returns:
- the calculated distance.
-
getDistance
Calculates the absolute distance frompttoplane- Parameters:
pt-plane-- Returns:
-
getDistance
Calculates the distance frompttoplane, 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 pointptonto 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 pointptonto 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 pointptonto 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 pointptonto 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 pointptonto 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 wherevectorcrossesrect. Treatsvectoras an infinite line. Returnsnullif vector does not crossrect.- Parameters:
vector-rect-- Returns:
-
crosses
Determines whethervectorcrossesrect. Vector is treated as a line segment.- Parameters:
vector-rect-- Returns:
-
crosses
Determines whethervectorcrossesrect. Theis_infiniteflag indicates whethervectorshould 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 ofshapewhich is closest topoint.- Parameters:
shape-point-- Returns:
-
getClosestVertex
Returns the vertex ofshapewhich 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 byp1andp2intersectsplane. Returns intersection point in plane coordinates, ornullif 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 byp1andp2intersectsplane. Returns intersection point in plane coordinates, ornullif 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 byptandvintersects triangletri. Returnsnullif there is no intersection.- Parameters:
pt-v-tri-- Returns:
- point of intersection, or
nullif 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 bypt1andvintersectsplane. Returnsnullif 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-pt2intersectsplane. Returnsnullif 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-pt2intersectsplane. Returnsnullif 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-pt2at which it intersectsplane. Returns -1 if this segment does not crossplane.- Parameters:
pt1-pt2-plane-- Returns:
- the ratio along the line segment
pt1-pt2at 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-pt2at which it intersectsplane. Returns -1 if this segment does not crossplane.- Parameters:
pt1-pt2-plane-- Returns:
- the ratio along the line segment
pt1-pt2at 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 theedgeparameter 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 whethertri1andtri2intersect.- Parameters:
tri1-tri2-- Returns:
-
getIntersectionSegment
public static org.jogamp.vecmath.Point3f[] getIntersectionSegment(Triangle3D tri1, Triangle3D tri2)Determines the line segment defining the seam of wheretri1andtri2intersect. 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 whichtriintersectsplane. Returnsnullif 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 whichtriintersectsplane. Returnsnullif it does not intersect;include_kissspecifies 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 whetherpintersectsvector, within the tolerance set for this session instance (GeometryFunctions.error).- Parameters:
vector-p-- Returns:
-
intersects
Determines whetherpintersectsvector, 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 segmentsl1andl2cross.- 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 innodeslie 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
Integers 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, wherep0andp1are the point before and afterp, respectively. One ofp0orp1(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 beforepp- point in curve at which to determine normalp1- point in curve afterpCW- 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, wherep0andp1are the point before and afterp, respectively. One ofp0orp1(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 beforepp- point in curve at which to determine normalp1- point in curve afterpCW- indicates direction of normal (clockwise iftrue, counterclockwise iffalse)- Returns:
- the normal at
p
-