Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

vecmath.h File Reference

#include <cmath>

Include dependency graph for vecmath.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define MATMUL(R, C)   (a[R].x * b[0].C + a[R].y * b[1].C + a[R].z * b[2].C + a[R].w * b[3].C)
#define MATMUL(R, C)   (a[R].x * b[0].C + a[R].y * b[1].C + a[R].z * b[2].C)

Typedefs

typedef Matrix3< double > Mat3d
typedef Matrix3< float > Mat3f
typedef Matrix4< double > Mat4d
typedef Matrix4< float > Mat4f
typedef Point2< float > Point2f
typedef Point3< double > Point3d
typedef Point3< float > Point3f
typedef Vector2< float > Vec2f
typedef Vector3< double > Vec3d
typedef Vector3< float > Vec3f
typedef Vector4< double > Vec4d
typedef Vector4< float > Vec4f

Functions

template<class T>
Vector3< T > cross (const Vector3< T > &a, const Vector3< T > &b)
template<class T>
det2x2 (T a, T b, T c, T d)
template<class T>
dot (const Vector4< T > &a, const Vector4< T > &b)
template<class T>
dot (const Vector3< T > &a, const Vector3< T > &b)
template<class T>
Matrix4< T > operator * (const Matrix4< T > &a, const Matrix4< T > &b)
template<class T>
Vector4< T > operator * (const Vector4< T > &v, const Matrix4< T > &m)
template<class T>
Vector4< T > operator * (const Matrix4< T > &m, const Vector4< T > &v)
template<class T>
Point3< T > operator * (const Point3< T > &p, const Matrix4< T > &m)
template<class T>
Point3< T > operator * (const Matrix4< T > &m, const Point3< T > &p)
template<class T>
Vector3< T > operator * (const Vector3< T > &v, const Matrix4< T > &m)
template<class T>
Vector3< T > operator * (const Matrix4< T > &m, const Vector3< T > &v)
template<class T>
Matrix3< T > operator * (const Matrix3< T > &a, const Matrix3< T > &b)
template<class T>
Point3< T > operator * (const Point3< T > &p, const Matrix3< T > &m)
template<class T>
Point3< T > operator * (const Matrix3< T > &m, const Point3< T > &p)
template<class T>
Vector3< T > operator * (const Vector3< T > &v, const Matrix3< T > &m)
template<class T>
Vector3< T > operator * (const Matrix3< T > &m, const Vector3< T > &v)
template<class T>
operator * (const Vector4< T > &a, const Vector4< T > &b)
template<class T>
Vector4< T > operator * (const Vector4< T > &v, T s)
template<class T>
Vector4< T > operator * (T s, const Vector4< T > &v)
template<class T>
Point3< T > operator * (T s, const Point3< T > &p)
template<class T>
Point3< T > operator * (const Point3< T > &p, T s)
template<class T>
operator * (const Vector3< T > &a, const Vector3< T > &b)
template<class T>
Vector3< T > operator * (const Vector3< T > &v, T s)
template<class T>
Vector3< T > operator * (T s, const Vector3< T > &v)
template<class T>
bool operator!= (const Vector4< T > &a, const Vector4< T > &b)
template<class T>
bool operator!= (const Point2< T > &a, const Point2< T > &b)
template<class T>
bool operator!= (const Vector2< T > &a, const Vector2< T > &b)
template<class T>
bool operator!= (const Point3< T > &a, const Point3< T > &b)
template<class T>
bool operator!= (const Vector3< T > &a, const Vector3< T > &b)
template<class T>
Matrix4< T > operator+ (const Matrix4< T > &a, const Matrix4< T > &b)
template<class T>
Matrix3< T > operator+ (const Matrix3< T > &a, const Matrix3< T > &b)
template<class T>
Vector4< T > operator+ (const Vector4< T > &a, const Vector4< T > &b)
template<class T>
Point3< T > operator+ (const Point3< T > &p, const Vector3< T > &v)
template<class T>
Vector3< T > operator+ (const Vector3< T > &a, const Vector3< T > &b)
template<class T>
Vector4< T > operator- (const Vector4< T > &a, const Vector4< T > &b)
template<class T>
Point3< T > operator- (const Point3< T > &p, const Vector3< T > &v)
template<class T>
Vector3< T > operator- (const Point3< T > &a, const Point3< T > &b)
template<class T>
Vector3< T > operator- (const Vector3< T > &a, const Vector3< T > &b)
template<class T>
Vector3< T > operator/ (const Vector3< T > &v, T s)
template<class T>
bool operator== (const Vector4< T > &a, const Vector4< T > &b)
template<class T>
bool operator== (const Point2< T > &a, const Point2< T > &b)
template<class T>
bool operator== (const Vector2< T > &a, const Vector2< T > &b)
template<class T>
bool operator== (const Point3< T > &a, const Point3< T > &b)
template<class T>
bool operator== (const Vector3< T > &a, const Vector3< T > &b)
template<class T>
Vector3< T > operator^ (const Vector3< T > &a, const Vector3< T > &b)


