Skip to main content

Module core

Module core 

Source
Expand description

Core types and structures for Clipper2

Direct port from clipper.core.h This module contains the fundamental data types and basic operations

Re-exports§

pub use get_bounds_path as get_bounds;

Modules§

constants
Constants matching C++ implementation Direct port from clipper.core.h line 55-71
errors
Error constants matching C++ implementation

Structs§

Clipper2Exception
Exception type for Clipper2 errors Direct port from clipper.core.h line 27
Point
2D point with generic numeric type Direct port from clipper.core.h line 117
Rect
Rectangle with generic numeric type Direct port from clipper.core.h line 295
UInt128Struct
128-bit unsigned integer struct for high-precision multiplication Direct port from clipper.core.h line 685

Enums§

FillRule
Fill rule determines how polygons with self-intersections are filled Direct port from clipper.core.h line 108
Location
Location of a point relative to a rectangle Direct port from clipper.rectclip.h line 20
PointInPolygonResult
Result of point-in-polygon test Direct port from clipper.core.h line 1046

Constants§

INVALID_POINT64
Invalid point constants
INVALID_POINTD

Traits§

FromF64
Trait for converting from f64 with appropriate rounding behavior Matches C++ Point constructor semantics: rounds for integral types, casts for float
ToF64
Helper trait for converting to f64 - matching C++ static_cast behavior

Functions§

area
Calculate area of a polygon path using the shoelace formula Direct port from clipper.core.h line 854
area_paths
Calculate total area of multiple polygon paths Direct port from clipper.core.h line 874
check_precision_range
Check if precision is within acceptable range and adjust if needed Direct port from clipper.core.h line 682
check_precision_range_simple
Check precision range without error code (convenience function) Direct port from clipper.core.h line 691
cross_product_sign
Get the sign of the cross product of vectors (pt1->pt2) and (pt2->pt3) Uses high-precision 128-bit arithmetic for exact results with i64 coordinates Direct port from clipper.core.h line 753
cross_product_three_points
Calculate cross product of two vectors formed by three points
Direct port from clipper.core.h line 810
cross_product_two_vectors
Calculate cross product of two vectors Direct port from clipper.core.h line 816
distance_sqr
Calculate squared distance between two points Direct port from clipper.core.h line 834
do_error
Handle errors by throwing appropriate exceptions Direct port from clipper.core.h line 73
dot_product_three_points
Calculate dot product of two vectors formed by three points Direct port from clipper.core.h line 822
dot_product_two_vectors
Calculate dot product of two vectors Direct port from clipper.core.h line 828
ellipse_point64
Generate an elliptical path around a center point Direct port from clipper.h line 613 (Ellipse template function)
ellipse_point_d
Generate an elliptical path around a center point (PointD version) Direct port from clipper.h line 613 (Ellipse template function)
get_bounds_path
Calculate the bounding rectangle of a path Direct port from clipper.core.h line 432
get_bounds_path_convert
Calculate the bounding rectangle of a path with type conversion Direct port from clipper.core.h line 467
get_bounds_paths
Calculate the bounding rectangle of multiple paths Direct port from clipper.core.h line 449
get_bounds_paths_convert
Calculate the bounding rectangle of multiple paths with type conversion Direct port from clipper.core.h line 484
get_closest_point_on_segment
Get the closest point on a segment to an off-segment point Direct port from clipper.core.h line 1024
get_location
Get the location of a point relative to a rectangle Returns false if the point is on the rectangle edge, true otherwise Direct port from clipper.rectclip.cpp line 37
get_segment_intersect_pt
Calculate exact intersection point between two line segments for Point64 Direct port from clipper.core.h line 902 - simplified version for i64 coordinates
get_segment_intersect_pt_d
Calculate intersection point between two line segments for PointD (floating-point) Direct port from clipper.core.h line 952 (floating-point specialization)
get_sign
Get the sign of a value: -1, 0, or 1 Direct port from clipper.core.h line 996
is_collinear
Test if three points are collinear (lie on the same straight line) Direct port from clipper.core.h line 796 - simplified version for Point64
is_horizontal
Check if a line segment between two points is horizontal Returns true if both points have the same y-coordinate Direct port from clipper.rectclip.cpp line 68
is_positive
Test if a polygon has positive orientation (counterclockwise) Direct port from clipper.core.h line 886
mid_point
Calculate midpoint between two points Direct port from clipper.core.h line 278
multiply_u64
Multiply two 64-bit unsigned integers to get 128-bit result Direct port from clipper.core.h line 690
near_equal
Check if two points are near each other within a distance threshold Direct port from clipper.core.h line 616
perpendic_dist_from_line_sqrd
Perpendicular distance squared from a point to a line defined by two points Direct port from clipper.core.h line 840 Uses the formula: (Ax3 + By3 + C)^2 / (A^2 + B^2) where A, B, C define the line equation
perpendicular_distance_from_line_sqr
Calculate squared perpendicular distance from point to line Direct port from clipper.core.h line 840
point_in_polygon
Determine if a point is inside, on the boundary, or outside a polygon Direct port from clipper.core.h line 1049 - simplified version for Point64 Uses the winding number algorithm with proper edge case handling
products_are_equal
Check if products ab and cd are equal using exact 128-bit arithmetic Direct port from clipper.core.h line 703
reflect_point
Reflect a point about a pivot point Direct port from clipper.core.h line 986
scale_path
Scale a path with type conversion and separate x/y scales Direct port from clipper.core.h line 523
scale_path_uniform
Scale a path with uniform scale Direct port from clipper.core.h line 550
scale_paths
Scale multiple paths with type conversion and separate x/y scales Includes range checking for integral output types Direct port from clipper.core.h line 557
scale_paths_uniform
Scale multiple paths with uniform scale Direct port from clipper.core.h line 584
scale_rect
Scale a rectangle with type conversion Direct port from clipper.core.h line 405
segments_intersect
Check if two line segments intersect Direct port from clipper.core.h line 1003
sqr
Square a value (matches C++ template inline double Sqr(T val)) Direct port from clipper.core.h line 611
strip_duplicates_path
Strip duplicate consecutive points from a path Direct port from clipper.core.h line 658
strip_duplicates_paths
Strip duplicate consecutive points from multiple paths Direct port from clipper.core.h line 670
strip_near_equal
Strip near-equal consecutive points from a path Direct port from clipper.core.h line 623
strip_near_equal_paths
Strip near-equal consecutive points from multiple paths Direct port from clipper.core.h line 647
transform_path
Transform a path between types (no scaling, just type conversion) Direct port from clipper.core.h line 591
transform_paths
Transform multiple paths between types (no scaling, just type conversion) Direct port from clipper.core.h line 601
translate_point
Translate a point by dx, dy Direct port from clipper.core.h line 975
tri_sign
Helper for returning -1, 0, or 1 based on sign Direct port from clipper.core.h line 697

Type Aliases§

Path
Vector of points forming a path
Path64
PathD
Paths
Vector of paths
Paths64
PathsD
Point64
PointD
Rect64
RectD