Skip to content

Commit

Permalink
added example
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell committed Oct 22, 2024
1 parent cb75053 commit ff88478
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@

A Rust Cargo crate for finding the distance between a point and a constructive solid geometry (CSG) surface

## Example usage

This example finds the distance from a point along a vector to a spherical surface.

```rust
use csg_distance::{Point, Vector, CSGSurface};

fn main() {
let point = Point { x: 1.0, y: 2.0, z: 3.0 };
let vector = Vector { dx: 1.0, dy: 0.0, dz: 0.0 };

let surface = CSGSurface::Sphere { x: 0.0, y: 0.0, z: 0.0, radius: 1.0 };

if let Some(distance) = surface.distance_to_surface(&point, &vector) {
println!("Distance to surface: {}", distance);
} else {
println!("No intersection with the surface.");
}
}
```

## Supported Surfaces

csg_surface_distance supports the following types of surfaces:
Expand Down

0 comments on commit ff88478

Please sign in to comment.