MCPcopy Create free account
hub / github.com/cpmech/plotpy / draw_plane_nzz

Method draw_plane_nzz

src/surface_geometry.rs:137–163  ·  view source on GitHub ↗

Draws a plane that has a normal vector with a non-zero z (nzz) component The plane may be perpendicular to z if n = (0,0,1) # Input `p` -- (len=3) point on plane `n` -- (len=3) normal vector `xmin` and `xmax` -- limits along x `ymin` and `ymax` -- limits along y `nx` -- number of divisions along x (must be ≥ 2) `ny` -- number of divisions along y (must be ≥ 2) # Output `x`, `y`, `z` -- the co

(
        &mut self,
        p: &[f64],
        n: &[f64],
        xmin: f64,
        xmax: f64,
        ymin: f64,
        ymax: f64,
        nx: usize,
        ny: usize,
    )

Source from the content-addressed store, hash-verified

135 /// See also integration test in the **tests** directory.
136 ///
137 pub fn draw_plane_nzz(
138 &mut self,
139 p: &[f64],
140 n: &[f64],
141 xmin: f64,
142 xmax: f64,
143 ymin: f64,
144 ymax: f64,
145 nx: usize,
146 ny: usize,
147 ) -> Result<(Vec<Vec<f64>>, Vec<Vec<f64>>, Vec<Vec<f64>>), StrError> {
148 if p.len() != 3 || n.len() != 3 {
149 return Err("p.len() and n.len() must be equal to 3");
150 }
151 if f64::abs(n[2]) < 1e-10 {
152 return Err("the z-component of the normal vector cannot be zero");
153 }
154 if nx < 2 || ny < 2 {
155 return Err("nx and ny must be ≥ 2");
156 }
157 let d = -n[0] * p[0] - n[1] * p[1] - n[2] * p[2];
158 let (x, y, z) = generate3d(xmin, xmax, ymin, ymax, nx + 1, ny + 1, |x, y| {
159 (-d - n[0] * x - n[1] * y) / n[2]
160 });
161 self.draw(&x, &y, &z);
162 Ok((x, y, z))
163 }
164
165 /// Draws a hemisphere
166 ///

Callers 3

draw_plane_nzz_worksFunction · 0.80
test_surface_geometryFunction · 0.80

Calls 2

generate3dFunction · 0.85
drawMethod · 0.45

Tested by 3

draw_plane_nzz_worksFunction · 0.64
test_surface_geometryFunction · 0.64