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

Creates a sphere

Returns the center

Returns the radius

Returns whether the point pt is on sphere

Trait Implementations

The range of the parameter of the surface.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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.

Creates the surface division Read more

The surface is in the space of Self::Point.

The derivation vector of the curve.

Substitutes the parameter (u, v).

Returns the derivation by u.

Returns the derivation by v.

Returns the 2nd-order derivation by u.

Returns the 2nd-order derivation by both u and v.

Returns the 2nd-order derivation by v.

Returns the normal vector at (u, v).

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

point

curve => f64, surface => (f64, f64)

Search nearest parameter t such that self.subs(t) is nearest point.
Returns None if could not find such parameter. Read more

point

curve => f64, surface => (f64, f64)

Search parameter t such that self.subs(t) is near point.
Returns None if could not find such parameter. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.