- Cal3D 0.11 API Reference -

matrix.h
1//****************************************************************************//
2// matrix.h //
3// Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger //
4//****************************************************************************//
5// This library is free software; you can redistribute it and/or modify it //
6// under the terms of the GNU Lesser General Public License as published by //
7// the Free Software Foundation; either version 2.1 of the License, or (at //
8// your option) any later version. //
9//****************************************************************************//
10
11#ifndef CAL_MATRIX_H
12#define CAL_MATRIX_H
13
14//****************************************************************************//
15// Includes //
16//****************************************************************************//
17
18#include "cal3d/global.h"
19
20//****************************************************************************//
21// Forward declarations //
22//****************************************************************************//
23
24 class CalQuaternion;
25
26//****************************************************************************//
27// Class declaration //
28//****************************************************************************//
29
30/*****************************************************************************/
33
34 class CAL3D_API CalMatrix
35{
36 // member variables
37 public:
38 float dxdx,dydx,dzdx;
39 float dxdy,dydy,dzdy;
40 float dxdz,dydz,dzdz;
41
42 // constructors/destructor
43 public:
44 inline CalMatrix() : dxdx(0.0), dydx(0.0), dzdx(0.0),
45 dxdy(0.0), dydy(0.0), dzdy(0.0),
46 dxdz(0.0), dydz(0.0), dzdz(0.0)
47 {
48 }
49
50 CalMatrix(const CalQuaternion &q);
51
52 inline CalMatrix(float weight, const CalMatrix &m)
53 {
54 dxdx = m.dxdx*weight;
55 dxdy = m.dxdy*weight;
56 dxdz = m.dxdz*weight;
57 dydx = m.dydx*weight;
58 dydy = m.dydy*weight;
59 dydz = m.dydz*weight;
60 dzdx = m.dzdx*weight;
61 dzdy = m.dzdy*weight;
62 dzdz = m.dzdz*weight;
63 }
64
65
66 inline ~CalMatrix() {};
67
68 // member functions
69 public:
70 void operator=(const CalQuaternion& q);
71
72 inline void operator=(const CalMatrix& m)
73 {
74 dxdx=m.dxdx; dxdy=m.dxdy; dxdz=m.dxdz;
75 dydx=m.dydx; dydy=m.dydy; dydz=m.dydz;
76 dzdx=m.dzdx; dzdy=m.dzdy; dzdz=m.dzdz;
77 }
78 inline void operator *= (const CalMatrix &m)
79 {
80 float ndxdx=m.dxdx*dxdx+m.dxdy*dydx+m.dxdz*dzdx;
81 float ndydx=m.dydx*dxdx+m.dydy*dydx+m.dydz*dzdx;
82 float ndzdx=m.dzdx*dxdx+m.dzdy*dydx+m.dzdz*dzdx;
83
84 float ndxdy=m.dxdx*dxdy+m.dxdy*dydy+m.dxdz*dzdy;
85 float ndydy=m.dydx*dxdy+m.dydy*dydy+m.dydz*dzdy;
86 float ndzdy=m.dzdx*dxdy+m.dzdy*dydy+m.dzdz*dzdy;
87
88 float ndxdz=m.dxdx*dxdz+m.dxdy*dydz+m.dxdz*dzdz;
89 float ndydz=m.dydx*dxdz+m.dydy*dydz+m.dydz*dzdz;
90 float ndzdz=m.dzdx*dxdz+m.dzdy*dydz+m.dzdz*dzdz;
91
92 dxdx=ndxdx;
93 dydx=ndydx;
94 dzdx=ndzdx;
95 dxdy=ndxdy;
96 dydy=ndydy;
97 dzdy=ndzdy;
98 dxdz=ndxdz;
99 dydz=ndydz;
100 dzdz=ndzdz;
101 }
102
103 inline void operator *= (float factor)
104 {
105 dxdx *= factor;
106 dydx *= factor;
107 dzdx *= factor;
108 dxdy *= factor;
109 dydy *= factor;
110 dzdy *= factor;
111 dxdz *= factor;
112 dydz *= factor;
113 dzdz *= factor;
114 }
115 inline void blend(float factor, const CalMatrix& m)
116 {
117 dxdx += m.dxdx*factor;
118 dydx += m.dydx*factor;
119 dzdx += m.dzdx*factor;
120 dxdy += m.dxdy*factor;
121 dydy += m.dydy*factor;
122 dzdy += m.dzdy*factor;
123 dxdz += m.dxdz*factor;
124 dydz += m.dydz*factor;
125 dzdz += m.dzdz*factor;
126 }
127
128 inline float det()
129 {
130 return dxdx * (dydy*dzdz-dydz*dzdy)
131 -dxdy* ( dydx*dzdz-dzdx*dydz)
132 +dxdz* (dydx*dzdy-dzdx*dydy);
133 }
134
135};
136
137
138#endif
139
140//****************************************************************************//
CalMatrix::operator=
void operator=(const CalQuaternion &q)
Quaternion to Matrix Conversion.
Definition matrix.cpp:76
CalQuaternion
The quaternion class.
Definition quaternion.h:36

Generated by The Cal3D Team with Doxygen 1.15.0