#include "vec.h"Include dependency graph for matrix.h:

Go to the source code of this file.
Compounds | |
| struct | DrawContext |
| class | Matrix |
Defines | |
| #define | M(a, b) (tmp.r[b*3+a]) |
| #define | M(A, B) t.r[B*3+A] |
| #define | M(A, B) t.r[B*3+A] |
| #define | a (trans.r[0]) |
| #define | b (trans.r[3]) |
| #define | c (trans.r[6]) |
| #define | d (trans.r[1]) |
| #define | e (trans.r[4]) |
| #define | f (trans.r[7]) |
| #define | g (trans.r[2]) |
| #define | h (trans.r[5]) |
| #define | i (trans.r[8]) |
| #define | a (trans.r[0]) |
| #define | b (trans.r[3]) |
| #define | c (trans.r[6]) |
| #define | d (trans.r[1]) |
| #define | e (trans.r[4]) |
| #define | f (trans.r[7]) |
| #define | g (trans.r[2]) |
| #define | h (trans.r[5]) |
| #define | i (trans.r[8]) |
| #define | M(a, b) (tmp.r[b*3+a]) |
Functions | |
| const Matrix | identity_matrix (1, 0, 0, 0, 1, 0, 0, 0, 1, QVector(0, 0, 0)) |
| void | ScaleMatrix (Matrix &matrix, const Vector &scale) |
| void | VectorAndPositionToMatrix (Matrix &matrix, const Vector &v1, const Vector &v2, const Vector &v3, const QVector &pos) |
| void | Zero (Matrix &matrix) |
| void | Identity (Matrix &matrix) |
| void | RotateAxisAngle (Matrix &tmp, const Vector &axis, const float angle) |
| void | Translate (Matrix &matrix, const QVector &v) |
| void | MultMatrix (Matrix &dest, const Matrix &m1, const Matrix &m2) |
| void | CopyMatrix (Matrix &dest, const Matrix &source) |
| QVector | Transform (const Matrix &t, const QVector &v) |
| Vector | Transform (const Matrix &t, const Vector &v) |
| Vector | InvTransformNormal (const Matrix &t, const Vector &v) |
| QVector | InvTransformNormal (const Matrix &t, const QVector &v) |
| QVector | InvTransform (const Matrix &t, const QVector &v) |
| Vector | InvTransform (const Matrix &t, const Vector &v) |
| Vector | TransformNormal (const Matrix &t, const Vector &v) |
| QVector | TransformNormal (const Matrix &t, const QVector &v) |
| int | invert (float b[], float a[]) |
| void | MatrixToVectors (const Matrix &m, Vector &p, Vector &q, Vector &r, QVector &c) |
| QVector | InvScaleTransform (const Matrix &trans, QVector pos) |
| void | InvertMatrix (Matrix &o, const Matrix &trans) |
| void | Rotate (Matrix &tmp, const Vector &axis, float angle) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||||||||
|
Copies Matrix source into the destination Matrix
00205 {
00206 dest = source;
00207 }
|
|
|
Computes a 4x4 identity matrix
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
00297 {
00298 #define a (trans.r[0])
00299 #define b (trans.r[3])
00300 #define c (trans.r[6])
00301 #define d (trans.r[1])
00302 #define e (trans.r[4])
00303 #define f (trans.r[7])
00304 #define g (trans.r[2])
00305 #define h (trans.r[5])
00306 #define i (trans.r[8])
00307 float factor = 1.0F/(-c*e*g+ b*f*g + c*d*h - a*f*h - b*d*i + a*e*i);
00308 o.r[0]=factor*(e*i- f*h);
00309 o.r[3]=factor*(c*h-b*i);
00310 o.r[6]=factor*(b*f-c*e);
00311 o.r[1]=factor*(f*g-d*i);
00312 o.r[4]=factor*(a*i-c*g);
00313 o.r[7]=factor*(c*d-a*f);
00314 o.r[2]=factor*(d*h-e*g);
00315 o.r[5]=factor*(b*g-a*h);
00316 o.r[8]=factor*(a*e-b*d);
00317 #undef a
00318 #undef b
00319 #undef c
00320 #undef d
00321 #undef e
00322 #undef f
00323 #undef g
00324 #undef h
00325 #undef i
00326 o.position= TransformNormal (o,QVector (-trans.position));
00327 }
|
|
||||||||||||
|
00274 {
00275 pos = pos - trans.position;
00276 #define a (trans.r[0])
00277 #define b (trans.r[3])
00278 #define c (trans.r[6])
00279 #define d (trans.r[1])
00280 #define e (trans.r[4])
00281 #define f (trans.r[7])
00282 #define g (trans.r[2])
00283 #define h (trans.r[5])
00284 #define i (trans.r[8])
00285 double factor = 1.0F/(-c*e*g+ b*f*g + c*d*h - a*f*h - b*d*i + a*e*i);
00286 return (QVector(pos.Dot (QVector (e*i- f*h,c*h-b*i,b*f-c*e)),pos.Dot (QVector (f*g-d*i,a*i-c*g, c*d-a*f)),pos.Dot (QVector (d*h-e*g, b*g-a*h, a*e-b*d)))*factor);
00287 #undef a
00288 #undef b
00289 #undef c
00290 #undef d
00291 #undef e
00292 #undef f
00293 #undef g
00294 #undef h
00295 #undef i
00296 }
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||||||||||||||
|
|
|
||||||||||||||||
|
Multiplies m1 and m2 and pops the result into dest; dest != m1, dest !=m2
00176 {
00177 dest.r[0] = m1.r[0]*m2.r[0] + m1.r[3]*m2.r[1] + m1.r[6]*m2.r[2];
00178 dest.r[1] = m1.r[1]*m2.r[0] + m1.r[4]*m2.r[1] + m1.r[7]*m2.r[2];
00179 dest.r[2] = m1.r[2]*m2.r[0] + m1.r[5]*m2.r[1] + m1.r[8]*m2.r[2];
00180
00181 dest.r[3] = m1.r[0]*m2.r[3] + m1.r[3]*m2.r[4] + m1.r[6]*m2.r[5];
00182 dest.r[4] = m1.r[1]*m2.r[3] + m1.r[4]*m2.r[4] + m1.r[7]*m2.r[5];
00183 dest.r[5] = m1.r[2]*m2.r[3] + m1.r[5]*m2.r[4] + m1.r[8]*m2.r[5];
00184
00185
00186 dest.r[6] = m1.r[0]*m2.r[6] + m1.r[3]*m2.r[7] + m1.r[6]*m2.r[8];
00187 dest.r[7] = m1.r[1]*m2.r[6] + m1.r[4]*m2.r[7] + m1.r[7]*m2.r[8];
00188 dest.r[8] = m1.r[2]*m2.r[6] + m1.r[5]*m2.r[7] + m1.r[8]*m2.r[8];
00189
00190 dest.position.i = m1.r[0]*m2.position.i + m1.r[3]*m2.position.j + m1.r[6]*m2.position.k + m1.position.i;
00191 dest.position.j = m1.r[1]*m2.position.i + m1.r[4]*m2.position.j + m1.r[7]*m2.position.k + m1.position.j;
00192 dest.position.k = m1.r[2]*m2.position.i + m1.r[5]*m2.position.j + m1.r[8]*m2.position.k + m1.position.k;
00193
00194 }
|
|
||||||||||||||||
|
00329 {
00330 double c = cos (angle);
00331 double s = sin (angle);
00332 //Row, COl
00333 #define M(a,b) (tmp.r[b*3+a])
00334 M(0,0)=axis.i*axis.i*(1-c)+c;
00335 M(0,1)=axis.i*axis.j*(1-c)-axis.k*s;
00336 M(0,2)=axis.i*axis.k*(1-c)+axis.j*s;
00337 // M(0,3)=0;
00338 M(1,0)=axis.j*axis.i*(1-c)+axis.k*s;
00339 M(1,1)=axis.j*axis.j*(1-c)+c;
00340 M(1,2)=axis.j*axis.k*(1-c)-axis.i*s;
00341 // M(1,3)=0;
00342 M(2,0)=axis.i*axis.k*(1-c)-axis.j*s;
00343 M(2,1)=axis.j*axis.k*(1-c)+axis.i*s;
00344 M(2,2)=axis.k*axis.k*(1-c)+c;
00345 // M(2,3)=0;
00346 #undef M
00347 tmp.position.Set(0,0,0);
00348 }
|
|
||||||||||||||||
|
Computes a Translation matrix based on x,y,z translation
00139 {
00140 float c = cosf (angle);
00141 float s = sinf (angle);
00142 #define M(a,b) (tmp.r[b*3+a])
00143 M(0,0)=axis.i*axis.i*(1-c)+c;
00144 M(0,1)=axis.i*axis.j*(1-c)-axis.k*s;
00145 M(0,2)=axis.i*axis.k*(1-c)+axis.j*s;
00146 // M(0,3)=0;
00147 M(1,0)=axis.j*axis.i*(1-c)+axis.k*s;
00148 M(1,1)=axis.j*axis.j*(1-c)+c;
00149 M(1,2)=axis.j*axis.k*(1-c)-axis.i*s;
00150 // M(1,3)=0;
00151 M(2,0)=axis.i*axis.k*(1-c)-axis.j*s;
00152 M(2,1)=axis.j*axis.k*(1-c)+axis.i*s;
00153 M(2,2)=axis.k*axis.k*(1-c)+c;
00154 // M(2,3)=0;
00155 #undef M
00156 tmp.position.Set (0,0,0);
00157 }
|
|
||||||||||||
|
moves a vector struct to a matrix
|
|
||||||||||||
|
|
|
||||||||||||
|
moves a vector in the localspace to world space through matrix t
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||||||||||||||
|
|
|
|
zeros out a 4x4 matrix quickly
|
1.2.15