3D Matrix

// 3D matrix.
class RVAPI M4f
{
public:
    // X vector.
    S4f x;

    // Y vector.
    S4f y;

    // Z vector.
    S4f z;

    // Homogeneous vector.
    S4f w;

    // Get this matrix transformed by [matrix].
    M4f operator * (const M4f &matrix) const;

    // Transform this matrix by [matrix].
    M4f &operator *= (const M4f &matrix) { return *this = *this * matrix; }

    // Get this matrix inverted.
    M4f Invert() const;

    // Normailze this matrix.
    M4f &Normalize();

    // Construct uninitialized matrix.
    M4f() {}

    // Destructor.
    ~M4f() {}
};

// Get [scalar] transformed by [matrix].
RVAPI S4f operator * (const S4f &scalar, const M4f &matrix);

// Transform [scalar] by [matrix].
inline const S4f &operator *= (S4f &scalar, const M4f &matrix) { return scalar = scalar * matrix; }

// Identity matrix.
class RVAPI M4fIdent : public M4f
{
public:
    // Constructor.
    M4fIdent();
};

// Translate matrix.
class RVAPI M4fTrans : public M4f
{
public:
    // Construct matrix from [scalar].
    M4fTrans(const S3f &scalar);

    // Construct matrix from coordinates.
    M4fTrans(float x, float y, float z);

    // Construct matrix from single value.
    M4fTrans(float n = 0);
};

// Scale matrix.
class RVAPI M4fScale : public M4f
{
public:
    // Construct matrix from [scalar].
    M4fScale(const S3f &scalar);

    // Construct matrix from axis scale values.
    M4fScale(float x, float y, float z);

    // Construct matrix from single value.
    M4fScale(float n = 1);
};

// X rotation matrix.
class RVAPI M4fRotX : public M4f
{
public:
    // Construct matrix from [angle].
    M4fRotX(float angle);
};

// Y rotation matrix.
class RVAPI M4fRotY : public M4f
{
public:
    // Construct matrix from [angle].
    M4fRotY(float angle);
};

// Z rotation matrix.
class RVAPI M4fRotZ : public M4f
{
public:
    // Construct matrix from [angle].
    M4fRotZ(float angle);
};

// Rotation matrix.
class RVAPI M4fRot : public M4f
{
public:
    // Construct matrix from [axis] and [angle].
    M4fRot(const S3f &axis, float angle);
};

// Alignment matrix.
class RVAPI M4fAlign : public M4f
{
public:
    // Construct matrix to align from [scalarA] to [scalarB].
    M4fAlign(const S3f &scalarA, const S3f &scalarB);
};

// Look at matrix.
class RVAPI M4fLookAt : public M4f
{
public:
    // Construct matrix to look from [eye] to [at] while maintaining [up].
    M4fLookAt(const S3f &eye, const S3f &at, const S3f &up);
};

// Untranslated matrix.
class RVAPI M4fTransOut : public M4f
{
public:
    // Construct matrix from [matrix] with translation removed and stored in [trans].
    M4fTransOut(const M4f &matrix, S3f &trans);
};

// Restored translation matrix.
class RVAPI M4fTransIn : public M4f
{
public:
    // Construct matrix from [matrix] with translation restored from [trans].
    M4fTransIn(const M4f &matrix, const S3f &trans);
};