Define Documentation

#define MATMUL R,
 )     (a[R].x * b[0].C + a[R].y * b[1].C + a[R].z * b[2].C + a[R].w * b[3].C)
 

#define MATMUL R,
 )     (a[R].x * b[0].C + a[R].y * b[1].C + a[R].z * b[2].C)
 

Referenced by operator *().


Typedef Documentation

typedef Matrix3<double> Mat3d
 

Definition at line 178 of file vecmath.h.

typedef Matrix3<float> Mat3f
 

Definition at line 177 of file vecmath.h.

typedef Matrix4<double> Mat4d
 

Definition at line 176 of file vecmath.h.

typedef Matrix4<float> Mat4f
 

Definition at line 175 of file vecmath.h.

typedef Point2<float> Point2f
 

Definition at line 172 of file vecmath.h.

typedef Point3<double> Point3d
 

Definition at line 170 of file vecmath.h.

typedef Point3<float> Point3f
 

Definition at line 169 of file vecmath.h.

typedef Vector2<float> Vec2f
 

Definition at line 171 of file vecmath.h.

typedef Vector3<double> Vec3d
 

Definition at line 168 of file vecmath.h.

typedef Vector3<float> Vec3f
 

Definition at line 167 of file vecmath.h.

typedef Vector4<double> Vec4d
 

Definition at line 174 of file vecmath.h.

typedef Vector4<float> Vec4f
 

Definition at line 173 of file vecmath.h.


Function Documentation

template<class T>
Vector3<T> cross const Vector3< T > &  a,
const Vector3< T > &  b
 

Definition at line 293 of file vecmath.h.

Referenced by Convert3DSMesh(), ConvertToVertexList(), convertToVertexList(), generateNormals(), SphereMesh::generateNormals(), and Plane< T >::intersection().

00294 {
00295     return Vector3<T>(a.y * b.z - a.z * b.y,
00296                       a.z * b.x - a.x * b.z,
00297                       a.x * b.y - a.y * b.x);
00298 }

template<class T>
T det2x2 a,
b,
c,
d
 

Definition at line 705 of file vecmath.h.

Referenced by Matrix3< T >::inverse().

00706 {
00707     return a * d - b * c;
00708 }

template<class T>
T dot const Vector4< T > &  a,
const Vector4< T > &  b
 

Definition at line 564 of file vecmath.h.

00565 {
00566     return a * b;
00567 }

template<class T>
T dot const Vector3< T > &  a,
const Vector3< T > &  b
 

Definition at line 288 of file vecmath.h.

References Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

00289 {
00290     return a.x * b.x + a.y * b.y + a.z * b.z;
00291 }

template<class T>
Matrix4<T> operator * const Matrix4< T > &  a,
const Matrix4< T > &  b
 

Definition at line 1011 of file vecmath.h.

References MATMUL.

01013 {
01014 #define MATMUL(R, C) (a[R].x * b[0].C + a[R].y * b[1].C + a[R].z * b[2].C + a[R].w * b[3].C)
01015     return Matrix4<T>(Vector4<T>(MATMUL(0, x), MATMUL(0, y), MATMUL(0, z), MATMUL(0, w)),
01016                       Vector4<T>(MATMUL(1, x), MATMUL(1, y), MATMUL(1, z), MATMUL(1, w)),
01017                       Vector4<T>(MATMUL(2, x), MATMUL(2, y), MATMUL(2, z), MATMUL(2, w)),
01018                       Vector4<T>(MATMUL(3, x), MATMUL(3, y), MATMUL(3, z), MATMUL(3, w)));
01019 #undef MATMUL
01020 }

template<class T>
Vector4<T> operator * const Vector4< T > &  v,
const Matrix4< T > &  m
 

Definition at line 992 of file vecmath.h.

