Blender V2.61 - r43446

MT_Vector3.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00033 /*
00034 
00035  * Copyright (c) 2000 Gino van den Bergen <gino@acm.org>
00036  *
00037  * Permission to use, copy, modify, distribute and sell this software
00038  * and its documentation for any purpose is hereby granted without fee,
00039  * provided that the above copyright notice appear in all copies and
00040  * that both that copyright notice and this permission notice appear
00041  * in supporting documentation.  Gino van den Bergen makes no
00042  * representations about the suitability of this software for any
00043  * purpose.  It is provided "as is" without express or implied warranty.
00044  *
00045  */
00046 
00047 #ifndef MT_VECTOR3_H
00048 #define MT_VECTOR3_H
00049 
00050 #include <MT_assert.h>
00051 #include "MT_Tuple3.h"
00052 
00053 class MT_Vector3 : public MT_Tuple3 {
00054 public:
00055     virtual ~MT_Vector3() {}
00056     MT_Vector3() {}
00057     MT_Vector3(const float *v) : MT_Tuple3(v) {}
00058     MT_Vector3(const double *v) : MT_Tuple3(v) {}
00059     MT_Vector3(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz) : MT_Tuple3(xx, yy, zz) {}
00060   
00061     MT_Vector3& operator+=(const MT_Vector3& v);
00062     MT_Vector3& operator-=(const MT_Vector3& v);
00063     MT_Vector3& operator*=(MT_Scalar s);
00064     MT_Vector3& operator/=(MT_Scalar s);
00065   
00066     MT_Scalar   dot(const MT_Vector3& v) const; 
00067 
00068     MT_Scalar   length2() const;
00069     MT_Scalar   length() const;
00070 
00071     MT_Vector3  absolute() const;
00072 
00073     void        noiseGate(MT_Scalar threshold);
00074 
00075     void        normalize();
00076     MT_Vector3  normalized() const;
00077     MT_Vector3  safe_normalized() const;
00078     
00079 
00080     void        scale(MT_Scalar x, MT_Scalar y, MT_Scalar z); 
00081     MT_Vector3  scaled(MT_Scalar x, MT_Scalar y, MT_Scalar z) const; 
00082     
00083     bool        fuzzyZero() const; 
00084 
00085     MT_Scalar   angle(const MT_Vector3& v) const;
00086     MT_Vector3  cross(const MT_Vector3& v) const;
00087     MT_Scalar   triple(const MT_Vector3& v1, const MT_Vector3& v2) const;
00088 
00089     int         closestAxis() const;
00090 
00091     static MT_Vector3 random();
00092 };
00093 
00094 MT_Vector3 operator+(const MT_Vector3& v1, const MT_Vector3& v2);
00095 MT_Vector3 operator-(const MT_Vector3& v1, const MT_Vector3& v2);
00096 MT_Vector3 operator-(const MT_Vector3& v);
00097 MT_Vector3 operator*(const MT_Vector3& v, MT_Scalar s);
00098 MT_Vector3 operator*(MT_Scalar s, const MT_Vector3& v);
00099 MT_Vector3 operator/(const MT_Vector3& v, MT_Scalar s);
00100 
00101 MT_Vector3 operator*(const MT_Vector3& v1, const MT_Vector3& v2);
00102 
00103 MT_Scalar  MT_dot(const MT_Vector3& v1, const MT_Vector3& v2);
00104 
00105 MT_Scalar  MT_length2(const MT_Vector3& v);
00106 MT_Scalar  MT_length(const MT_Vector3& v);
00107 
00108 bool       MT_fuzzyZero(const MT_Vector3& v);
00109 bool       MT_fuzzyEqual(const MT_Vector3& v1, const MT_Vector3& v2);
00110 
00111 MT_Scalar  MT_angle(const MT_Vector3& v1, const MT_Vector3& v2);
00112 MT_Vector3 MT_cross(const MT_Vector3& v1, const MT_Vector3& v2);
00113 MT_Scalar  MT_triple(const MT_Vector3& v1, const MT_Vector3& v2, 
00114                      const MT_Vector3& v3);
00115 
00116 #ifdef GEN_INLINED
00117 #include "MT_Vector3.inl"
00118 #endif
00119 
00120 #endif
00121