About
The geometryutils.h header file contains the maxon::GeometryUtilsInterface which includes various functions to handle vectors, lines, half-lines (rays), line segments and primitives like triangles and quads.
Angles
Angles between vectors can be calculated with:
Areas
Multiple points can define a triangle, a quad or an arbitrary shape.
static MAXON_METHOD Float CalculateOutlineArea(const Block< const Vector > &outlinePoints)
static MAXON_METHOD Float CalculateQuadrangleArea(const Vector &a, const Vector &b, const Vector &c, const Vector &d)
static MAXON_METHOD Float CalculateTriangleArea(const Vector &a, const Vector &b, const Vector &c)
Float64 Float
Definition: apibase.h:197
Barycentric Coordinates
Barycentric coordinates define the position of a point within a given triangle. The coordinates for a given point are calculated with:
The coordinates within a polygon are calculated with:
static MAXON_METHOD Vector CalculateBarycentricCoordinate3D(const Vector &point, const Vector &a, const Vector &b, const Vector &c)
Py_UCS4 * res
Definition: unicodeobject.h:1113
Interpolation
Bilinear interpolation allows to interpolate values in a two dimensional grid:
PyObject PyObject const char const char char ** s
Definition: bytesobject.h:60
static MAXON_METHOD Vector BilinearInterpolate(const Vector &pa, const Vector &pb, const Vector &pc, const Vector &pd, const Float s, const Float t)
Intersection
These functions allow to calculate the intersection of lines, half-lines, segments, triangles and quads.
Intersection of lines, half-lines, and sections with each other:
See also:
if (segementIntersection)
if (lineIntersection)
static MAXON_METHOD Bool IntersectSegments(const Vector &segment1Point1, const Vector &segment1Point2, const Vector &segment2Point1, const Vector &segment2Point2, Vector &intersectionPoint, Float tolerance=GeomConstants::EPSILON4)
static MAXON_METHOD Bool IntersectLines(const Vector &line1Point, const Vector &line1Dir, const Vector &line2Point, const Vector &line2Dir, Vector &intersectionPoint, Float tolerance=GeomConstants::EPSILON4)
static const ENUM_DONT_INITIALIZE DONT_INITIALIZE
Definition: apibase.h:620
bool Bool
boolean type, possible values are only false/true, 8 bit
Definition: apibase.h:181
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:176
Intersection of lines, half-lines, and segments with planes:
if (linePlaneIntersect)
if (halfLinePlaneIntersect)
DiagnosticOutput(
"Half-line intersects plane at @", halfLinePlaneIntersectPoint);
if (segmentPlaneIntersect)
static MAXON_METHOD Bool IntersectSegmentPlane(const Vector &segmentPoint1, const Vector &segmentPoint2, const Vector &planePoint, const Vector &planeNormal, Vector &intersectionPoint, Float tolerance=GeomConstants::EPSILON4)
static MAXON_METHOD Bool IntersectLinePlane(const Vector &linePoint, const Vector &lineDir, const Vector &planePoint, const Vector &planeNormal, Vector &intersectionPoint, Float tolerance=GeomConstants::EPSILON4)
static MAXON_METHOD Bool IntersectHalfLinePlane(const Vector &halfLinePoint, const Vector &halfLineDir, const Vector &planePoint, const Vector &planeNormal, Vector &intersectionPoint, Float tolerance=GeomConstants::EPSILON4)
Intersections of lines, half-lines and segments with triangles and quadrangles:
if (lineTriIntersect)
if (halfLineTriIntersect)
DiagnosticOutput(
"Half-line intersects triangle at @", halfLineTriIntersectPoint);
if (segmentTriIntersect)
static MAXON_METHOD Bool IntersectHalfLineTriangle(const Vector &halfLineOrigin, const Vector &halfLineDir, const Vector &a, const Vector &b, const Vector &c, Vector &intersectionPoint, Vector2d *barycCoords=nullptr, Float tolerance=GeomConstants::EPSILON4)
static MAXON_METHOD Bool IntersectLineTriangle(const Vector &linePoint, const Vector &lineDir, const Vector &a, const Vector &b, const Vector &c, Vector &intersectionPoint, Vector2d *barycCoords=nullptr, Float tolerance=GeomConstants::EPSILON4)
static MAXON_METHOD Bool IntersectSegmentTriangle(const Vector &segmentPoint1, const Vector &segmentPoint2, const Vector &a, const Vector &b, const Vector &c, Vector &intersectionPoint, Vector *barycCoords=nullptr, Float tolerance=GeomConstants::EPSILON4)
Intersection of triangles, quadrangles and planes:
Points Inside
These functions are used to check if a given point is inside a given shape:
static MAXON_METHOD Bool PointInTriangle2D(const Vector2d &point, const Vector2d &a, const Vector2d &b, const Vector2d &c)
static MAXON_METHOD Int GetPointInPolygonWindingNumber2D(Vector2d point, const Block< const Vector2d > &outline)
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:188
Points on Lines
These functions check if a given point is on a line, half-line or within a segment:
PyObject * value
Definition: abstract.h:715
static MAXON_METHOD Bool PointInHalfLine(const Vector &point, const Vector &halfLineOrigin, const Vector &halfLineDir, Float tolerance=GeomConstants::EPSILON4)
static MAXON_METHOD Bool PointInSegment(const Vector &point, const Vector &segmentPoint1, const Vector &segmentPoint2, Float tolerance=GeomConstants::EPSILON4)
static MAXON_METHOD Float InterpolatePointOnSegment(const Vector &segmentPoint1, const Vector &segmentPoint2, const Vector &point, Bool clamp=true)
Vec3< Float, 1 > Vector
Definition: vector.h:56
Unstrided GetNormalized() const
Returns a normalized vector, so that GetLength(vector)==1.0.
Definition: vec.h:472
PyObject Py_ssize_t Py_ssize_t int direction
Definition: unicodeobject.h:916
Circumcenter
The circumcenter is the center of a circle containing all points of the given shape.
if (foundCenter)
static MAXON_METHOD Bool CalculateCircumcenter(const Vector &a, const Vector &b, const Vector &c, Vector ¢er, Float &rad, Float tolerance=GeomConstants::EPSILON4)
Vertex Properties
The convexity of a given vertex can be checked with:
See also ConvexHull Manual.
Projection
Functions to project points:
Miscellaneous
Miscellaneous functions are:
{
}
{
}
static MAXON_METHOD Float LinearRemapToRange(Float value, Float from1, Float to1, Float from2, Float to2)
static MAXON_METHOD Bool CalculateCircumcenter2D(const Vector2d &a, const Vector2d &b, const Vector2d &c, Vector2d ¢er, Float &sqrRad, Float tolerance=GeomConstants::EPSILON4)
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:210
#define MAXON_LIKELY(X)
Definition: compilerdetection.h:403
Further Reading