00993 {
00994     return Vector4<T>(m.r[0].x * v.x + m.r[1].x * v.y + m.r[2].x * v.z + m.r[3].x * v.w,
00995                       m.r[0].y * v.x + m.r[1].y * v.y + m.r[2].y * v.z + m.r[3].y * v.w,
00996                       m.r[0].z * v.x + m.r[1].z * v.y + m.r[2].z * v.z + m.r[3].z * v.w,
00997                       m.r[0].w * v.x + m.r[1].w * v.y + m.r[2].w * v.z + m.r[3].w * v.w);
00998 }

template<class T>
Vector4<T> operator * const Matrix4< T > &  m,
const Vector4< T > &  v
 

Definition at line 983 of file vecmath.h.

00984 {
00985     return Vector4<T>(m.r[0].x * v.x + m.r[0].y * v.y + m.r[0].z * v.z + m.r[0].w * v.w,
00986                       m.r[1].x * v.x + m.r[1].y * v.y + m.r[1].z * v.z + m.r[1].w * v.w,
00987                       m.r[2].x * v.x + m.r[2].y * v.y + m.r[2].z * v.z + m.r[2].w * v.w,
00988                       m.r[3].x * v.x + m.r[3].y * v.y + m.r[3].z * v.z + m.r[3].w * v.w);
00989 }

template<class T>
Point3<T> operator * const Point3< T > &  p,
const Matrix4< T > &  m
 

Definition at line 975 of file vecmath.h.

00976 {
00977     return Point3<T>(m.r[0].x * p.x + m.r[1].x * p.y + m.r[2].x * p.z + m.r[3].x,
00978                      m.r[0].y * p.x + m.r[1].y * p.y + m.r[2].y * p.z + m.r[3].y,
00979                      m.r[0].z * p.x + m.r[1].z * p.y + m.r[2].z * p.z + m.r[3].z);
00980 }

template<class T>
Point3<T> operator * const Matrix4< T > &  m,
const Point3< T > &  p
 

Definition at line 967 of file vecmath.h.

00968 {
00969     return Point3<T>(m.r[0].x * p.x + m.r[0].y * p.y + m.r[0].z * p.z + m.r[0].w,
00970                      m.r[1].x * p.x + m.r[1].y * p.y + m.r[1].z * p.z + m.r[1].w,
00971                      m.r[2].x * p.x + m.r[2].y * p.y + m.r[2].z * p.z + m.r[2].w);
00972 }

template<class T>
Vector3<T> operator * const Vector3< T > &  v,
const Matrix4< T > &  m
 

Definition at line 959 of file vecmath.h.

00960 {
00961     return Vector3<T>(m.r[0].x * v.x + m.r[1].x * v.y + m.r[2].x * v.z,
00962                       m.r[0].y * v.x + m.r[1].y * v.y + m.r[2].y * v.z,
00963                       m.r[0].z * v.x + m.r[1].z * v.y + m.r[2].z * v.z);
00964 }

template<class T>
Vector3<T> operator * const Matrix4< T > &  m,
const Vector3< T > &  v
 

Definition at line 951 of file vecmath.h.

00952 {
00953     return Vector3<T>(m.r[0].x * v.x + m.r[0].y * v.y + m.r[0].z * v.z,
00954                       m.r[1].x * v.x + m.r[1].y * v.y + m.r[1].z * v.z,
00955                       m.r[2].x * v.x + m.r[2].y * v.y + m.r[2].z * v.z);
00956 }

template<class T>
Matrix3<T> operator * const Matrix3< T > &  a,
const Matrix3< T > &  b
 

Definition at line 669 of file vecmath.h.

References MATMUL.

00671 {
00672 #define MATMUL(R, C) (a[R].x * b[0].C + a[R].y * b[1].C + a[R].z * b[2].C)
00673     return Matrix3<T>(Vector3<T>(MATMUL(0, x), MATMUL(0, y), MATMUL(0, z)),
00674                       Vector3<T>(MATMUL(1, x), MATMUL(1, y), MATMUL(1, z)),
00675                       Vector3<T>(MATMUL(2, x), MATMUL(2, y), MATMUL(2, z)));
00676 #undef MATMUL
00677 }

template<class T>
Point3<T> operator * const Point3< T > &  p,
const Matrix3< T > &  m
 

Definition at line 661 of file vecmath.h.

00662 {
00663     return Point3<T>(m.r[0].x * p.x + m.r[1].x * p.y + m.r[2].x * p.z,
00664                      m.r[0].y * p.x + m.r[1].y * p.y + m.r[2].y * p.z,
00665                      m.r[0].z * p.x + m.r[1].z * p.y + m.r[2].z * p.z);
00666 }

template<class T>
Point3<T> operator * const Matrix3< T > &  m,
const Point3< T > &  p
 

