oxygen_quark 0.0.11

Oxygen Quark is a maths library mainly developed for the Oxygen Game Engine.
Documentation
pub mod matrix2x2;
pub mod matrix3x3;
pub mod matrix4x4;

/*
pub mod complex_matrix2x2;
*/

use crate::vector::{Vector, VectorError};

pub enum MatrixError {
    ZeroDeterminantError,
    NonSquareMatrixError,
}

impl std::fmt::Debug for MatrixError {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(f, "{:?}", self)
    }
}

pub trait Matrix {
    /// The type of data the matrix holds.
    type Data;

    fn new() -> Self;
    fn from(value: Self::Data) -> Self;
    fn from_slice(values: &[Self::Data]) -> Self;
    fn scale(&self, scale: Self::Data) -> Self;
    fn determinant(&self) -> Result<Self::Data, MatrixError>;
    fn transpose(&self) -> Self;
    fn cofactor(&self) -> Result<Self, MatrixError>
    where
        Self: Sized;
    fn adjugate(&self) -> Result<Self, MatrixError>
    where
        Self: Sized;
    fn inverse(&self) -> Result<Self, MatrixError>
    where
        Self: Sized;
}

pub trait TransformVector<T: Vector> {
    fn transform_vector(&self, _other: T) -> Result<T, VectorError> {
        Err(crate::vector::VectorError::NonExistingTransformError)
    }
}