/// Calculates cross product ONLY for 3 dimensional vectors
/// If the vectors are not same dimension or if the dimensions are not == 3, None is returned
Calculates cross product ONLY for 3 dimensional vectors
If the vectors are not same dimension or if the dimensions are not == 3, None is returned
Calculates cross product ONLY for 3 dimensional vectors If the vectors are not same dimension or if the dimensions are not == 3 None is returned
pub fn cross_product(vec1: &Vector, vec2: &Vector) -> Option<Vector> {
        if Vector::equal_dimensions(&vec1, &vec2) && vec1.dimension == 3 {
            let mut vector = Vector::zero(vec1.dimension as u32);
            vector.components[0] =
                vec1.components[1] * vec2.components[2] - vec1.components[2] * vec2.components[1];
            vector.components[1] =
                vec1.components[2] * vec2.components[0] - vec1.components[0] * vec2.components[2];
            vector.components[2] =
                vec1.components[0] * vec2.components[1] - vec1.components[1] * vec2.components[0];
            return Some(vector);
        }
        return None;
    }
pub fn cross_product ( vec1 : & Vector , vec2 : & Vector ) -> Option < Vector > { if Vector :: equal_dimensions ( & vec1 , & vec2 ) && vec1 . dimension == 3 { let mut vector = Vector :: zero ( vec1 . dimension as u32 ) ; vector . components [ 0 ] = vec1 . components [ 1 ] * vec2 . components [ 2 ] - vec1 . components [ 2 ] * vec2 . components [ 1 ] ; vector . components [ 1 ] = vec1 . components [ 2 ] * vec2 . components [ 0 ] - vec1 . components [ 0 ] * vec2 . components [ 2 ] ; vector . components [ 2 ] = vec1 . components [ 0 ] * vec2 . components [ 1 ] - vec1 . components [ 1 ] * vec2 . components [ 0 ] ; return Some ( vector ) ; } return None ; }
Calculates cross product ONLY for 3 dimensional vectors
If the vectors are not same dimension or if the dimensions are not == 3, None is returned
Calculates cross product ONLY for 3 dimensional vectors If the vectors are not same dimension or if the dimensions are not == 3 None is returned
vec1
&Vector
vec2
&Vector