Blender V2.61 - r43446
|
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_VECTOR2_H 00048 #define MT_VECTOR2_H 00049 00050 #include <MT_assert.h> 00051 #include "MT_Tuple2.h" 00052 00053 class MT_Vector2 : public MT_Tuple2 { 00054 public: 00055 MT_Vector2() {} 00056 MT_Vector2(const float *v2) : MT_Tuple2(v2) {} 00057 MT_Vector2(const double *v2) : MT_Tuple2(v2) {} 00058 MT_Vector2(MT_Scalar xx, MT_Scalar yy) : MT_Tuple2(xx, yy) {} 00059 00060 MT_Vector2& operator+=(const MT_Vector2& v); 00061 MT_Vector2& operator-=(const MT_Vector2& v); 00062 MT_Vector2& operator*=(MT_Scalar s); 00063 MT_Vector2& operator/=(MT_Scalar s); 00064 00065 MT_Scalar dot(const MT_Vector2& v) const; 00066 00067 MT_Scalar length2() const; 00068 MT_Scalar length() const; 00069 00070 MT_Vector2 absolute() const; 00071 00072 void normalize(); 00073 MT_Vector2 normalized() const; 00074 00075 void scale(MT_Scalar x, MT_Scalar y); 00076 MT_Vector2 scaled(MT_Scalar x, MT_Scalar y) const; 00077 00078 bool fuzzyZero() const; 00079 00080 MT_Scalar angle(const MT_Vector2& v) const; 00081 MT_Vector2 cross(const MT_Vector2& v) const; 00082 MT_Scalar triple(const MT_Vector2& v1, const MT_Vector2& v2) const; 00083 00084 int closestAxis() const; 00085 00086 static MT_Vector2 random(); 00087 }; 00088 00089 MT_Vector2 operator+(const MT_Vector2& v1, const MT_Vector2& v2); 00090 MT_Vector2 operator-(const MT_Vector2& v1, const MT_Vector2& v2); 00091 MT_Vector2 operator-(const MT_Vector2& v); 00092 MT_Vector2 operator*(const MT_Vector2& v, MT_Scalar s); 00093 MT_Vector2 operator*(MT_Scalar s, const MT_Vector2& v); 00094 MT_Vector2 operator/(const MT_Vector2& v, MT_Scalar s); 00095 00096 MT_Scalar MT_dot(const MT_Vector2& v1, const MT_Vector2& v2); 00097 00098 MT_Scalar MT_length2(const MT_Vector2& v); 00099 MT_Scalar MT_length(const MT_Vector2& v); 00100 00101 bool MT_fuzzyZero(const MT_Vector2& v); 00102 bool MT_fuzzyEqual(const MT_Vector2& v1, const MT_Vector2& v2); 00103 00104 MT_Scalar MT_angle(const MT_Vector2& v1, const MT_Vector2& v2); 00105 MT_Vector2 MT_cross(const MT_Vector2& v1, const MT_Vector2& v2); 00106 MT_Scalar MT_triple(const MT_Vector2& v1, const MT_Vector2& v2, 00107 const MT_Vector2& v3); 00108 00109 #ifdef GEN_INLINED 00110 #include "MT_Vector2.inl" 00111 #endif 00112 00113 #endif 00114