Skip to content

Commit

Permalink
added example folder
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell committed Oct 24, 2024
1 parent 7867547 commit 3b6d957
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A Rust Cargo crate for finding the distance between a point and a constructive s
This example finds the distance from a point along a vector to a spherical surface.

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

fn main() {
let point = Point { x: 1.0, y: 2.0, z: 3.0 };
Expand Down
7 changes: 7 additions & 0 deletions example_use/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "example_use"
version = "0.1.0"
edition = "2021"

[dependencies]
csg_surface_distance = { path = "../" }
14 changes: 14 additions & 0 deletions example_use/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use csg_surface_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.");
}
}

0 comments on commit 3b6d957

Please sign in to comment.