deVector3.h

Go to the documentation of this file.
00001 /* Copyright (c) 2005 Arachi, Inc. and Stanford University.
00002  *
00003  * Permission is hereby granted, free of charge, to any person obtaining
00004  * a copy of this software and associated documentation files (the
00005  * "Software"), to deal in the Software without restriction, including
00006  * without limitation the rights to use, copy, modify, merge, publish,
00007  * distribute, sublicense, and/or sell copies of the Software, and to
00008  * permit persons to whom the Software is furnished to do so, subject
00009  * to the following conditions:
00010  *
00011  * The above copyright notice and this permission notice shall be included
00012  * in all copies or substantial portions of the Software.
00013  *
00014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00015  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00016  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00017  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
00018  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00019  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00020  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00021  */
00022 
00023 #ifndef _deVector3_h
00024 #define _deVector3_h
00025 
00032 class deVector3
00033 {
00034 public:
00036         deFloat& operator[](const deInt i) { return _data[i]; }
00038         const deFloat& operator[](const deInt i) const { return _data[i]; }
00040         operator deFloat*() { return _data; }
00042         operator const deFloat*() const { return _data; }
00044         deFloat& elementAt(const deInt i) { return _data[i]; }
00046         const deFloat& elementAt(const deInt i) const { return _data[i]; }
00047 
00049         DE_MATH_API void operator=(const deVector3& v);
00051         DE_MATH_API deInt operator==(const deVector3& v) const;
00053         DE_MATH_API void operator+=(const deVector3& v);
00055         DE_MATH_API void operator-=(const deVector3& v);
00057         DE_MATH_API void operator*=(const deVector3& v);
00059         DE_MATH_API void operator*=(const deFloat s);
00061         DE_MATH_API void operator+=(const deFloat s);
00062 
00064         DE_MATH_API void zero();
00065 
00067         DE_MATH_API deFloat dot(const deVector3& v) const;
00069         DE_MATH_API deFloat magnitude() const;
00071         DE_MATH_API void normalize();
00073         DE_MATH_API void set(const deFloat x, const deFloat y, const deFloat z);
00075         DE_MATH_API void set(const deFloat* v);
00077         DE_MATH_API void get(deFloat* v);
00078 
00080         DE_MATH_API void minimum(const deVector3& v);
00082         DE_MATH_API void maximum(const deVector3& v);
00083 
00085         DE_MATH_API void negate(const deVector3& v);
00087         DE_MATH_API void add(const deVector3& v1, const deVector3& v2);
00089         DE_MATH_API void subtract(const deVector3& v1, const deVector3& v2);
00091         DE_MATH_API void multiply(const deVector3& v1, const deVector3& v2);
00093         DE_MATH_API void multiply(const deVector3& v, const deFloat s);
00095         DE_MATH_API void add(const deVector3& v, const deFloat s);
00097         DE_MATH_API void crossMultiply(const deVector3& v1, const deVector3& v2);
00099         DE_MATH_API void multiply(const deMatrix3& m, const deVector3& v);
00101         DE_MATH_API void transposedMultiply(const deMatrix3& m, const deVector3& v);
00103         DE_MATH_API void multiply(const deTransform& t, const deVector3& v);
00105         DE_MATH_API void inversedMultiply(const deTransform& t, const deVector3& v);
00107         DE_MATH_API void diagonal(const deMatrix3& m);
00109         DE_MATH_API void column(const deMatrix3& m, const deInt col);
00111         DE_MATH_API void angularError(const deMatrix3& R, const deMatrix3& Rd);
00113         DE_MATH_API void eulerXYZ(const deMatrix3& m);
00115         DE_MATH_API void eulerZYX(const deMatrix3& m);
00117         DE_MATH_API void eulerZYX(const deMatrix3& m, const deVector3& v);
00119         DE_MATH_API void eulerZYX(const deQuaternion& q);
00121         DE_MATH_API void backSub(const deMatrix3& LU, const deVector3& y);
00123         DE_MATH_API void multiply(const deQuaternion& q, const deVector3& v);
00125         DE_MATH_API void inversedMultiply(const deQuaternion& q, const deVector3& v);
00127         DE_MATH_API void column(const deQuaternion& q, const deInt col);
00128         // dPhi = Einv ( q - qd) = -2*q_tilde^T qd <-- since (q_tilde^T q) = 0
00129         // E = 0.5*q_tilde
00130         // Einv = (EtE)inv Et = 4Et = 2*qtilde^T <-- since (q_tilde^T q_tilde) = I
00131         // q_tilde = [ -x -y -z; w -z  y; z  w -x; -y  x  w ] 
00132         // q_tilde^T = [ -x  w  z -y; -y -z  w  x; -z  y -x  w ]               
00133         DE_MATH_API void angularError(const deQuaternion& q, const deQuaternion& qd);
00135         DE_MATH_API void multiply(const deFrame& f, const deVector3& v);
00137         DE_MATH_API void inversedMultiply(const deFrame& f, const deVector3& v);
00138 
00140         // this = v + t * (vg - v)
00141         DE_MATH_API void lerp(const deVector3& v, const deVector3& vg, const deFloat t);
00142 
00143 private:
00144         deFloat _data[DE_VECTOR3_SIZE];
00145 };
00146 
00147 #endif // _deVector3_h

Generated on Sun Apr 9 22:12:42 2006 for TAO by  doxygen 1.4.6-NO