fn vertex_coords<'a, I: Iterator<Item = &'a Point>>(
    poly: &Concrete,
    vertices: I,
    projection_type: ProjectionType,
) -> Vec<[f32; 3]> {
    let dim = poly.dim_or();

    // Returns the ith coordinate of p, or 0 if it doesn't exist.
    let coord = |p: &Point, i: usize| p.get(i).copied().unwrap_or_default();

    // If the polytope is at most 3D, we just embed it into 3D space.
    if projection_type.is_orthogonal() || dim <= 3 {
        vertices.map(|p| [0, 1, 2].map(|i| coord(p, i))).collect()
    }
    // Else, we project it down.
    else {
        // Distance from the projection planes.
        let mut direction = Vector::zeros(dim);
        direction[3] = 1.0;

        let (min, max) = poly.minmax(direction).unwrap();
        let dist = (min as f32 - 1.0).abs().max(max as f32 + 1.0).abs();

        vertices
            .map(|p| {
                // We scale the first three coordinates accordingly.
                let factor: f32 = p.iter().skip(3).map(|&x| x as f32 + dist).product();
                [0, 1, 2].map(|i| coord(p, i) / factor)
            })
            .collect()
    }
}
/// Gets the coordinates of the vertices, after projecting down into 3D.
Gets the coordinates of the vertices, after projecting down into 3D.
Gets the coordinates of the vertices after projecting down into 3D .
fn vertex_coords<'a, I: Iterator<Item = &'a Point>>(
    poly: &Concrete,
    vertices: I,
    projection_type: ProjectionType,
) -> Vec<[f32; 3]> {
    let dim = poly.dim_or();
    // Returns the ith coordinate of p, or 0 if it doesn't exist.
    let coord = |p: &Point, i: usize| p.get(i).copied().unwrap_or_default();
    // If the polytope is at most 3D, we just embed it into 3D space.
    if projection_type.is_orthogonal() || dim <= 3 {
        vertices.map(|p| [0, 1, 2].map(|i| coord(p, i))).collect()
    }
    // Else, we project it down.
    else {
        // Distance from the projection planes.
        let mut direction = Vector::zeros(dim);
        direction[3] = 1.0;
        let (min, max) = poly.minmax(direction).unwrap();
        let dist = (min as f32 - 1.0).abs().max(max as f32 + 1.0).abs();
        vertices
            .map(|p| {
                // We scale the first three coordinates accordingly.
                let factor: f32 = p.iter().skip(3).map(|&x| x as f32 + dist).product();
                [0, 1, 2].map(|i| coord(p, i) / factor)
            })
            .collect()
    }
}
fn vertex_coords < ' a , I : Iterator < Item = & ' a Point > > ( poly : & Concrete , vertices : I , projection_type : ProjectionType , ) -> Vec < [ f32 ; 3 ] > { let dim = poly . dim_or ( ) ; // Returns the ith coordinate of p, or 0 if it doesn't exist. let coord = | p : & Point , i : usize | p . get ( i ) . copied ( ) . unwrap_or_default ( ) ; // If the polytope is at most 3D, we just embed it into 3D space. if projection_type . is_orthogonal ( ) || dim <= 3 { vertices . map ( | p | [ 0 , 1 , 2 ] . map ( | i | coord ( p , i ) ) ) . collect ( ) } // Else, we project it down. else { // Distance from the projection planes. let mut direction = Vector :: zeros ( dim ) ; direction [ 3 ] = 1.0 ; let ( min , max ) = poly . minmax ( direction ) . unwrap ( ) ; let dist = ( min as f32 - 1.0 ) . abs ( ) . max ( max as f32 + 1.0 ) . abs ( ) ; vertices . map ( | p | { // We scale the first three coordinates accordingly. let factor : f32 = p . iter ( ) . skip ( 3 ) . map ( | & x | x as f32 + dist ) . product ( ) ; [ 0 , 1 , 2 ] . map ( | i | coord ( p , i ) / factor ) } ) . collect ( ) } }
Gets the coordinates of the vertices, after projecting down into 3D.
Gets the coordinates of the vertices after projecting down into 3D .
poly
&Concrete
vertices
I
projection_type
ProjectionType
poly
&Concrete
vertices
I
projection_type
ProjectionType