()
| 67 | } |
| 68 | |
| 69 | fn 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] |
| 101 | fn test_plot_3d() -> Result<(), StrError> { |
no test coverage detected