fn simple_signed_volumes(
    pts: &[Point; 4],
    num_pts: usize,
    new_dir: &mut Vec3,
    lambdas_out: &mut Vec4,
) -> bool {
    const EPSILON: f32 = 0.0001 * 0.0001;
    match num_pts {
        2 => {
            let lambdas = signed_volume_1d(pts[0].xyz, pts[1].xyz);
            let mut v = Vec3::ZERO;
            for i in 0..2 {
                v += pts[i].xyz * lambdas[i];
            }
            *new_dir = -v;
            *lambdas_out = Vec4::new(lambdas.x, lambdas.y, 0.0, 0.0);
            v.length_squared() < EPSILON
        }
        3 => {
            let lambdas = signed_volume_2d(pts[0].xyz, pts[1].xyz, pts[2].xyz);
            let mut v = Vec3::ZERO;
            for i in 0..3 {
                v += pts[i].xyz * lambdas[i];
            }
            *new_dir = -v;
            *lambdas_out = Vec4::from((lambdas, 0.0));
            v.length_squared() < EPSILON
        }
        4 => {
            let lambdas = signed_volume_3d(pts[0].xyz, pts[1].xyz, pts[2].xyz, pts[3].xyz);
            let mut v = Vec3::ZERO;
            for i in 0..4 {
                v += pts[i].xyz * lambdas[i];
            }
            *new_dir = -v;
            *lambdas_out = lambdas;
            v.length_squared() < EPSILON
        }
        _ => unreachable!(),
    }
}
/// Projects the origin onto the simplex to acquire the new search direction, also checks if the
/// origin is "inside" the simplex.
Projects the origin onto the simplex to acquire the new search direction, also checks if the
origin is "inside" the simplex.
Projects the origin onto the simplex to acquire the new search direction also checks if the origin is " inside " the simplex .
fn simple_signed_volumes(
    pts: &[Point; 4],
    num_pts: usize,
    new_dir: &mut Vec3,
    lambdas_out: &mut Vec4,
) -> bool {
    const EPSILON: f32 = 0.0001 * 0.0001;
    match num_pts {
        2 => {
            let lambdas = signed_volume_1d(pts[0].xyz, pts[1].xyz);
            let mut v = Vec3::ZERO;
            for i in 0..2 {
                v += pts[i].xyz * lambdas[i];
            }
            *new_dir = -v;
            *lambdas_out = Vec4::new(lambdas.x, lambdas.y, 0.0, 0.0);
            v.length_squared() < EPSILON
        }
        3 => {
            let lambdas = signed_volume_2d(pts[0].xyz, pts[1].xyz, pts[2].xyz);
            let mut v = Vec3::ZERO;
            for i in 0..3 {
                v += pts[i].xyz * lambdas[i];
            }
            *new_dir = -v;
            *lambdas_out = Vec4::from((lambdas, 0.0));
            v.length_squared() < EPSILON
        }
        4 => {
            let lambdas = signed_volume_3d(pts[0].xyz, pts[1].xyz, pts[2].xyz, pts[3].xyz);
            let mut v = Vec3::ZERO;
            for i in 0..4 {
                v += pts[i].xyz * lambdas[i];
            }
            *new_dir = -v;
            *lambdas_out = lambdas;
            v.length_squared() < EPSILON
        }
        _ => unreachable!(),
    }
}
fn simple_signed_volumes ( pts : & [ Point ; 4 ] , num_pts : usize , new_dir : & mut Vec3 , lambdas_out : & mut Vec4 , ) -> bool { const EPSILON : f32 = 0.0001 * 0.0001 ; match num_pts { 2 => { let lambdas = signed_volume_1d ( pts [ 0 ] . xyz , pts [ 1 ] . xyz ) ; let mut v = Vec3 :: ZERO ; for i in 0 .. 2 { v += pts [ i ] . xyz * lambdas [ i ] ; } * new_dir = - v ; * lambdas_out = Vec4 :: new ( lambdas . x , lambdas . y , 0.0 , 0.0 ) ; v . length_squared ( ) < EPSILON } 3 => { let lambdas = signed_volume_2d ( pts [ 0 ] . xyz , pts [ 1 ] . xyz , pts [ 2 ] . xyz ) ; let mut v = Vec3 :: ZERO ; for i in 0 .. 3 { v += pts [ i ] . xyz * lambdas [ i ] ; } * new_dir = - v ; * lambdas_out = Vec4 :: from ( ( lambdas , 0.0 ) ) ; v . length_squared ( ) < EPSILON } 4 => { let lambdas = signed_volume_3d ( pts [ 0 ] . xyz , pts [ 1 ] . xyz , pts [ 2 ] . xyz , pts [ 3 ] . xyz ) ; let mut v = Vec3 :: ZERO ; for i in 0 .. 4 { v += pts [ i ] . xyz * lambdas [ i ] ; } * new_dir = - v ; * lambdas_out = lambdas ; v . length_squared ( ) < EPSILON } _ => unreachable ! ( ) , } }
Projects the origin onto the simplex to acquire the new search direction, also checks if the
origin is "inside" the simplex.
Projects the origin onto the simplex to acquire the new search direction also checks if the origin is " inside " the simplex .
pts
&[Point; 4]
num_pts
usize
new_dir
&mut Vec3
lambdas_out
&mut Vec4
pts
&[Point; 4]
num_pts
usize
new_dir
&mut Vec3
lambdas_out
&mut Vec4