Draws a sphere # Input `c` -- (len=3) center coordinates `r` -- radius `n_alpha` -- number of divisions along α (must be ≥ 2) `n_theta` -- number of divisions along θ (must be ≥ 2) # Output `x`, `y`, `z` -- the coordinates of all points as in a meshgrid # Example ``` use plotpy::{Plot, StrError, Surface}; use std::path::Path; fn main() -> Result<(), StrError> { // configure and draw surface
(
&mut self,
c: &[f64],
r: f64,
n_alpha: usize,
n_theta: usize,
)
| 391 | /// See also integration test in the **tests** directory. |
| 392 | /// |
| 393 | pub fn draw_sphere( |
| 394 | &mut self, |
| 395 | c: &[f64], |
| 396 | r: f64, |
| 397 | n_alpha: usize, |
| 398 | n_theta: usize, |
| 399 | ) -> Result<(Vec<Vec<f64>>, Vec<Vec<f64>>, Vec<Vec<f64>>), StrError> { |
| 400 | if c.len() != 3 { |
| 401 | return Err("c.len() must be equal to 3"); |
| 402 | } |
| 403 | if n_alpha < 2 || n_theta < 2 { |
| 404 | return Err("n_alpha and n_theta must be ≥ 2"); |
| 405 | } |
| 406 | let (alpha_min, alpha_max) = (-180.0, 180.0); |
| 407 | let (theta_min, theta_max) = (-90.0, 90.0); |
| 408 | self.draw_superquadric( |
| 409 | c, |
| 410 | &[r, r, r], |
| 411 | &[2.0, 2.0, 2.0], |
| 412 | alpha_min, |
| 413 | alpha_max, |
| 414 | theta_min, |
| 415 | theta_max, |
| 416 | n_alpha, |
| 417 | n_theta, |
| 418 | ) |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |