-
| How can I use  Matplotlib gives: import numpy as np
import matplotlib.pyplot as plt
PI = np.pi
TAU = 2 * PI
u, v = np.mgrid[0:TAU:20j, 0:PI:10j]
x = np.cos(u) * np.sin(v)
y = np.sin(u) * np.sin(v)
z = np.cos(v)
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.set_aspect("equal")
ax.plot_wireframe(x, y, z, color="r") | 
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            KmolYuan
          
      
      
        Dec 13, 2022 
      
    
    Replies: 1 comment
-
| Alternative plan: Use spherical mesh. // sr = the radius of the sphere
// Draw the sphere
{
    let t = (0..=500).map(|t| t as f64 / 500. * TAU);
    let z = t.clone().map(|t| sr * t.cos());
    let y = t.map(|t| sr * t.sin());
    const N: usize = 96;
    for i in 0..N {
        let phi = i as f64 / N as f64 * TAU;
        let x = z.clone().map(|z| z * phi.sin());
        let z = z.clone().map(|z| z * phi.cos());
        let iter = x.zip(y.clone()).zip(z).map(|((x, y), z)| (x, y, z));
        chart.draw_series(LineSeries::new(iter, BLACK.mix(0.1)))?;
    }
} | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
      Answer selected by
        KmolYuan
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Alternative plan: Use spherical mesh.