8    enum EZeroCtor      { ZeroCtor };
 
    9    enum EIdentityCtor  { IdentityCtor };
 
   10    enum ERowsCtor      { RowsCtor };
 
   11    enum EColsCtor      { ColsCtor };
 
   14    cMat3(
const EZeroCtor);
 
   15    cMat3(
const EIdentityCtor);
 
   18    cMat3(
const float _00, 
const float _01, 
const float _02,
 
   19        const float _10, 
const float _11, 
const float _12,
 
   20        const float _20, 
const float _21, 
const float _22);
 
   21    cMat3(
const cMat3& v) { memcpy(
this, &v, 
sizeof(v)); }
 
   23    void Copy(
const float *Float9);
 
   24    void CopyTransposed(
const float *Float9);
 
   29    const cVec3 & GetRow(
const int Index) 
const;
 
   30    const cVec3 & GetRow0() 
const;
 
   31    const cVec3 & GetRow1() 
const;
 
   32    const cVec3 & GetRow2() 
const;
 
   34    cVec3 & Row(
const int Index);
 
   39    void SetRow(
const int Index, 
const cVec3 &);
 
   40    void SetRow0(
const cVec3 &);
 
   41    void SetRow1(
const cVec3 &);
 
   42    void SetRow2(
const cVec3 &);
 
   44    void SetRow(
const int Index, 
const float X, 
const float Y, 
const float Z);
 
   45    void SetRow0(
const float X, 
const float Y, 
const float Z);
 
   46    void SetRow1(
const float X, 
const float Y, 
const float Z);
 
   47    void SetRow2(
const float X, 
const float Y, 
const float Z);
 
   49    const cVec3 GetCol(
const int Index) 
const;
 
   50    const cVec3 GetCol0() 
const;
 
   51    const cVec3 GetCol1() 
const;
 
   52    const cVec3 GetCol2() 
const;
 
   54    void SetCol(
const int Index, 
const cVec3 &);
 
   55    void SetCol0(
const cVec3 &);
 
   56    void SetCol1(
const cVec3 &);
 
   57    void SetCol2(
const cVec3 &);
 
   59    void SetCol(
const int Index, 
const float X, 
const float Y, 
const float Z);
 
   60    void SetCol0(
const float X, 
const float Y, 
const float Z);
 
   61    void SetCol1(
const float X, 
const float Y, 
const float Z);
 
   62    void SetCol2(
const float X, 
const float Y, 
const float Z);
 
   64    void SetElem(
int Row, 
int Col, 
float Value);
 
   65    float GetElem(
const int Row, 
const int Col) 
const;
 
   66    float & Elem(
const int Row, 
const int Col);
 
   68    const cVec3 & operator [] (
const int Row) 
const;
 
   69    cVec3 & operator [] (
const int Row);
 
   71    float operator () (
const int Row, 
const int Col) 
const;
 
   72    float & operator () (
const int Row, 
const int Col);
 
   75    float Determinant() 
const;
 
   77    bool operator == (
const cMat3 &) 
const;
 
   78    static bool Equals(
const cMat3 &, 
const cMat3 &, 
const float Eps = cMath::MatrixEpsilon);
 
   80    bool IsZero(
const float Eps = cMath::MatrixEpsilon) 
const;
 
   81    bool IsIdentity(
const float Eps = cMath::MatrixEpsilon) 
const;
 
   82    bool IsSymmetric(
const float Eps = cMath::MatrixEpsilon) 
const;
 
   83    bool IsOrthonormal(
const float Eps = cMath::MatrixEpsilon) 
const;
 
   85    const cMat3 operator - () 
const;
 
   90    cMat3& operator *= (
const float);
 
   91    cMat3& operator /= (
const float);
 
   96    const cMat3 operator * (
const float) 
const;
 
   97    friend const cMat3 operator * (
const float, 
const cMat3 &);
 
   98    const cMat3 operator / (
const float) 
const;
 
  100    void Add(
const cMat3 &R);
 
  101    void Sub(
const cMat3 &R);
 
  102    void Mul(
const cMat3 &R);
 
  103    void Mul(
const float s);
 
  108    static const cMat3 Mul(
const cMat3 &L, 
const float s);
 
  111    static const cMat3 Zero;
 
  112    static const cMat3 Identity;
 
  117    static bool Invert(
const cMat3 &Fm, 
cMat3 *To);
 
  118    bool Invert() { 
return Invert(*
this, 
this); }
 
  120    static const cMat3 OrthoNormalize(
const cMat3 &Src);
 
  121    void OrthoNormalize();
 
  123    static const cMat3 Rotation(
const cVec3 &Axis, 
const float Angle);
 
  124    static const cMat3 RotationX(
const float Angle);
 
  125    static const cMat3 RotationY(
const float Angle);
 
  126    static const cMat3 RotationZ(
const float Angle);
 
  127    static const cMat3 RotationXYZ(
const float Pitch, 
const float Yaw, 
const float Roll);
 
  128    static const cMat3 EulerZYX(
const float eulerX, 
const float eulerY, 
const float eulerZ); 
 
  130    static const cMat3 Scaling(
const float XYZ);
 
  131    static const cMat3 Scaling(
const float X, 
const float Y);
 
  132    static const cMat3 Scaling(
const float X, 
const float Y, 
const float Z);
 
  136    const float * ToFloatPtr() 
