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

Function gen_curve_3d

tests/test_plot.rs:69–98  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

67}
68
69fn gen_curve_3d() -> Curve {
70 // curve
71 let mut curve = Curve::new();
72 // https://matplotlib.org/stable/gallery/mplot3d/lines3d.html
73 // theta = np.linspace(-4 * np.pi, 4 * np.pi, 100)
74 // z = np.linspace(-2, 2, 100)
75 // r = z**2 + 1
76 // x = r * np.sin(theta)
77 // y = r * np.cos(theta)
78 let np = 101;
79 let t0 = -4.0 * PI;
80 let t1 = 4.0 * PI;
81 let dt = (t1 - t0) / ((np - 1) as f64);
82 let z0 = -2.0;
83 let z1 = 2.0;
84 let dz = (z1 - z0) / ((np - 1) as f64);
85 let mut xx = vec![0.0; np];
86 let mut yy = vec![0.0; np];
87 let mut zz = vec![0.0; np];
88 for i in 0..np {
89 let theta = t0 + (i as f64) * dt;
90 let z = z0 + (i as f64) * dz;
91 let r = z * z + 1.0;
92 xx[i] = r * f64::sin(theta);
93 yy[i] = r * f64::cos(theta);
94 zz[i] = z;
95 }
96 curve.draw_3d(&xx, &yy, &zz);
97 curve
98}
99
100#[test]
101fn test_plot_3d() -> Result<(), StrError> {

Callers 2

test_plot_3dFunction · 0.85

Calls 1

draw_3dMethod · 0.45

Tested by

no test coverage detected