Changeset 124

Show
Ignore:
Timestamp:
11/22/07 03:28:03 (1 year ago)
Author:
baxissimo
Message:

* Added .length param to vectors to make them compile time compatible with regular D arrays.
* Made underlying data properties public (m00, etc.)
* Fixed bug in Matrix22 isOrthogonal method

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Helix/helix/linalgebra.d

    r123 r124  
    132132    struct Vector2 
    133133    { 
     134        enum { length = 2u } 
     135 
    134136        align(1) 
    135137        { 
     
    409411    struct Vector3 
    410412    { 
     413        enum { length = 3u } 
     414 
    411415        align(1) 
    412416        { 
     
    739743    struct Vector4 
    740744    { 
     745        enum { length = 4u } 
     746 
    741747        align(1) 
    742748        { 
     
    15381544    struct Matrix22 
    15391545    { 
    1540         private align(1) union 
     1546        align(1) union 
    15411547        { 
    15421548            struct 
     
    16691675        bool isOrthogonal(int relprec = defrelprec, int absprec = defabsprec) 
    16701676        { 
    1671             return equal(cross(v[0],v[1]),0, relprec, absprec); 
     1677            return equal(abs(cross(v[0],v[1])),1.0, relprec, absprec); 
    16721678        } 
    16731679         
     
    17861792        void invert() 
    17871793        { 
    1788             *this = inverse(); 
     1794            real idet = 1.0/(m00 * m11 - m01 * m10); 
     1795            swap(m00,m11); 
     1796            m10 = -m10; 
     1797            m01 = -m01; 
     1798            (*this) *= idet; 
    17891799        } 
    17901800         
     
    18691879        */ 
    18701880        void polarDecomposition(out Matrix22 Q, out Matrix22 S) 
    1871         out { assert(Q.isRotation()); } 
     1881            out { assert(Q.isRotation(),  
     1882                         "(postcondition) Q not a rotation:\n" ~ Q.toString); } 
    18721883        body 
    18731884        { 
     
    20842095    struct Matrix33 
    20852096    { 
    2086         private align(1) union 
     2097        align(1) union 
    20872098        { 
    20882099            struct 
     
    27482759    struct Matrix44 
    27492760    { 
    2750         private align (1) union 
     2761        align (1) union 
    27512762        { 
    27522763            struct