Definition at line 652 of file vecmath.h.

00653 {
00654     return Point3<T>(m.r[0].x * p.x + m.r[0].y * p.y + m.r[0].z * p.z,
00655                      m.r[1].x * p.x + m.r[1].y * p.y + m.r[1].z * p.z,
00656                      m.r[2].x * p.x + m.r[2].y * p.y + m.r[2].z * p.z);
00657 }

template<class T>
Vector3<T> operator * const Vector3< T > &  v,
const Matrix3< T > &  m
 

Definition at line 643 of file vecmath.h.

00644 {
00645     return Vector3<T>(m.r[0].x * v.x + m.r[1].x * v.y + m.r[2].x * v.z,
00646                       m.r[0].y * v.x + m.r[1].y * v.y + m.r[2].y * v.z,
00647                       m.r[0].z * v.x + m.r[1].z * v.y + m.r[2].z * v.z);
00648 }

template<class T>
Vector3<T> operator * const Matrix3< T > &  m,
const Vector3< T > &  v
 

Definition at line 634 of file vecmath.h.

00635 {
00636     return Vector3<T>(m.r[0].x * v.x + m.r[0].y * v.y + m.r[0].z * v.z,
00637                       m.r[1].x * v.x + m.r[1].y * v.y + m.r[1].z * v.z,
00638                       m.r[2].x * v.x + m.r[2].y * v.y + m.r[2].z * v.z);
00639 }

template<class T>
T operator * const Vector4< T > &  a,
const Vector4< T > &  b
 

Definition at line 559 of file vecmath.h.

References Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

00560 {
00561     return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
00562 }

template<class T>
Vector4<T> operator * const Vector4< T > &  v,
s
 

Definition at line 553 of file vecmath.h.

00554 {
00555     return Vector4<T>(s * v.x, s * v.y, s * v.z, s * v.w);
00556 }

template<class T>
Vector4<T> operator * s,
const Vector4< T > &  v
 

Definition at line 548 of file vecmath.h.

00549 {
00550     return Vector4<T>(s * v.x, s * v.y, s * v.z, s * v.w);
00551 }

template<class T>
Point3<T> operator * s,
const Point3< T > &  p
 

Definition at line 399 of file vecmath.h.

00400 {
00401     return Point3<T>(p.x * s, p.y * s, p.z * s);
00402 }

template<class T>
Point3<T> operator * const Point3< T > &  p,
s
 

Definition at line 394 of file vecmath.h.

00395 {
00396     return Point3<T>(p.x * s, p.y * s, p.z * s);
00397 }

template<class T>
T operator * const Vector3< T > &  a,
const Vector3< T > &  b
 

Definition at line 259 of file vecmath.h.

References Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

00260 {
00261     return a.x * b.x + a.y * b.y + a.z * b.z;
00262 }

template<class T>
Vector3<T> operator * const Vector3< T > &  v,
s
 

Definition at line 253 of file vecmath.h.

00254 {
00255     return Vector3<T>(s * v.x, s * v.y, s * v.z);
00256 }

template<class T>
Vector3<T> operator * s,
const Vector3< T > &  v
 

Definition at line 248 of file vecmath.h.

00249 {
00250     return Vector3<T>(s * v.x, s * v.y, s * v.z);
00251 }

template<class T>
bool operator!= const Vector4< T > &  a,
const Vector4< T > &  b
 

Definition at line 505 of file vecmath.h.

References Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

00506 {
00507     return a.x != b.x || a.y != b.y || a.z != b.z || a.w != b.w;
00508 }

template<class T>
bool operator!= const Point2< T > &  a,
const Point2< T > &  b
 

Definition at line 473 of file vecmath.h.

References Vector3< T >::x, and Vector3< T >::y.

00474 {
00475     return a.x != b.x || a.y != b.y;
00476 }

template<class T>
bool operator!= const Vector2< T > &  a,
const Vector2< T > &  b
 

Definition at line 449 of file vecmath.h.

References Vector3< T >::x, and Vector3< T >::y.

00450 {
00451     return a.x != b.x || a.y != b.y;
00452 }

template<class T>
bool operator!= const Point3< T > &  a,
const Point3< T > &  b
 

Definition at line 376 of file vecmath.h.

References Point3< T >::x, Point3< T >::y, and Point3< T >::z.

00377 {
00378     return a.x != b.x || a.y != b.y || a.z != b.z;
00379 }

template<class T>
bool operator!= const Vector3< T > &  a,
const Vector3< T > &  b
 

Definition at line 277 of file vecmath.h.

References Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