const;
 
  137    float * ToFloatPtr();
 
  138    const cMat4 ToMat4() 
const;
 
  139    const cQuat ToQuat() 
const;
 
  141    void ToVectors(
cVec3 *Forward, 
cVec3 *Right = 
nullptr, 
cVec3 *Up = 
nullptr) 
const;
 
  143    static const cMat3 FromForward(
const cVec3& Forward);
 
  144    const cVec3 ToForward() 
const;
 
  145    const cVec3 ToRight() 
const;
 
  146    const cVec3 ToUp() 
const;
 
  148    const cAngles ToAngles() 
const;
 
  150    std::tuple<float, float, float, float, float, float, float, float, float> __getstate__();
 
  151    void __setstate__(
const std::tuple<float, float, float, float, float, float, float, float, float>& state);
 
  152    const std::string __repr__() 
const;
 
 
  159inline cMat3::cMat3() {
 
  163inline cMat3::cMat3(
const EZeroCtor) {
 
  170inline cMat3::cMat3(
const EIdentityCtor) {
 
  171    m_Rows[0].Set(1.0f, 0.0f, 0.0f);
 
  172    m_Rows[1].Set(0.0f, 1.0f, 0.0f);
 
  173    m_Rows[2].Set(0.0f, 0.0f, 1.0f);
 
  177inline cMat3::cMat3(
const ERowsCtor, 
const cVec3 &Row0, 
const cVec3 &Row1, 
const cVec3 &Row2) {
 
  184inline cMat3::cMat3(
const EColsCtor, 
const cVec3 &Col0, 
const cVec3 &Col1, 
const cVec3 &Col2) {
 
  185    m_Rows[0].Set(Col0.x, Col1.x, Col2.x);
 
  186    m_Rows[1].Set(Col0.y, Col1.y, Col2.y);
 
  187    m_Rows[2].Set(Col0.z, Col1.z, Col2.z);
 
  191inline cMat3::cMat3(
const float _00, 
const float _01, 
const float _02,
 
  192                    const float _10, 
const float _11, 
const float _12,
 
  193                    const float _20, 
const float _21, 
const float _22) {
 
  194    m_Rows[0].Set(_00, _01, _02);
 
  195    m_Rows[1].Set(_10, _11, _12);
 
  196    m_Rows[2].Set(_20, _21, _22);
 
  200inline void cMat3::Copy(
const float *Float9) {
 
  201    m_Rows[0].Set(Float9[0], Float9[1], Float9[2]);
 
  202    m_Rows[1].Set(Float9[3], Float9[4], Float9[5]);
 
  203    m_Rows[2].Set(Float9[6], Float9[7], Float9[8]);
 
  207inline void cMat3::CopyTransposed(
const float *Float9) {
 
  208    m_Rows[0].Set(Float9[0], Float9[3], Float9[6]);
 
  209    m_Rows[1].Set(Float9[1], Float9[4], Float9[7]);
 
  210    m_Rows[2].Set(Float9[2], Float9[5], Float9[8]);
 
  214inline void cMat3::SetZero() {
 
  221inline void cMat3::SetIdentity() {
 
  222    m_Rows[0].Set(1.0f, 0.0f, 0.0f);
 
  223    m_Rows[1].Set(0.0f, 1.0f, 0.0f);
 
  224    m_Rows[2].Set(0.0f, 0.0f, 1.0f);
 
  228inline const cVec3 & cMat3::GetRow(
const int Index)
 const {
 
  229    cAssert(Index >= 0 && Index < 3);
 
  230    return m_Rows[Index];
 
  234inline const cVec3 & cMat3::GetRow0()
 const {
 
  239inline const cVec3 & cMat3::GetRow1()
 const {
 
  244inline const cVec3 & cMat3::GetRow2()
 const {
 
  249inline cVec3 & cMat3::Row(
const int Index) {
 
  250    cAssert(Index >= 0 && Index < 3);
 
  251    return m_Rows[Index];
 
  255inline cVec3 & cMat3::Row0() {
 
  260inline cVec3 & cMat3::Row1() {
 
  265inline cVec3 & cMat3::Row2() {
 
  270inline void cMat3::SetRow(
const int Index, 
const cVec3 &r) {
 
  271    cAssert(Index >= 0 && Index < 3);
 
  276inline void cMat3::SetRow0(
const cVec3 &r) {
 
  281inline void cMat3::SetRow1(
const cVec3 &r) {
 
  286inline void cMat3::SetRow2(
const cVec3 &r) {
 
  291inline void cMat3::SetRow(
const int Index, 
const float X, 
const float Y, 
const float Z) {
 
  292    cAssert(Index >= 0 && Index < 3);
 
  293    m_Rows[Index].Set(X, Y, Z);
 
  297inline void cMat3::SetRow0(
const float X, 
const float Y, 
const float Z) {
 
  298    m_Rows[0].Set(X, Y, Z);
 
  302inline void cMat3::SetRow1(
const float X, 
const float Y, 
const float Z) {
 
  303    m_Rows[1].Set(X, Y, Z);
 
  307inline void cMat3::SetRow2(
const float X, 
const float Y, 
const float Z) {
 
  308    m_Rows[2].Set(X, Y, Z);
 
  312inline const cVec3 cMat3::GetCol(
const int Index)
 const {
 
  313    cAssert(Index >= 0 && Index < 3);
 
  314    return cVec3(m_Rows[0][Index], m_Rows[1][Index], m_Rows[2][Index]);
 
  318inline const cVec3 cMat3::GetCol0()
 const {
 
  319    return cVec3(m_Rows[0].x, m_Rows[1].x, m_Rows[2].x);
 
  323inline const cVec3 cMat3::GetCol1()
 const {
 
  324    return cVec3(m_Rows[0].y, m_Rows[1].y, m_Rows[2].y);
 
  328inline const cVec3 cMat3::GetCol2()
 const {
 
  329    return cVec3(m_Rows[0].z, m_Rows[1].z, m_Rows[2].z);
 
  333inline void cMat3::SetCol(
const int Index, 
const cVec3 &u) {
 
  334    cAssert(Index >= 0 && Index < 3);
 
  335    m_Rows[0][Index] = u.x;
 
  336    m_Rows[1][Index] = u.y;
 
  337    m_Rows[2][Index] = u.z;
 
  341inline void cMat3::SetCol0(
const cVec3 &u) {
 
  348inline void cMat3::SetCol1(
const cVec3 &u) {
 
  355inline void cMat3::SetCol2(
const cVec3 &u) {
 
  362inline void cMat3::SetCol(
const int Index, 
const float X, 
const float Y, 
const float Z) {
 
  363    cAssert(Index >= 0 && Index < 3);
 
  364    m_Rows[0][Index] = X;
 
  365    m_Rows[1][Index] = Y;
 
  366    m_Rows[2][Index] = Z;
 
  370inline void cMat3::SetCol0(
const float X, 
const float Y, 
const float Z) {
 
  377inline void cMat3::SetCol1(
const float X, 
const float Y, 
const float Z) {
 
  384inline void cMat3::SetCol2(
const float X, 
const float Y, 
const float Z) {
 
  391inline void cMat3::SetElem(
int Row, 
int Col, 
float Value) {
 
  392    cAssert(Row >= 0 && Row < 3);
 
  393    cAssert(Col >= 0 && Col < 3);
 
  394    m_Rows[Row][Col] = Value;
 
  398inline float cMat3::GetElem(
const int Row, 
const int Col)
 const {
 
  399    cAssert(Row >= 0 && Row < 3);
 
  400    cAssert(Col >= 0 && Col < 3);
 
  401    return m_Rows[Row][Col];
 
  405inline float & cMat3::Elem(
const int Row, 
const int Col) {
 
  406    cAssert(Row >= 0 && Row < 3);
 
  407    cAssert(Col >= 0 && Col < 3);
 
  408    return m_Rows[Row][Col];
 
  412inline const cVec3 & cMat3::operator [] (
const int Row)
 const {
 
  413    cAssert(Row >= 0 && Row < 3);
 
  418inline cVec3 & cMat3::operator [] (
const int Row) {
 
  419    cAssert(Row >= 0 && Row < 3);
 
  424inline float cMat3::operator () (
const int Row, 
const int Col)
 const {
 
  425    cAssert(Row >= 0 && Row < 3);
 
  426    cAssert(Col >= 0 && Col < 3);
 
  427    return m_Rows[Row][Col];
 
  431inline float & cMat3::operator () (
const int Row, 
const int Col) {
 
  432    cAssert(Row >= 0 && Row < 3);
 
  433    cAssert(Col >= 0 && Col < 3);
 
  434    return m_Rows[Row][Col];
 
  438inline float cMat3::Trace()
 const {
 
  439    return m_Rows[0][0] + m_Rows[1][1] + m_Rows[2][2];
 
  443inline bool cMat3::operator == (
const cMat3 &u)
 const {
 
  444    return cMat3::Equals( *
this, u );
 
  448inline bool cMat3::Equals(
const cMat3 &P, 
const cMat3 &Q, 
const float Eps) {
 
  449    if(cVec3::Equals(P[0], Q[0]) && cVec3::Equals(P[1], Q[1]) && cVec3::Equals(P[2], Q[2])) {
 
  456inline const cMat3 cMat3::operator - ()
 const {
 
  457    return Mul(*
this, -1.0f);
 
  463inline void cMat3::Add(
const cMat3 &R) {
 
  464    float *l = 
reinterpret_cast<float *
>(
this);
 
  465    const float *r = 
reinterpret_cast<const float *
>(&R);
 
  467    for(
int i = 0; i < 9; i++) {
 
  473inline cMat3& cMat3::operator += (
const cMat3 &R) {
 
  482    const float *l = 
reinterpret_cast<const float *
>(&L);
 
  483    const float *r = 
reinterpret_cast<const float *
>(&R);
 
  485    float *s = 
reinterpret_cast<float *
>(&S);
 
  487    for(
int i = 0; i < 9; i++) {
 
  494inline const cMat3 cMat3::operator + (
const cMat3 &R)
 const {
 
  495    return Mul(*
this, R);
 
  501inline void cMat3::Sub(
const cMat3 &R) {
 
  502    float *l = 
reinterpret_cast<float *
>(
this);
 
  503    const float *r = 
reinterpret_cast<const float *
>(&R);
 
  505    for(
int i = 0; i < 9; i++) {
 
  511inline cMat3& cMat3::operator -= (
const cMat3 &R) {
 
  520    const float *l = 
reinterpret_cast<const float *
>(&L);
 
  521    const float *r = 
reinterpret_cast<const float *
>(&R);
 
  523    float *d = 
reinterpret_cast<float *
>(&D);
 
  525    for(
int i = 0; i < 9; i++) {
 
  531inline const cMat3 cMat3::operator - (
const cMat3 &R)
 const {
 
  532    return Sub(*
this, R);
 
  538inline void cMat3::Mul(
const cMat3 &R) {
 
  539    float *l = 
reinterpret_cast<float *
>(
this);
 
  540    const float *r = 
reinterpret_cast<const float *
>(&R);
 
  543    for(
int i = 0; i < 3; i++) {
 
  544        for(
int j = 0; j < 3; j++) {
 
  545            t[j] = l[0] * r[0 * 3 + j] + l[1] * r[1 * 3 + j] + l[2] * r[2 * 3 + j];
 
  555inline void cMat3::Mul(
const float s) {
 
  556    float *l = (
float *)
this;
 
  557    for(
int i = 0; i < 9; i++) {
 
  563inline cMat3& cMat3::operator *= (
const cMat3 &R) {
 
  569inline cMat3& cMat3::operator *= (
const float s) {
 
  575inline cMat3& cMat3::operator /= (
const float s) {
 
  586    const float *l = 
reinterpret_cast<const float *
>(&L);
 
  587    const float *r = 
reinterpret_cast<const float *
>(&R);
 
  588    float *m = 
reinterpret_cast<float *
>(&M);
 
  590    for(
int i = 0; i < 3; i++) {
 
  591        for(
int j = 0; j < 3; j++) {
 
  592            *m = l[0] * r[0 * 3 + j] + l[1] * r[1 * 3 + j] + l[2] * r[2 * 3 + j];
 
  601inline const cMat3 cMat3::Mul(
const cMat3 &L, 
const float s) {
 
  603    const float *l = (
const float *)&L;
 
  604    float *m = (
float *)&M;
 
  606    for(
int i = 0; i < 9; i++) {
 
  615    res_vec.x = L.m_Rows[0].x *vc.x + L.m_Rows[0].y *vc.y + L.m_Rows[0].z *vc.z;
 
  616    res_vec.y = L.m_Rows[1].x *vc.x + L.m_Rows[1].y *vc.y + L.m_Rows[1].z *vc.z;
 
  617    res_vec.z = L.m_Rows[2].x *vc.x + L.m_Rows[2].y *vc.y + L.m_Rows[2].z *vc.z;
 
  623inline const cMat3 cMat3::operator * (
const cMat3 &R)
 const {
 
  624    return Mul(*
this, R);
 
  628inline const cMat3 cMat3::operator * (
const float s)
 const {
 
  629    return Mul(*
this, s);
 
  633inline const cMat3 cMat3::operator / (
const float s)
 const {
 
  635    return Mul(*
this, is);
 
  639inline const cMat3 operator * (
const float s, 
const cMat3 &R) {
 
  640    return cMat3::Mul(R, s);
 
  644inline bool cMat3::IsZero(
const float Eps)
 const {
 
  645    return Equals(*
this, Zero, Eps);
 
  649inline bool cMat3::IsIdentity(
const float Eps)
 const {
 
  650    return Equals(*
this, Identity, Eps);
 
  654inline bool cMat3::IsSymmetric(
const float Eps)
 const {
 
  655    if(!cMath::Equals(m_Rows[2][0], m_Rows[0][2], Eps)) {
 
  658    if(!cMath::Equals(m_Rows[2][1], m_Rows[1][2], Eps)) {
 
  661    if(!cMath::Equals(m_Rows[1][0], m_Rows[0][1], Eps)) {
 
  668inline bool cMat3::IsOrthonormal(
const float Eps)
 const {
 
  669    return cMath::IsOne(Determinant(), Eps);
 
  673inline const float * cMat3::ToFloatPtr()
 const {
 
  674    return m_Rows[0].ToFloatPtr();
 
  678inline float * cMat3::ToFloatPtr() {
 
  679    return m_Rows[0].ToFloatPtr();
 
  683inline const cMat3 cMat3::Transpose(
const cMat3 &M) {
 
  685    for(
int i = 0; i < 3; i++) {
 
  686        T.SetRow(i, M.GetCol(i));
 
  692inline void cMat3::Transpose() {
 
  693    cMath::Swap(m_Rows[0][1], m_Rows[1][0]);
 
  694    cMath::Swap(m_Rows[0][2], m_Rows[2][0]);
 
  695    cMath::Swap(m_Rows[1][2], m_Rows[2][1]);
 
  699inline const cMat3 cMat3::OrthoNormalize(
const cMat3 &Src) {
 
  701    O.m_Rows[0].Normalize();
 
  702    O.m_Rows[2] = cVec3::Cross(O.m_Rows[0], O.m_Rows[1]).ToNormal();
 
  703    O.m_Rows[1] = cVec3::Cross(O.m_Rows[2], O.m_Rows[0]).ToNormal();
 
  708inline void cMat3::OrthoNormalize() {
 
  709    m_Rows[0].Normalize();
 
  710    m_Rows[2] = cVec3::Cross(m_Rows[0], m_Rows[1]).ToNormal();
 
  711    m_Rows[1] = cVec3::Cross(m_Rows[2], m_Rows[0]).ToNormal();
 
  721    r.x = u.x * R(0, 0) + u.y * R(1, 0);
 
  722    r.y = u.x * R(0, 1) + u.y * R(1, 1);
 
  727inline void cVec2::Transform(
const cMat3 &R) {
 
  728    *
this = Transform(*
this, R);
 
  732inline void cVec2::operator *= (
const cMat3 &R) {
 
  733    *
this = Transform(*
this, R);
 
  737inline const cVec2 cVec2::operator * (
const cMat3 &R)
 const {
 
  738    return Transform(*
this, R);
 
  748    r.x = u.x * R(0, 0) + u.y * R(1, 0) + u.z * R(2, 0);
 
  749    r.y = u.x * R(0, 1) + u.y * R(1, 1) + u.z * R(2, 1);
 
  750    r.z = u.x * R(0, 2) + u.y * R(1, 2) + u.z * R(2, 2);
 
  755inline void cVec3::Transform(
const cMat3 &R) {
 
  756    *
this = Transform(*
this, R);
 
  760inline cVec3& cVec3::operator *= (
const cMat3 &R) {
 
  761    *
this = Transform(*
this, R);
 
  767inline const cVec3 cVec3::operator * (
const cMat3 &R)
 const {
 
  768    return Transform(*
this, R);
 
  774::std::ostream& operator<<( ::std::ostream&,  
const cMat3& );
 
The 3D-matrix, refer it as coat::mat3 in the Core API.
Definition cMat3.h:6
 
The 4D-matrix, refer it as coat::mat4 in the Core API.
Definition cMat4.h:6
 
The 2D-vector, refer it as coat::vec2 in the Core API.
Definition cVec2.h:9
 
The 3D-vector, refer it as coat::vec3 in the Core API.
Definition cVec3.h:10