My Project: openb3dlib.mod/openb3d/src/geom.h Source File

My Project

geom.h
Go to the documentation of this file.
1 #ifndef GEOM_H
2 #define GEOM_H
3
4 #include <math.h>
5
6 class Vector;
7 class Line;
8 class Plane;
9 class MMatrix;
10 class Transform;
11
12 const float PI=3.14159265359f; //180 degrees
13 const float TWOPI=PI*2.0f; //360 degrees
14 const float HALFPI=PI*.5f; //90 degrees
15 const float QUARTERPI=PI*.25f; //45 degrees
16 const float EPSILON=.000001f; //small value
17 //const float INFINITY;////=10000000.0f; //big value
18
19 class Vector{
20 public:
21 float x,y,z;
22
23 Vector():x(0),y(0),z(0){
24 }
25 Vector( float x,float y,float z ):x(x),y(y),z(z){
26 }
27 operator float*(){
28 return &x;
29 }
30 operator const float *(){
31 return &x;
32 }
33 float &operator[]( int n ){
34 return (&x)[n];
35 }
36 float operator[]( int n )const{
37 return (&x)[n];
38 }
39 Vector operator-()const{
40 return Vector( -x,-y,-z );
41 }
42 Vector operator*( float scale )const{
43 return Vector( x*scale,y*scale,z*scale );
44 }
45 Vector operator*( const Vector &q )const{
46 return Vector( x*q.x,y*q.y,z*q.z );
47 }
48 Vector operator/( float scale )const{
49 return Vector( x/scale,y/scale,z/scale );
50 }
51 Vector operator/( const Vector &q )const{
52 return Vector( x/q.x,y/q.y,z/q.z );
53 }
54 Vector operator+( const Vector &q )const{
55 return Vector( x+q.x,y+q.y,z+q.z );
56 }
57 Vector operator-( const Vector &q )const{
58 return Vector( x-q.x,y-q.y,z-q.z );
59 }
60 Vector &operator*=( float scale ){
61 x*=scale;y*=scale;z*=scale;return *this;
62 }
63 Vector &operator*=( const Vector &q ){
64 x*=q.x;y*=q.y;z*=q.z;return *this;
65 }
66 Vector &operator/=( float scale ){
67 x/=scale;y/=scale;z/=scale;return *this;
68 }
69 Vector &operator/=( const Vector &q ){
70 x/=q.x;y/=q.y;z/=q.z;return *this;
71 }
72 Vector &operator+=( const Vector &q ){
73 x+=q.x;y+=q.y;z+=q.z;return *this;
74 }
75 Vector &operator-=( const Vector &q ){
76 x-=q.x;y-=q.y;z-=q.z;return *this;
77 }
78 bool operator<( const Vector &q )const{
79 if( fabs(x-q.x)>EPSILON ) return x<q.x ? true : false;
80 if( fabs(y-q.y)>EPSILON ) return y<q.y ? true : false;
81 return fabs(z-q.z)>EPSILON && z<q.z;
82 }
83 bool operator==( const Vector &q )const{
84 return fabs(x-q.x)<=EPSILON && fabs(y-q.y)<=EPSILON && fabs(z-q.z)<=EPSILON;
85 }
86 bool operator!=( const Vector &q )const{
87 return fabs(x-q.x)>EPSILON || fabs(y-q.y)>EPSILON || fabs(z-q.z)>EPSILON;
88 }
89 float dot( const Vector &q )const{
90 return x*q.x+y*q.y+z*q.z;
91 }
92 Vector cross( const Vector &q )const{
93 return Vector( y*q.z-z*q.y,z*q.x-x*q.z,x*q.y-y*q.x );
94 }
95 float length()const{
96 return sqrtf(x*x+y*y+z*z);
97 }
98 float distance( const Vector &q )const{
99 float dx=x-q.x,dy=y-q.y,dz=z-q.z;return sqrtf(dx*dx+dy*dy+dz*dz);
100 }
101 Vector normalized()const{
102 float l=length();return Vector( x/l,y/l,z/l );
103 }
104 void normalize(){
105 float l=length();x/=l;y/=l;z/=l;
106 }
107 float yaw()const{
108 return -atan2f( x,z );
109 }
110 float pitch()const{
111 return -atan2f( y,sqrtf( x*x+z*z ) );
112 }
113 void clear(){
114 x=y=z=0;
115 }
116 };
117
118 class Line{
119 public:
120 Vector o,d;
121 Line(){
122 }
123 Line( const Vector &o,const Vector &d ):o(o),d(d){
124 }
125 Line operator+( const Vector &q )const{
126 return Line( o+q,d );
127 }
128 Line operator-( const Vector &q )const{
129 return Line( o-q,d );
130 }
131 Vector operator*( float q )const{
132 return o+d*q;
133 }
134 Vector nearest( const Vector &q )const{
135 return o+d*(d.dot(q-o)/d.dot(d));
136 }
137 };
138
139 class Plane{
140 public:
141 Vector n;
142 float d;
143
144 Plane():d(0){
145 }
146 //normal/offset form
147 Plane( const Vector &n,float d ):n(n),d(d){
148 }
149 //point/normal form
150 Plane( const Vector &p,const Vector &n ):n(n),d(-n.dot(p)){
151 }
152 //create plane from tri
153 Plane( const Vector &v0,const Vector &v1,const Vector &v2 ){
154 n=(v1-v0).cross(v2-v0).normalized();d=-n.dot(v0);
155 }
156 Plane operator-()const{
157 return Plane( -n,-d );
158 }
159 float t_intersect( const Line &q )const{
160 return -distance(q.o)/n.dot(q.d);
161 }
162 Vector intersect( const Line &q )const{
163 return q*t_intersect(q);
164 }
165 Line intersect( const Plane &q )const{
166 Vector lv=n.cross( q.n ).normalized();
167 return Line( q.intersect( Line( nearest( n*-d ),n.cross(lv) ) ),lv );
168 }
169 Vector nearest( const Vector &q )const{
170 return q-n*distance(q);
171 }
172 void negate(){
173 n=-n;d=-d;
174 }
175 float distance( const Vector &q )const{
176 return n.dot(q)+d;
177 }
178 };
179
180 struct Quat{
181 float w;
182 Vector v;
183 Quat():w(1){
184 }
185 Quat( float w,const Vector &v ):w(w),v(v){
186 }
187 Quat operator-()const{
188 return Quat( w,-v );
189 }
190 Quat operator+( const Quat &q )const{
191 return Quat( w+q.w,v+q.v );
192 }
193 Quat operator-( const Quat &q )const{
194 return Quat( w-q.w,v-q.v );
195 }
196 Quat operator*( const Quat &q )const{
197 return Quat( w*q.w-v.dot(q.v),q.v.cross(v)+q.v*w+v*q.w );
198 }
199 Vector operator*( const Vector &q )const{
200 return (*this * Quat(0,q) * -*this).v;
201 }
202 Quat operator*( float q )const{
203 return Quat( w*q,v*q );
204 }
205 Quat operator/( float q )const{
206 return Quat( w/q,v/q );
207 }
208 float dot( const Quat &q )const{
209 return v.x*q.v.x+v.y*q.v.y+v.z*q.v.z+w*q.w;
210 }
211 float length()const{
212 return sqrtf( w*w+v.x*v.x+v.y*v.y+v.z*v.z );
213 }
214 void normalize(){
215 *this=*this/length();
216 }
217 Quat normalized()const{
218 return *this/length();
219 }
220 Quat slerpTo( const Quat &q,float a )const{
221 Quat t=q;
222 float d=dot(q),b=1-a;
223 if( d<0 ){ t.w=-t.w;t.v=-t.v;d=-d; }
224 if( d<1-EPSILON ){
225 float om=acosf( d );
226 float si=sinf( om );
227 a=sinf( a*om )/si;
228 b=sinf( b*om )/si;
229 }
230 return *this*b + t*a;
231 }
232 Vector i()const{
233 float xz=v.x*v.z,wy=w*v.y;
234 float xy=v.x*v.y,wz=w*v.z;
235 float yy=v.y*v.y,zz=v.z*v.z;
236 return Vector( 1-2*(yy+zz),2*(xy-wz),2*(xz+wy) );
237 }
238 Vector j()const{
239 float yz=v.y*v.z,wx=w*v.x;
240 float xy=v.x*v.y,wz=w*v.z;
241 float xx=v.x*v.x,zz=v.z*v.z;
242 return Vector( 2*(xy+wz),1-2*(xx+zz),2*(yz-wx) );
243 }
244 Vector k()const{
245 float xz=v.x*v.z,wy=w*v.y;
246 float yz=v.y*v.z,wx=w*v.x;
247 float xx=v.x*v.x,yy=v.y*v.y;
248 return Vector( 2*(xz-wy),2*(yz+wx),1-2*(xx+yy) );
249 }
250 };
251
252 class MMatrix{
253 static MMatrix tmps[64];
254 static MMatrix &alloc_tmp(){ static int tmp=0;return tmps[tmp++&63]; }
255 friend class Transform;
256 public:
257 Vector i,j,k;
258
259 MMatrix():i(Vector(1,0,0)),j(Vector(0,1,0)),k(Vector(0,0,1)){
260 }
261 MMatrix( const Vector &i,const Vector &j,const Vector &k ):i(i),j(j),k(k){
262 }
263 MMatrix( const Quat &q ){
264 float xx=q.v.x*q.v.x,yy=q.v.y*q.v.y,zz=q.v.z*q.v.z;
265 float xy=q.v.x*q.v.y,xz=q.v.x*q.v.z,yz=q.v.y*q.v.z;
266 float wx=q.w*q.v.x,wy=q.w*q.v.y,wz=q.w*q.v.z;
267 i=Vector( 1-2*(yy+zz),2*(xy-wz),2*(xz+wy) ),
268 j=Vector( 2*(xy+wz),1-2*(xx+zz),2*(yz-wx) ),
269 k=Vector( 2*(xz-wy),2*(yz+wx),1-2*(xx+yy) );
270 }
271 MMatrix( float angle,const Vector &axis ){
272 const Vector &u=axis;
273 float c=cosf(angle),s=sinf(angle);
274 float x2=axis.x*axis.x,y2=axis.y*axis.y,z2=axis.z*axis.z;
275 i=Vector( x2+c*(1-x2),u.x*u.y*(1-c)-u.z*s,u.z*u.x*(1-c)+u.y*s );
276 j=Vector( u.x*u.y*(1-c)+u.z*s,y2+c*(1-y2),u.y*u.z*(1-c)-u.x*s );
277 k=Vector( u.z*u.x*(1-c)-u.y*s,u.y*u.z*(1-c)+u.x*s,z2+c*(1-z2) );
278 }
279 Vector &operator[]( int n ){
280 return (&i)[n];
281 }
282 const Vector &operator[]( int n )const{
283 return (&i)[n];
284 }
285 MMatrix &operator~()const{
286 MMatrix &m=alloc_tmp();
287 m.i.x=i.x;m.i.y=j.x;m.i.z=k.x;
288 m.j.x=i.y;m.j.y=j.y;m.j.z=k.y;
289 m.k.x=i.z;m.k.y=j.z;m.k.z=k.z;
290 return m;
291 }
292 float determinant()const{
293 return i.x*(j.y*k.z-j.z*k.y )-i.y*(j.x*k.z-j.z*k.x )+i.z*(j.x*k.y-j.y*k.x );
294 }
295 MMatrix &operator-()const{
296 MMatrix &m=alloc_tmp();
297 float t=1.0f/determinant();
298 m.i.x= t*(j.y*k.z-j.z*k.y);m.i.y=-t*(i.y*k.z-i.z*k.y);m.i.z= t*(i.y*j.z-i.z*j.y);
299 m.j.x=-t*(j.x*k.z-j.z*k.x);m.j.y= t*(i.x*k.z-i.z*k.x);m.j.z=-t*(i.x*j.z-i.z*j.x);
300 m.k.x= t*(j.x*k.y-j.y*k.x);m.k.y=-t*(i.x*k.y-i.y*k.x);m.k.z= t*(i.x*j.y-i.y*j.x);
301 return m;
302 }
303 MMatrix &cofactor()const{
304 MMatrix &m=alloc_tmp();
305 m.i.x= (j.y*k.z-j.z*k.y);m.i.y=-(j.x*k.z-j.z*k.x);m.i.z= (j.x*k.y-j.y*k.x);
306 m.j.x=-(i.y*k.z-i.z*k.y);m.j.y= (i.x*k.z-i.z*k.x);m.j.z=-(i.x*k.y-i.y*k.x);
307 m.k.x= (i.y*j.z-i.z*j.y);m.k.y=-(i.x*j.z-i.z*j.x);m.k.z= (i.x*j.y-i.y*j.x);
308 return m;
309 }
310 bool operator==( const MMatrix &q )const{
311 return i==q.i && j==q.j && k==q.k;
312 }
313 bool operator!=( const MMatrix &q )const{
314 return i!=q.i || j!=q.j || k!=q.k;
315 }
316 Vector operator*( const Vector &q )const{
317 return Vector( i.x*q.x+j.x*q.y+k.x*q.z,i.y*q.x+j.y*q.y+k.y*q.z,i.z*q.x+j.z*q.y+k.z*q.z );
318 }
319 MMatrix &operator*( const MMatrix &q )const{
320 MMatrix &m=alloc_tmp();
321 m.i.x=i.x*q.i.x+j.x*q.i.y+k.x*q.i.z;m.i.y=i.y*q.i.x+j.y*q.i.y+k.y*q.i.z;m.i.z=i.z*q.i.x+j.z*q.i.y+k.z*q.i.z;
322 m.j.x=i.x*q.j.x+j.x*q.j.y+k.x*q.j.z;m.j.y=i.y*q.j.x+j.y*q.j.y+k.y*q.j.z;m.j.z=i.z*q.j.x+j.z*q.j.y+k.z*q.j.z;
323 m.k.x=i.x*q.k.x+j.x*q.k.y+k.x*q.k.z;m.k.y=i.y*q.k.x+j.y*q.k.y+k.y*q.k.z;m.k.z=i.z*q.k.x+j.z*q.k.y+k.z*q.k.z;
324 return m;
325 }
326 void orthogonalize(){
327 k.normalize();
328 i=j.cross( k ).normalized();
329 j=k.cross( i );
330 }
331 MMatrix &orthogonalized()const{
332 MMatrix &m=alloc_tmp();
333 m=*this;m.orthogonalize();
334 return m;
335 }
336 };
337
338 class Box{
339 public:
340 Vector a,b;
341 Box():a( Vector(INFINITY,INFINITY,INFINITY) ),b( Vector(-INFINITY,-INFINITY,-INFINITY) ){
342 }
343 Box( const Vector &q ):a(q),b(q){
344 }
345 Box( const Vector &a,const Vector &b ):a(a),b(b){
346 }
347 Box( const Line &l ):a(l.o),b(l.o){
348 update( l.o+l.d );
349 }
350 void clear(){
351 a.x=a.y=a.z=INFINITY;
352 b.x=b.y=b.z=-INFINITY;
353 }
354 bool empty()const{
355 return b.x<a.x || b.y<a.y || b.z<a.z;
356 }
357 Vector centre()const{
358 return Vector( (a.x+b.x)*.5f,(a.y+b.y)*.5f,(a.z+b.z)*.5f );
359 }
360 Vector corner( int n )const{
361 return Vector( ((n&1)?b:a).x,((n&2)?b:a).y,((n&4)?b:a).z );
362 }
363 void update( const Vector &q ){
364 if( q.x<a.x ) a.x=q.x;if( q.y<a.y ) a.y=q.y;if( q.z<a.z ) a.z=q.z;
365 if( q.x>b.x ) b.x=q.x;if( q.y>b.y ) b.y=q.y;if( q.z>b.z ) b.z=q.z;
366 }
367 void update( const Box &q ){
368 if( q.a.x<a.x ) a.x=q.a.x;if( q.a.y<a.y ) a.y=q.a.y;if( q.a.z<a.z ) a.z=q.a.z;
369 if( q.b.x>b.x ) b.x=q.b.x;if( q.b.y>b.y ) b.y=q.b.y;if( q.b.z>b.z ) b.z=q.b.z;
370 }
371 bool overlaps( const Box &q )const{
372 return
373 (b.x<q.b.x?b.x:q.b.x)>=(a.x>q.a.x?a.x:q.a.x) &&
374 (b.y<q.b.y?b.y:q.b.y)>=(a.y>q.a.y?a.y:q.a.y) &&
375 (b.z<q.b.z?b.z:q.b.z)>=(a.z>q.a.z?a.z:q.a.z);
376 }
377 void expand( float n ){
378 a.x-=n;a.y-=n;a.z-=n;b.x+=n;b.y+=n;b.z+=n;
379 }
380 float width()const{
381 return b.x-a.x;
382 }
383 float height()const{
384 return b.y-a.y;
385 }
386 float depth()const{
387 return b.z-a.z;
388 }
389 bool contains( const Vector &q ){
390 return q.x>=a.x && q.x<=b.x && q.y>=a.y && q.y<=b.y && q.z>=a.z && q.z<=b.z;
391 }
392 };
393
394 class Transform{
395 static Transform tmps[64];
396 static Transform &alloc_tmp(){ static int tmp=0;return tmps[tmp++&63]; }
397 public:
398 MMatrix m;
399 Vector v;
400
401 Transform(){
402 }
403 Transform( const MMatrix &m ):m(m){
404 }
405 Transform( const Vector &v ):v(v){
406 }
407 Transform( const MMatrix &m,const Vector &v ):m(m),v(v){
408 }
409 Transform &operator-()const{
410 Transform &t=alloc_tmp();
411 t.m=-m;t.v=t.m*-v;
412 return t;
413 }
414 Transform &operator~()const{
415 Transform &t=alloc_tmp();
416 t.m=~m;t.v=t.m*-v;
417 return t;
418 }
419 Vector operator*( const Vector &q )const{
420 return m*q+v;
421 }
422 Line operator*( const Line &q )const{
423 Vector t=(*this)*q.o;
424 return Line( t,(*this)*(q.o+q.d)-t );
425 }
426 Box operator*( const Box &q )const{
427 Box t( (*this*q.corner(0) ) );
428 for( int k=1;k<8;++k ) t.update( *this*q.corner(k) );
429 return t;
430 }
431 Transform &operator*( const Transform &q )const{
432 Transform &t=alloc_tmp();
433 t.m=m*q.m;t.v=m*q.v+v;
434 return t;
435 }
436 bool operator==( const Transform &q )const{
437 return m==q.m && v==q.v;
438 }
439 bool operator!=( const Transform &q )const{
440 return !operator==( q );
441 }
442 };
443
444 inline float transformRadius( float r,const MMatrix &t ){
445 static const float sq_3=sqrtf(1.0f/3.0f);
446 return (t * Vector( sq_3,sq_3,sq_3 )).length()*r;
447 }
448
449 inline MMatrix pitchMMatrix( float q ){
450 return MMatrix( Vector(1,0,0),Vector(0,cosf(q),sinf(q)),Vector(0,-sinf(q),cosf(q)) );
451 }
452
453 inline MMatrix yawMMatrix( float q ){
454 return MMatrix( Vector(cosf(q),0,sinf(q)),Vector(0,1,0),Vector(-sinf(q),0,cosf(q)) );
455 }
456
457 inline MMatrix rollMMatrix( float q ){
458 return MMatrix( Vector(cosf(q),sinf(q),0),Vector(-sinf(q),cosf(q),0),Vector(0,0,1) );
459 }
460
461 inline float MMatrixPitch( const MMatrix &m ){
462 return m.k.pitch();
463 // return asinf( -m.k.y );
464 }
465
466 inline float MMatrixYaw( const MMatrix &m ){
467 return m.k.yaw();
468 //return atan2f( -m.k.x,m.k.z );
469 }
470
471 inline float MMatrixRoll( const MMatrix &m ){
472 return atan2f( m.i.y,m.j.y );
473 //MMatrix t=pitchMMatrix( -MMatrixPitch(m) )*yawMMatrix( -MMatrixYaw(m) )*m;
474 //return atan2f( t.i.y,t.i.x );
475 }
476
477 inline MMatrix scaleMMatrix( float x,float y,float z ){
478 return MMatrix( Vector( x,0,0 ),Vector( 0,y,0 ),Vector( 0,0,z ) );
479 }
480
481 inline MMatrix scaleMMatrix( const Vector &scale ){
482 return MMatrix( Vector( scale.x,0,0 ),Vector( 0,scale.y,0 ),Vector( 0,0,scale.z ) );
483 }
484
485 inline Quat pitchQuat( float p ){
486 return Quat( cosf(p/-2),Vector( sinf(p/-2),0,0 ) );
487 }
488
489 inline Quat yawQuat( float y ){
490 return Quat( cosf(y/2),Vector( 0,sinf(y/2),0 ) );
491 }
492
493 inline Quat rollQuat( float r ){
494 return Quat( cosf(r/-2),Vector( 0,0,sinf(r/-2) ) );
495 }
496
497 //inline Quat rotationQuat( float p,float y,float r ){
498 // return yawQuat(y)*pitchQuat(p)*rollQuat(r);
499 //}
500
501 Quat rotationQuat( float p,float y,float r );
502
503 inline MMatrix rotationMMatrix( float p,float y,float r ){
504 return yawMMatrix(y)*pitchMMatrix(p)*rollMMatrix(r);
505 }
506
507 inline MMatrix rotationMMatrix( const Vector &rot ){
508 return yawMMatrix(rot.y)*pitchMMatrix(rot.x)*rollMMatrix(rot.z);
509 }
510
511 inline float quatPitch( const Quat &q ){
512 return q.k().pitch();
513 }
514
515 inline float quatYaw( const Quat &q ){
516 return q.k().yaw();
517 }
518
519 inline float quatRoll( const Quat &q ){
520 // Vector i=q.i(),j=q.j();
521 // return atan2f( i.y,j.y );
522 return MMatrixRoll( q );
523 }
524
525 inline Quat MMatrixQuat( const MMatrix &p ){
526 MMatrix m=p;
527 m.orthogonalize();
528 float t=m.i.x+m.j.y+m.k.z,w,x,y,z;
529 if( t>EPSILON ){
530 t=sqrtf( t+1 )*2;
531 x=(m.k.y-m.j.z)/t;
532 y=(m.i.z-m.k.x)/t;
533 z=(m.j.x-m.i.y)/t;
534 w=t/4;
535 }else if( m.i.x>m.j.y && m.i.x>m.k.z ){
536 t=sqrtf( m.i.x-m.j.y-m.k.z+1 )*2;
537 x=t/4;
538 y=(m.j.x+m.i.y)/t;
539 z=(m.i.z+m.k.x)/t;
540 w=(m.k.y-m.j.z)/t;
541 }else if( m.j.y>m.k.z ){
542 t=sqrtf( m.j.y-m.k.z-m.i.x+1 )*2;
543 x=(m.j.x+m.i.y)/t;
544 y=t/4;
545 z=(m.k.y+m.j.z)/t;
546 w=(m.i.z-m.k.x)/t;
547 }else{
548 t=sqrtf( m.k.z-m.j.y-m.i.x+1 )*2;
549 x=(m.i.z+m.k.x)/t;
550 y=(m.k.y+m.j.z)/t;
551 z=t/4;
552 w=(m.j.x-m.i.y)/t;
553 }
554 return Quat( w,Vector( x,y,z ) );
555 }
556
557 #endif
Box::centre
Vector centre() const
Definition: geom.h:357
Box::update
void update(const Box &q)
Definition: geom.h:367
pitchMMatrix
MMatrix pitchMMatrix(float q)
Definition: geom.h:449
Vector::x
float x
Definition: geom.h:21
Plane::Plane
Plane(const Vector &n, float d)
Definition: geom.h:147
Vector::y
float y
Definition: geom.h:21
Box::update
void update(const Vector &q)
Definition: geom.h:363
Quat::operator-
Quat operator-() const
Definition: geom.h:187
Vector::operator/=
Vector & operator/=(const Vector &q)
Definition: geom.h:69
Box::a
Vector a
Definition: geom.h:340
MMatrix::i
Vector i
Definition: geom.h:257
Plane::d
float d
Definition: geom.h:142
Quat::operator*
Quat operator*(float q) const
Definition: geom.h:202
Box::contains
bool contains(const Vector &q)
Definition: geom.h:389
Quat::v
Vector v
Definition: geom.h:182
EPSILON
const float EPSILON
Definition: geom.h:16
Box::Box
Box()
Definition: geom.h:341
Vector::Vector
Vector(float x, float y, float z)
Definition: geom.h:25
Vector::normalized
Vector normalized() const
Definition: geom.h:101
MMatrix::determinant
float determinant() const
Definition: geom.h:292
yawQuat
Quat yawQuat(float y)
Definition: geom.h:489
Vector::operator!=
bool operator!=(const Vector &q) const
Definition: geom.h:86
MMatrix::orthogonalize
void orthogonalize()
Definition: geom.h:326
Transform::operator==
bool operator==(const Transform &q) const
Definition: geom.h:436
Box::Box
Box(const Line &l)
Definition: geom.h:347
MMatrix::operator~
MMatrix & operator~() const
Definition: geom.h:285
MMatrix::operator[]
Vector & operator[](int n)
Definition: geom.h:279
Vector::operator*=
Vector & operator*=(float scale)
Definition: geom.h:60
Transform::operator*
Line operator*(const Line &q) const
Definition: geom.h:422
MMatrix::j
Vector j
Definition: geom.h:257
Quat::Quat
Quat()
Definition: geom.h:183
Plane::operator-
Plane operator-() const
Definition: geom.h:156
Vector::operator[]
float operator[](int n) const
Definition: geom.h:36
quatRoll
float quatRoll(const Quat &q)
Definition: geom.h:519
Line::operator*
Vector operator*(float q) const
Definition: geom.h:131
quatYaw
float quatYaw(const Quat &q)
Definition: geom.h:515
Vector::operator+
Vector operator+(const Vector &q) const
Definition: geom.h:54
Vector::operator*
Vector operator*(float scale) const
Definition: geom.h:42
HALFPI
const float HALFPI
Definition: geom.h:14
Vector::yaw
float yaw() const
Definition: geom.h:107
Vector::pitch
float pitch() const
Definition: geom.h:110
Box::depth
float depth() const
Definition: geom.h:386
MMatrixQuat
Quat MMatrixQuat(const MMatrix &p)
Definition: geom.h:525
Quat::operator-
Quat operator-(const Quat &q) const
Definition: geom.h:193
Line::Line
Line(const Vector &o, const Vector &d)
Definition: geom.h:123
Box::overlaps
bool overlaps(const Box &q) const
Definition: geom.h:371
MMatrix::MMatrix
MMatrix()
Definition: geom.h:259
Vector::operator==
bool operator==(const Vector &q) const
Definition: geom.h:83
Box::Box
Box(const Vector &q)
Definition: geom.h:343
yawMMatrix
MMatrix yawMMatrix(float q)
Definition: geom.h:453
MMatrix::MMatrix
MMatrix(const Vector &i, const Vector &j, const Vector &k)
Definition: geom.h:261
Line::operator+
Line operator+(const Vector &q) const
Definition: geom.h:125
Plane::Plane
Plane(const Vector &v0, const Vector &v1, const Vector &v2)
Definition: geom.h:153
Vector::length
float length() const
Definition: geom.h:95
MMatrixRoll
float MMatrixRoll(const MMatrix &m)
Definition: geom.h:471
Line::operator-
Line operator-(const Vector &q) const
Definition: geom.h:128
pitchQuat
Quat pitchQuat(float p)
Definition: geom.h:485
Transform
Definition: geom.h:394
QUARTERPI
const float QUARTERPI
Definition: geom.h:15
transformRadius
float transformRadius(float r, const MMatrix &t)
Definition: geom.h:444
Vector::operator-
Vector operator-() const
Definition: geom.h:39
scaleMMatrix
MMatrix scaleMMatrix(float x, float y, float z)
Definition: geom.h:477
Transform::m
MMatrix m
Definition: geom.h:398
MMatrix::orthogonalized
MMatrix & orthogonalized() const
Definition: geom.h:331
Vector::operator/
Vector operator/(const Vector &q) const
Definition: geom.h:51
Vector::Vector
Vector()
Definition: geom.h:23
PI
const float PI
Definition: geom.h:12
rollQuat
Quat rollQuat(float r)
Definition: geom.h:493
Box::Box
Box(const Vector &a, const Vector &b)
Definition: geom.h:345
Plane::t_intersect
float t_intersect(const Line &q) const
Definition: geom.h:159
Vector::clear
void clear()
Definition: geom.h:113
MMatrix::operator*
Vector operator*(const Vector &q) const
Definition: geom.h:316
Box::corner
Vector corner(int n) const
Definition: geom.h:360
Transform::Transform
Transform()
Definition: geom.h:401
rotationQuat
Quat rotationQuat(float p, float y, float r)
Definition: geom.cpp:6
MMatrix::operator!=
bool operator!=(const MMatrix &q) const
Definition: geom.h:313
Vector::operator<
bool operator<(const Vector &q) const
Definition: geom.h:78
Plane::Plane
Plane(const Vector &p, const Vector &n)
Definition: geom.h:150
Transform::operator!=
bool operator!=(const Transform &q) const
Definition: geom.h:439
Line
Definition: geom.h:118
Plane::nearest
Vector nearest(const Vector &q) const
Definition: geom.h:169
Line::nearest
Vector nearest(const Vector &q) const
Definition: geom.h:134
Box::clear
void clear()
Definition: geom.h:350
Vector::dot
float dot(const Vector &q) const
Definition: geom.h:89
Quat::i
Vector i() const
Definition: geom.h:232
MMatrix::k
Vector k
Definition: geom.h:257
Transform::Transform
Transform(const MMatrix &m)
Definition: geom.h:403
Transform::v
Vector v
Definition: geom.h:399
Quat::Quat
Quat(float w, const Vector &v)
Definition: geom.h:185
Vector::operator/=
Vector & operator/=(float scale)
Definition: geom.h:66
Vector::operator-
Vector operator-(const Vector &q) const
Definition: geom.h:57
Box::expand
void expand(float n)
Definition: geom.h:377
rotationMMatrix
MMatrix rotationMMatrix(float p, float y, float r)
Definition: geom.h:503
Quat::operator/
Quat operator/(float q) const
Definition: geom.h:205
Quat::operator*
Vector operator*(const Vector &q) const
Definition: geom.h:199
Plane
Definition: geom.h:139
Box::b
Vector b
Definition: geom.h:340
MMatrix::operator==
bool operator==(const MMatrix &q) const
Definition: geom.h:310
Transform::operator-
Transform & operator-() const
Definition: geom.h:409
Box::height
float height() const
Definition: geom.h:383
Plane::distance
float distance(const Vector &q) const
Definition: geom.h:175
Transform::Transform
Transform(const Vector &v)
Definition: geom.h:405
Transform::operator*
Transform & operator*(const Transform &q) const
Definition: geom.h:431
Vector::operator+=
Vector & operator+=(const Vector &q)
Definition: geom.h:72
Box::width
float width() const
Definition: geom.h:380
Vector::operator-=
Vector & operator-=(const Vector &q)
Definition: geom.h:75
Quat
Definition: geom.h:180
MMatrix::MMatrix
MMatrix(float angle, const Vector &axis)
Definition: geom.h:271
Box::empty
bool empty() const
Definition: geom.h:354
Plane::negate
void negate()
Definition: geom.h:172
Transform::operator*
Box operator*(const Box &q) const
Definition: geom.h:426
Plane::Plane
Plane()
Definition: geom.h:144
Vector::normalize
void normalize()
Definition: geom.h:104
Quat::k
Vector k() const
Definition: geom.h:244
Quat::normalize
void normalize()
Definition: geom.h:214
MMatrix::operator[]
const Vector & operator[](int n) const
Definition: geom.h:282
Transform::operator*
Vector operator*(const Vector &q) const
Definition: geom.h:419
Quat::normalized
Quat normalized() const
Definition: geom.h:217
Quat::dot
float dot(const Quat &q) const
Definition: geom.h:208
Vector::distance
float distance(const Vector &q) const
Definition: geom.h:98
Line::Line
Line()
Definition: geom.h:121
Vector
Definition: geom.h:19
Line::d
Vector d
Definition: geom.h:120
Box
Definition: geom.h:338
MMatrix::operator-
MMatrix & operator-() const
Definition: geom.h:295
rollMMatrix
MMatrix rollMMatrix(float q)
Definition: geom.h:457
Quat::w
float w
Definition: geom.h:181
quatPitch
float quatPitch(const Quat &q)
Definition: geom.h:511
MMatrix::operator*
MMatrix & operator*(const MMatrix &q) const
Definition: geom.h:319
Quat::length
float length() const
Definition: geom.h:211
MMatrix::cofactor
MMatrix & cofactor() const
Definition: geom.h:303
Quat::operator*
Quat operator*(const Quat &q) const
Definition: geom.h:196
Transform::operator~
Transform & operator~() const
Definition: geom.h:414
Quat::operator+
Quat operator+(const Quat &q) const
Definition: geom.h:190
TWOPI
const float TWOPI
Definition: geom.h:13
MMatrixPitch
float MMatrixPitch(const MMatrix &m)
Definition: geom.h:461
MMatrix
Definition: geom.h:252
Plane::intersect
Vector intersect(const Line &q) const
Definition: geom.h:162
Vector::operator[]
float & operator[](int n)
Definition: geom.h:33
Transform::Transform
Transform(const MMatrix &m, const Vector &v)
Definition: geom.h:407
Vector::operator/
Vector operator/(float scale) const
Definition: geom.h:48
Plane::intersect
Line intersect(const Plane &q) const
Definition: geom.h:165
Vector::operator*=
Vector & operator*=(const Vector &q)
Definition: geom.h:63
MMatrixYaw
float MMatrixYaw(const MMatrix &m)
Definition: geom.h:466
Vector::operator*
Vector operator*(const Vector &q) const
Definition: geom.h:45
Plane::n
Vector n
Definition: geom.h:141
Quat::j
Vector j() const
Definition: geom.h:238
Quat::slerpTo
Quat slerpTo(const Quat &q, float a) const
Definition: geom.h:220
Vector::cross
Vector cross(const Vector &q) const
Definition: geom.h:92
MMatrix::MMatrix
MMatrix(const Quat &q)
Definition: geom.h:263
Line::o
Vector o
Definition: geom.h:120
Vector::z
float z
Definition: geom.h:21