00278 {
00279     return a.x != b.x || a.y != b.y || a.z != b.z;
00280 }

template<class T>
Matrix4<T> operator+ const Matrix4< T > &  a,
const Matrix4< T > &  b
 

Definition at line 1023 of file vecmath.h.

01024 {
01025     return Matrix4<T>(a[0] + b[0], a[1] + b[1], a[2] + b[2], a[3] + b[3]);
01026 }

template<class T>
Matrix3<T> operator+ const Matrix3< T > &  a,
const Matrix3< T > &  b
 

Definition at line 680 of file vecmath.h.

00682 {
00683     return Matrix3<T>(a.r[0] + b.r[0],
00684                       a.r[1] + b.r[1],
00685                       a.r[2] + b.r[2]);
00686 }

template<class T>
Vector4<T> operator+ const Vector4< T > &  a,
const Vector4< T > &  b
 

Definition at line 538 of file vecmath.h.

00539 {
00540     return Vector4<T>(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
00541 }

template<class T>
Point3<T> operator+ const Point3< T > &  p,
const Vector3< T > &  v
 

Definition at line 381 of file vecmath.h.

00382 {
00383     return Point3<T>(p.x + v.x, p.y + v.y, p.z + v.z);
00384 }

template<class T>
Vector3<T> operator+ const Vector3< T > &  a,
const Vector3< T > &  b
 

Definition at line 238 of file vecmath.h.

00239 {
00240     return Vector3<T>(a.x + b.x, a.y + b.y, a.z + b.z);
00241 }

template<class T>
Vector4<T> operator- const Vector4< T > &  a,
const Vector4< T > &  b
 

Definition at line 543 of file vecmath.h.

00544 {
00545     return Vector4<T>(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
00546 }

template<class T>
Point3<T> operator- const Point3< T > &  p,
const Vector3< T > &  v
 

Definition at line 386 of file vecmath.h.

00387 {
00388     return Point3<T>(p.x - v.x, p.y - v.y, p.z - v.z);
00389 }

template<class T>
Vector3<T> operator- const Point3< T > &  a,
const Point3< T > &  b
 

Definition at line 348 of file vecmath.h.

00349 {
00350     return Vector3<T>(a.x - b.x, a.y - b.y, a.z - b.z);
00351 }

template<class T>
Vector3<T> operator- const Vector3< T > &  a,
const Vector3< T > &  b
 

Definition at line 243 of file vecmath.h.

00244 {
00245     return Vector3<T>(a.x - b.x, a.y - b.y, a.z - b.z);
00246 }

template<class T>
Vector3<T> operator/ const Vector3< T > &  v,
s
 

Definition at line 282 of file vecmath.h.

00283 {
00284     T is = 1 / s;
00285     return Vector3<T>(is * v.x, is * v.y, is * v.z);
00286 }

template<class T>
bool operator== const Vector4< T > &  a,
const Vector4< T > &  b
 

Definition at line 500 of file vecmath.h.

References Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

00501 {
00502     return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
00503 }

template<class T>
bool operator== const Point2< T > &  a,
const Point2< T > &  b
 

Definition at line 468 of file vecmath.h.

References Vector3< T >::x, and Vector3< T >::y.

00469 {
00470     return a.x == b.x && a.y == b.y;
00471 }

template<class T>
bool operator== const Vector2< T > &  a,
const Vector2< T > &  b
 

Definition at line 444 of file vecmath.h.

References Vector3< T >::x, and Vector3< T >::y.

00445 {
00446     return a.x == b.x && a.y == b.y;
00447 }

template<class T>
bool operator== const Point3< T > &  a,
const Point3< T > &  b
 

Definition at line 371 of file vecmath.h.

References Point3< T >::x, Point3< T >::y, and Point3< T >::z.

00372 {
00373     return a.x == b.x && a.y == b.y && a.z == b.z;
00374 }

template<class T>
bool operator== const Vector3< T > &  a,
const Vector3< T > &  b
 

Definition at line 272 of file vecmath.h.

References Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

00273 {
00274     return a.x == b.x && a.y == b.y && a.z == b.z;
00275 }

template<class T>
Vector3<T> operator^ const Vector3< T > &  a,
const Vector3< T > &  b
 

Definition at line 265 of file vecmath.h.

00266 {
00267     return Vector3<T>(a.y * b.z - a.z * b.y,
00268                       a.z * b.x - a.x * b.z,
00269                       a.x * b.y - a.y * b.x);
00270 }


Generated on Sat Jan 14 22:32:52 2006 for Celestia by  doxygen 1.4.1