### Run Naive Incircle Predicate Example Source: https://github.com/georust/robust/blob/main/examples/predicate-map/README.md Execute the naive incircle predicate example. This command generates an image file named 'naive-incircle.png'. ```bash cargo run --example predicate-map naive incircle naive-incircle.png ``` -------------------------------- ### Run Naive Orient2d Predicate Example Source: https://github.com/georust/robust/blob/main/examples/predicate-map/README.md Execute the naive orient2d predicate example. This command generates an image file named 'naive-orient2d.png'. ```bash cargo run --example predicate-map naive orient2d naive-orient2d.png ``` -------------------------------- ### Run Robust Orient2d Predicate Example Source: https://github.com/georust/robust/blob/main/examples/predicate-map/README.md Execute the robust orient2d predicate example. This command generates an image file named 'robust-orient2d.png'. ```bash cargo run --example predicate-map robust orient2d robust-orient2d.png ``` -------------------------------- ### Run Robust Incircle Predicate Example Source: https://github.com/georust/robust/blob/main/examples/predicate-map/README.md Execute the robust incircle predicate example. This command generates an image file named 'robust-incircle.png'. ```bash cargo run --example predicate-map robust incircle robust-incircle.png ``` -------------------------------- ### Create and Use 3D Coordinates (f64/f32) Source: https://context7.com/georust/robust/llms.txt Shows how to create `Coord3D` structs for 3D points, supporting both f64 and f32 types. Similar to `Coord`, `f32` inputs are converted to `f64` internally for calculations. ```rust use robust::Coord3D; // Create 3D coordinates for sphere/plane calculations let point_a = Coord3D { x: 0.0, y: 0.0, z: 0.0 }; let point_b = Coord3D { x: 1.0, y: 0.0, z: 0.0 }; let point_c = Coord3D { x: 0.0, y: 1.0, z: 0.0 }; let point_d = Coord3D { x: 0.0, y: 0.0, z: 1.0 }; // 3D coordinates also support f32 input let point_f32: Coord3D = Coord3D { x: 1.0f32, y: 2.0f32, z: 3.0f32 }; ``` -------------------------------- ### Create and Use 2D Coordinates (f64/f32) Source: https://context7.com/georust/robust/llms.txt Demonstrates creating and using `Coord` structs for 2D points with both f64 and f32 types. `f32` inputs are automatically converted to `f64` internally. Coordinates support copying and equality checks. ```rust use robust::Coord; // Create 2D coordinates with f64 let point_a = Coord { x: 0.0, y: 0.0 }; let point_b = Coord { x: 1.0, y: 0.0 }; let point_c = Coord { x: 0.5, y: 0.5 }; // Create 2D coordinates with f32 (automatically converted to f64 internally) let point_f32: Coord = Coord { x: 1.0f32, y: 2.0f32 }; // Coordinates can be copied and compared let copied = point_a; assert_eq!(point_a, copied); ``` -------------------------------- ### Use Robust Predicates in no_std Environment Source: https://context7.com/georust/robust/llms.txt Demonstrates using `orient2d` from the `robust` crate within a `no_std` Rust environment. All geometric predicates are available when the `no_std` feature is enabled. ```rust #![no_std] use robust::{orient2d, Coord}; // All predicates work in no_std environments fn check_orientation(pa: Coord, pb: Coord, pc: Coord) -> bool { orient2d(pa, pb, pc) > 0.0 } ``` -------------------------------- ### Enable no_std Support in Cargo.toml Source: https://context7.com/georust/robust/llms.txt To use the `robust` library in a `no_std` environment, add the `no_std` feature flag to your `Cargo.toml` file. This allows the library to function without the Rust standard library, suitable for embedded systems. ```toml # Cargo.toml [dependencies] robust = { version = "1.2", features = ["no_std"] } ``` -------------------------------- ### Perform 3D Orientation Test Source: https://context7.com/georust/robust/llms.txt The `orient3d` function determines if a fourth point `pd` lies below, above, or on the plane defined by three other points (`pa`, `pb`, `pc`). It returns positive for below, negative for above, and zero for coplanar points. This is useful for signed tetrahedron volume calculations. ```rust use robust::{orient3d, Coord3D}; // Define a plane using three points (the XY plane at z=0) let pa = Coord3D { x: 0.0, y: 0.0, z: 0.0 }; let pb = Coord3D { x: 1.0, y: 0.0, z: 0.0 }; let pc = Coord3D { x: 0.0, y: 1.0, z: 0.0 }; // Point below the plane (negative z) - returns positive let pd_below = Coord3D { x: 0.5, y: 0.5, z: -1.0 }; let result = orient3d(pa, pb, pc, pd_below); assert!(result > 0.0, "Point is below the plane"); // Point above the plane (positive z) - returns negative let pd_above = Coord3D { x: 0.5, y: 0.5, z: 1.0 }; let result = orient3d(pa, pb, pc, pd_above); assert!(result < 0.0, "Point is above the plane"); // Point on the plane - returns zero let pd_on_plane = Coord3D { x: 0.5, y: 0.5, z: 0.0 }; let result = orient3d(pa, pb, pc, pd_on_plane); assert!(result == 0.0, "Point is coplanar"); // Useful for tetrahedron volume calculations (signed volume = orient3d / 6) let tetrahedron_signed_volume = orient3d(pa, pb, pc, pd_below) / 6.0; ``` -------------------------------- ### orient2d Source: https://context7.com/georust/robust/llms.txt Determines the orientation of three 2D points (pa, pb, pc). ```APIDOC ## orient2d ### Description Returns a positive value if the coordinates pa, pb, and pc occur in counterclockwise order (pc lies to the left of the directed line from pa to pb). Returns a negative value if they occur in clockwise order (pc lies to the right). Returns 0 if the three points are collinear. ### Parameters - **pa** (Coord) - Required - First point - **pb** (Coord) - Required - Second point - **pc** (Coord) - Required - Third point ### Response - **f64** - The signed orientation result. ``` -------------------------------- ### Perform 2D Orientation Test Source: https://context7.com/georust/robust/llms.txt Uses the `orient2d` function to determine the orientation of three 2D points. It returns a positive value for counterclockwise, negative for clockwise, and zero for collinear points. This function is robust against floating-point inaccuracies. ```rust use robust::{orient2d, Coord}; // Define three points let pa = Coord { x: 0.0, y: 0.0 }; let pb = Coord { x: 1.0, y: 0.0 }; // Point to the left of line pa->pb (counterclockwise) - returns positive let pc_left = Coord { x: 0.5, y: 1.0 }; let result = orient2d(pa, pb, pc_left); assert!(result > 0.0, "Point is to the left (counterclockwise)"); // Point to the right of line pa->pb (clockwise) - returns negative let pc_right = Coord { x: 0.5, y: -1.0 }; let result = orient2d(pa, pb, pc_right); assert!(result < 0.0, "Point is to the right (clockwise)"); // Point on the line (collinear) - returns zero let pc_on_line = Coord { x: 0.5, y: 0.0 }; let result = orient2d(pa, pb, pc_on_line); assert!(result == 0.0, "Point is collinear"); // Works with near-degenerate cases where naive arithmetic fails let p1 = Coord { x: 12.0, y: 12.0 }; let p2 = Coord { x: 24.0, y: 24.0 }; let p3 = Coord { x: 0.5, y: 0.5 }; let robust_result = orient2d(p1, p3, p2); // Returns correct sign even for nearly-collinear points ``` -------------------------------- ### Check if Point is Inside Circumsphere Source: https://context7.com/georust/robust/llms.txt Use `insphere` to determine if a point lies inside, outside, or on the circumsphere defined by four other points. The first four points (pa, pb, pc, pd) must have a positive orientation (checked with `orient3d`). Crucial for 3D Delaunay tetrahedralization. ```rust use robust::{insphere, orient3d, Coord3D}; // Define a tetrahedron with positive orientation let pa = Coord3D { x: 0.0, y: 0.0, z: 0.0 }; let pb = Coord3D { x: 1.0, y: 0.0, z: 0.0 }; let pc = Coord3D { x: 0.5, y: 1.0, z: 0.0 }; let pd = Coord3D { x: 0.5, y: 0.5, z: 1.0 }; // Verify positive orientation assert!(orient3d(pa, pb, pc, pd) > 0.0, "Points must have positive orientation"); // Point inside the circumsphere - returns positive let pe_inside = Coord3D { x: 0.5, y: 0.5, z: 0.3 }; let result = insphere(pa, pb, pc, pd, pe_inside); assert!(result > 0.0, "Point is inside the circumsphere"); // Point outside the circumsphere - returns negative let pe_outside = Coord3D { x: 0.5, y: 0.5, z: 10.0 }; let result = insphere(pa, pb, pc, pd, pe_outside); assert!(result < 0.0, "Point is outside the circumsphere"); // Essential for 3D Delaunay tetrahedralization fn is_delaunay_tetrahedron( pa: Coord3D, pb: Coord3D, pc: Coord3D, pd: Coord3D, pe: Coord3D ) -> bool { // For a Delaunay tetrahedralization, no point should be inside the circumsphere insphere(pa, pb, pc, pd, pe) <= 0.0 } ``` -------------------------------- ### orient3d Source: https://context7.com/georust/robust/llms.txt Determines the orientation of four 3D points (pa, pb, pc, pd) relative to a plane. ```APIDOC ## orient3d ### Description Returns a positive value if the point pd lies below the plane passing through pa, pb, and pc. Returns a negative value if pd lies above the plane. Returns 0 if the four points are coplanar. ### Parameters - **pa** (Coord3D) - Required - First point of the plane - **pb** (Coord3D) - Required - Second point of the plane - **pc** (Coord3D) - Required - Third point of the plane - **pd** (Coord3D) - Required - Point to test ### Response - **f64** - The signed orientation result. ``` -------------------------------- ### Check if Point is Inside Circumcircle Source: https://context7.com/georust/robust/llms.txt Use `incircle` to determine if a point lies inside, outside, or on the circumcircle of three other points. The order of the first three points (pa, pb, pc) must be counterclockwise for a positive result when the fourth point (pd) is inside. Essential for Delaunay triangulation. ```rust use robust::{incircle, orient2d, Coord}; // Define a triangle in counterclockwise order let pa = Coord { x: 0.0, y: 0.0 }; let pb = Coord { x: 1.0, y: 0.0 }; let pc = Coord { x: 0.5, y: 1.0 }; // Verify counterclockwise orientation assert!(orient2d(pa, pb, pc) > 0.0, "Points must be counterclockwise"); // Point inside the circumcircle - returns positive let pd_inside = Coord { x: 0.5, y: 0.3 }; let result = incircle(pa, pb, pc, pd_inside); assert!(result > 0.0, "Point is inside the circumcircle"); // Point outside the circumcircle - returns negative let pd_outside = Coord { x: 0.5, y: 5.0 }; let result = incircle(pa, pb, pc, pd_outside); assert!(result < 0.0, "Point is outside the circumcircle"); // Point on the circumcircle - returns zero // For an equilateral triangle centered at origin with circumradius r let r = 1.0; let pa = Coord { x: r, y: 0.0 }; let pb = Coord { x: -r / 2.0, y: r * 0.866025403784 }; let pc = Coord { x: -r / 2.0, y: -r * 0.866025403784 }; let pd_on_circle = Coord { x: 0.0, y: r }; // Another point on same circle // result will be very close to 0 for cocircular points // Essential for Delaunay triangulation algorithms fn is_delaunay_edge(pa: Coord, pb: Coord, pc: Coord, pd: Coord) -> bool { // For a Delaunay triangulation, no point should be inside the circumcircle incircle(pa, pb, pc, pd) <= 0.0 } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.