/// Creates a cylinder with the x-direction as axis, length 1 and radius 1.
/// `x_subdivisions` defines the number of subdivisions in the x-direction
/// and `angle_subdivisions` defines the number of circular subdivisions.
Creates a cylinder with the x-direction as axis, length 1 and radius 1.
`x_subdivisions` defines the number of subdivisions in the x-direction
and `angle_subdivisions` defines the number of circular subdivisions.
Creates a cylinder with the x - direction as axis length 1 and radius 1 . ` x_subdivisions ` defines the number of subdivisions in the x - direction and ` angle_subdivisions ` defines the number of circular subdivisions .
pub fn cylinder(self, x_subdivisions: usize, angle_subdivisions: usize) -> Self
    {
        if x_subdivisions < 2 || angle_subdivisions < 3 { return self; }
        let mut positions = Vec::new();
        for i in 0..x_subdivisions + 1 {
            let x = i as f64 / x_subdivisions as f64;
            for j in 0..angle_subdivisions {
                let angle = 2.0 * std::f64::consts::PI * j as f64 / angle_subdivisions as f64;
                positions.push(x);
                positions.push(angle.cos());
                positions.push(angle.sin());
            }
        }
        let mut indices = Vec::new();
        for i in 0..x_subdivisions as u32 {
            for j in 0..angle_subdivisions as u32 {
                indices.push(i * angle_subdivisions as u32 + j);
                indices.push(i * angle_subdivisions as u32 + (j + 1) % angle_subdivisions as u32);
                indices.push((i + 1) * angle_subdivisions as u32 + (j + 1) % angle_subdivisions as u32);
                indices.push(i * angle_subdivisions as u32 + j);
                indices.push((i + 1) * angle_subdivisions as u32 + (j + 1) % angle_subdivisions as u32);
                indices.push((i + 1) * angle_subdivisions as u32 + j);
            }
        }
        self.with_positions(positions).with_indices(indices)
    }
pub fn cylinder ( self , x_subdivisions : usize , angle_subdivisions : usize ) -> Self { if x_subdivisions < 2 || angle_subdivisions < 3 { return self ; } let mut positions = Vec :: new ( ) ; for i in 0 .. x_subdivisions + 1 { let x = i as f64 / x_subdivisions as f64 ; for j in 0 .. angle_subdivisions { let angle = 2.0 * std :: f64 :: consts :: PI * j as f64 / angle_subdivisions as f64 ; positions . push ( x ) ; positions . push ( angle . cos ( ) ) ; positions . push ( angle . sin ( ) ) ; } } let mut indices = Vec :: new ( ) ; for i in 0 .. x_subdivisions as u32 { for j in 0 .. angle_subdivisions as u32 { indices . push ( i * angle_subdivisions as u32 + j ) ; indices . push ( i * angle_subdivisions as u32 + ( j + 1 ) % angle_subdivisions as u32 ) ; indices . push ( ( i + 1 ) * angle_subdivisions as u32 + ( j + 1 ) % angle_subdivisions as u32 ) ; indices . push ( i * angle_subdivisions as u32 + j ) ; indices . push ( ( i + 1 ) * angle_subdivisions as u32 + ( j + 1 ) % angle_subdivisions as u32 ) ; indices . push ( ( i + 1 ) * angle_subdivisions as u32 + j ) ; } } self . with_positions ( positions ) . with_indices ( indices ) }
Creates a cylinder with the x-direction as axis, length 1 and radius 1.
Creates a cylinder with the x - direction as axis length 1 and radius 1 .
self
x_subdivisions
usize
angle_subdivisions
usize