Struct truck_geometry::specifieds::Sphere [−][src]
pub struct Sphere { /* fields omitted */ }
Expand description
sphere
Examples
use truck_geometry::*;
use std::f64::consts::PI;
let center = Point3::new(1.0, 2.0, 3.0);
let radius = 4.56;
let sphere = Sphere::new(center, radius);
const N: usize = 100;
for i in 0..=N {
for j in 0..=N {
// the parameter u is latitude
let u = PI * i as f64 / N as f64;
// the parameter v is longitude
let v = 2.0 * PI * j as f64 / N as f64;
// simple relation between a point and its normal.
let pt = sphere.subs(u, v);
let n = sphere.normal(u, v);
assert_near!(pt - center, n * radius);
// the proof of u is latitude and v is longitude
assert!((PI / 2.0 - u) * (pt.z - center.z) >= 0.0);
assert!((PI - v) * (pt.y - center.y) >= 0.0);
}
}
Implementations
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Returns whether the curve curve
is included in the surface self
.
Returns whether the curve curve
is included in the surface self
.
Auto Trait Implementations
impl RefUnwindSafe for Sphere
impl UnwindSafe for Sphere
Blanket Implementations
Mutably borrows from an owned value. Read more