1 | <html> |
---|
2 | <head> |
---|
3 | <title>OgreVector3.h Source File - OGRE Documentation</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
4 | <link type="text/css" rel="stylesheet" href="style.css"> |
---|
5 | </head> |
---|
6 | |
---|
7 | <body> |
---|
8 | <!-- Generated by Doxygen 1.3.6 --> |
---|
9 | <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a> | <a class="qindex" href="pages.html">Related Pages</a></div> |
---|
10 | <h1>OgreVector3.h</h1><a href="OgreVector3_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/*</span> |
---|
11 | 00002 <span class="comment">-----------------------------------------------------------------------------</span> |
---|
12 | 00003 <span class="comment">This source file is part of OGRE</span> |
---|
13 | 00004 <span class="comment"> (Object-oriented Graphics Rendering Engine)</span> |
---|
14 | 00005 <span class="comment">For the latest info, see http://www.ogre3d.org/</span> |
---|
15 | 00006 <span class="comment"></span> |
---|
16 | 00007 <span class="comment">Copyright (c) 2000-2005 The OGRE Team</span> |
---|
17 | 00008 <span class="comment">Also see acknowledgements in Readme.html</span> |
---|
18 | 00009 <span class="comment"></span> |
---|
19 | 00010 <span class="comment">This program is free software; you can redistribute it and/or modify it under</span> |
---|
20 | 00011 <span class="comment">the terms of the GNU Lesser General Public License as published by the Free Software</span> |
---|
21 | 00012 <span class="comment">Foundation; either version 2 of the License, or (at your option) any later</span> |
---|
22 | 00013 <span class="comment">version.</span> |
---|
23 | 00014 <span class="comment"></span> |
---|
24 | 00015 <span class="comment">This program is distributed in the hope that it will be useful, but WITHOUT</span> |
---|
25 | 00016 <span class="comment">ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS</span> |
---|
26 | 00017 <span class="comment">FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.</span> |
---|
27 | 00018 <span class="comment"></span> |
---|
28 | 00019 <span class="comment">You should have received a copy of the GNU Lesser General Public License along with</span> |
---|
29 | 00020 <span class="comment">this program; if not, write to the Free Software Foundation, Inc., 59 Temple</span> |
---|
30 | 00021 <span class="comment">Place - Suite 330, Boston, MA 02111-1307, USA, or go to</span> |
---|
31 | 00022 <span class="comment">http://www.gnu.org/copyleft/lesser.txt.</span> |
---|
32 | 00023 <span class="comment">-----------------------------------------------------------------------------</span> |
---|
33 | 00024 <span class="comment">*/</span> |
---|
34 | 00025 <span class="preprocessor">#ifndef __Vector3_H__</span> |
---|
35 | 00026 <span class="preprocessor"></span><span class="preprocessor">#define __Vector3_H__</span> |
---|
36 | 00027 <span class="preprocessor"></span> |
---|
37 | 00028 <span class="preprocessor">#include "<a class="code" href="OgrePrerequisites_8h.html">OgrePrerequisites.h</a>"</span> |
---|
38 | 00029 <span class="preprocessor">#include "<a class="code" href="OgreMath_8h.html">OgreMath.h</a>"</span> |
---|
39 | 00030 <span class="preprocessor">#include "<a class="code" href="OgreQuaternion_8h.html">OgreQuaternion.h</a>"</span> |
---|
40 | 00031 |
---|
41 | 00032 <span class="keyword">namespace </span>Ogre |
---|
42 | 00033 { |
---|
43 | 00034 |
---|
44 | <a name="l00042"></a><a class="code" href="classOgre_1_1Vector3.html">00042</a> <span class="keyword">class </span><a class="code" href="OgrePlatform_8h.html#a16">_OgreExport</a> Vector3 |
---|
45 | 00043 { |
---|
46 | 00044 <span class="keyword">public</span>: |
---|
47 | 00045 <span class="keyword">union </span>{ |
---|
48 | 00046 <span class="keyword">struct </span>{ |
---|
49 | <a name="l00047"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">00047</a> <a class="code" href="namespaceOgre.html#a420">Real</a> x, y, z; |
---|
50 | 00048 }; |
---|
51 | <a name="l00049"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o3">00049</a> <a class="code" href="namespaceOgre.html#a420">Real</a> val[3]; |
---|
52 | 00050 }; |
---|
53 | 00051 |
---|
54 | 00052 <span class="keyword">public</span>: |
---|
55 | <a name="l00053"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a0">00053</a> <span class="keyword">inline</span> Vector3() |
---|
56 | 00054 { |
---|
57 | 00055 } |
---|
58 | 00056 |
---|
59 | <a name="l00057"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a1">00057</a> <span class="keyword">inline</span> Vector3( <a class="code" href="namespaceOgre.html#a420">Real</a> fX, <a class="code" href="namespaceOgre.html#a420">Real</a> fY, <a class="code" href="namespaceOgre.html#a420">Real</a> fZ ) |
---|
60 | 00058 : x( fX ), y( fY ), z( fZ ) |
---|
61 | 00059 { |
---|
62 | 00060 } |
---|
63 | 00061 |
---|
64 | <a name="l00062"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a2">00062</a> <span class="keyword">inline</span> Vector3( <a class="code" href="namespaceOgre.html#a420">Real</a> afCoordinate[3] ) |
---|
65 | 00063 : x( afCoordinate[0] ), |
---|
66 | 00064 y( afCoordinate[1] ), |
---|
67 | 00065 z( afCoordinate[2] ) |
---|
68 | 00066 { |
---|
69 | 00067 } |
---|
70 | 00068 |
---|
71 | <a name="l00069"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a3">00069</a> <span class="keyword">inline</span> Vector3( <span class="keywordtype">int</span> afCoordinate[3] ) |
---|
72 | 00070 { |
---|
73 | 00071 x = (<a class="code" href="namespaceOgre.html#a420">Real</a>)afCoordinate[0]; |
---|
74 | 00072 y = (<a class="code" href="namespaceOgre.html#a420">Real</a>)afCoordinate[1]; |
---|
75 | 00073 z = (<a class="code" href="namespaceOgre.html#a420">Real</a>)afCoordinate[2]; |
---|
76 | 00074 } |
---|
77 | 00075 |
---|
78 | <a name="l00076"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a4">00076</a> <span class="keyword">inline</span> Vector3( <span class="keyword">const</span> <a class="code" href="namespaceOgre.html#a420">Real</a>* <span class="keyword">const</span> r ) |
---|
79 | 00077 : x( r[0] ), y( r[1] ), z( r[2] ) |
---|
80 | 00078 { |
---|
81 | 00079 } |
---|
82 | 00080 |
---|
83 | <a name="l00081"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a5">00081</a> <span class="keyword">inline</span> Vector3( <span class="keyword">const</span> Vector3& rkVector ) |
---|
84 | 00082 : x( rkVector.x ), y( rkVector.y ), z( rkVector.z ) |
---|
85 | 00083 { |
---|
86 | 00084 } |
---|
87 | 00085 |
---|
88 | <a name="l00086"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a6">00086</a> <span class="keyword">inline</span> <a class="code" href="namespaceOgre.html#a420">Real</a> operator [] ( size_t i )<span class="keyword"> const</span> |
---|
89 | 00087 <span class="keyword"> </span>{ |
---|
90 | 00088 assert( i < 3 ); |
---|
91 | 00089 |
---|
92 | 00090 <span class="keywordflow">return</span> *(&x+i); |
---|
93 | 00091 } |
---|
94 | 00092 |
---|
95 | <a name="l00093"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a7">00093</a> <span class="keyword">inline</span> <a class="code" href="namespaceOgre.html#a420">Real</a>& operator [] ( size_t i ) |
---|
96 | 00094 { |
---|
97 | 00095 assert( i < 3 ); |
---|
98 | 00096 |
---|
99 | 00097 <span class="keywordflow">return</span> *(&x+i); |
---|
100 | 00098 } |
---|
101 | 00099 |
---|
102 | <a name="l00104"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a8">00104</a> <span class="keyword">inline</span> Vector3& operator = ( <span class="keyword">const</span> Vector3& rkVector ) |
---|
103 | 00105 { |
---|
104 | 00106 x = rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>; |
---|
105 | 00107 y = rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>; |
---|
106 | 00108 z = rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>; |
---|
107 | 00109 |
---|
108 | 00110 <span class="keywordflow">return</span> *<span class="keyword">this</span>; |
---|
109 | 00111 } |
---|
110 | 00112 |
---|
111 | <a name="l00113"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a9">00113</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="namespaceOgre.html#a618">operator == </a>( <span class="keyword">const</span> Vector3& rkVector )<span class="keyword"> const</span> |
---|
112 | 00114 <span class="keyword"> </span>{ |
---|
113 | 00115 <span class="keywordflow">return</span> ( x == rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> && y == rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> && z == rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> ); |
---|
114 | 00116 } |
---|
115 | 00117 |
---|
116 | <a name="l00118"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a10">00118</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="namespaceOgre.html#a619">operator != </a>( <span class="keyword">const</span> Vector3& rkVector )<span class="keyword"> const</span> |
---|
117 | 00119 <span class="keyword"> </span>{ |
---|
118 | 00120 <span class="keywordflow">return</span> ( x != rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> || y != rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> || z != rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> ); |
---|
119 | 00121 } |
---|
120 | 00122 |
---|
121 | 00123 <span class="comment">// arithmetic operations</span> |
---|
122 | <a name="l00124"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a11">00124</a> <span class="keyword">inline</span> Vector3 operator + ( <span class="keyword">const</span> Vector3& rkVector )<span class="keyword"> const</span> |
---|
123 | 00125 <span class="keyword"> </span>{ |
---|
124 | 00126 Vector3 kSum; |
---|
125 | 00127 |
---|
126 | 00128 kSum.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> = x + rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>; |
---|
127 | 00129 kSum.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> = y + rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>; |
---|
128 | 00130 kSum.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> = z + rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>; |
---|
129 | 00131 |
---|
130 | 00132 <span class="keywordflow">return</span> kSum; |
---|
131 | 00133 } |
---|
132 | 00134 |
---|
133 | <a name="l00135"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a12">00135</a> <span class="keyword">inline</span> Vector3 operator - ( <span class="keyword">const</span> Vector3& rkVector )<span class="keyword"> const</span> |
---|
134 | 00136 <span class="keyword"> </span>{ |
---|
135 | 00137 Vector3 kDiff; |
---|
136 | 00138 |
---|
137 | 00139 kDiff.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> = x - rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>; |
---|
138 | 00140 kDiff.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> = y - rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>; |
---|
139 | 00141 kDiff.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> = z - rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>; |
---|
140 | 00142 |
---|
141 | 00143 <span class="keywordflow">return</span> kDiff; |
---|
142 | 00144 } |
---|
143 | 00145 |
---|
144 | <a name="l00146"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a13">00146</a> <span class="keyword">inline</span> Vector3 <a class="code" href="namespaceOgre.html#a612">operator * </a>( <a class="code" href="namespaceOgre.html#a420">Real</a> fScalar )<span class="keyword"> const</span> |
---|
145 | 00147 <span class="keyword"> </span>{ |
---|
146 | 00148 Vector3 kProd; |
---|
147 | 00149 |
---|
148 | 00150 kProd.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> = fScalar*x; |
---|
149 | 00151 kProd.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> = fScalar*y; |
---|
150 | 00152 kProd.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> = fScalar*z; |
---|
151 | 00153 |
---|
152 | 00154 <span class="keywordflow">return</span> kProd; |
---|
153 | 00155 } |
---|
154 | 00156 |
---|
155 | <a name="l00157"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a14">00157</a> <span class="keyword">inline</span> Vector3 <a class="code" href="namespaceOgre.html#a612">operator * </a>( <span class="keyword">const</span> Vector3& rhs)<span class="keyword"> const</span> |
---|
156 | 00158 <span class="keyword"> </span>{ |
---|
157 | 00159 Vector3 kProd; |
---|
158 | 00160 |
---|
159 | 00161 kProd.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> = rhs.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> * x; |
---|
160 | 00162 kProd.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> = rhs.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> * y; |
---|
161 | 00163 kProd.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> = rhs.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> * z; |
---|
162 | 00164 |
---|
163 | 00165 <span class="keywordflow">return</span> kProd; |
---|
164 | 00166 } |
---|
165 | 00167 |
---|
166 | <a name="l00168"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a15">00168</a> <span class="keyword">inline</span> Vector3 <a class="code" href="namespaceOgre.html#a613">operator / </a>( <a class="code" href="namespaceOgre.html#a420">Real</a> fScalar )<span class="keyword"> const</span> |
---|
167 | 00169 <span class="keyword"> </span>{ |
---|
168 | 00170 assert( fScalar != 0.0 ); |
---|
169 | 00171 |
---|
170 | 00172 Vector3 kDiv; |
---|
171 | 00173 |
---|
172 | 00174 <a class="code" href="namespaceOgre.html#a420">Real</a> fInv = 1.0 / fScalar; |
---|
173 | 00175 kDiv.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> = x * fInv; |
---|
174 | 00176 kDiv.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> = y * fInv; |
---|
175 | 00177 kDiv.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> = z * fInv; |
---|
176 | 00178 |
---|
177 | 00179 <span class="keywordflow">return</span> kDiv; |
---|
178 | 00180 } |
---|
179 | 00181 |
---|
180 | <a name="l00182"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a16">00182</a> <span class="keyword">inline</span> Vector3 <a class="code" href="namespaceOgre.html#a613">operator / </a>( <span class="keyword">const</span> Vector3& rhs)<span class="keyword"> const</span> |
---|
181 | 00183 <span class="keyword"> </span>{ |
---|
182 | 00184 Vector3 kDiv; |
---|
183 | 00185 |
---|
184 | 00186 kDiv.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> = x / rhs.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>; |
---|
185 | 00187 kDiv.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> = y / rhs.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>; |
---|
186 | 00188 kDiv.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> = z / rhs.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>; |
---|
187 | 00189 |
---|
188 | 00190 <span class="keywordflow">return</span> kDiv; |
---|
189 | 00191 } |
---|
190 | 00192 |
---|
191 | 00193 |
---|
192 | <a name="l00194"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a17">00194</a> <span class="keyword">inline</span> Vector3 operator - ()<span class="keyword"> const</span> |
---|
193 | 00195 <span class="keyword"> </span>{ |
---|
194 | 00196 Vector3 kNeg; |
---|
195 | 00197 |
---|
196 | 00198 kNeg.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> = -x; |
---|
197 | 00199 kNeg.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> = -y; |
---|
198 | 00200 kNeg.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> = -z; |
---|
199 | 00201 |
---|
200 | 00202 <span class="keywordflow">return</span> kNeg; |
---|
201 | 00203 } |
---|
202 | 00204 |
---|
203 | <a name="l00205"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3n0">00205</a> <span class="keyword">inline</span> <span class="keyword">friend</span> Vector3 <a class="code" href="namespaceOgre.html#a612">operator * </a>( <a class="code" href="namespaceOgre.html#a420">Real</a> fScalar, <span class="keyword">const</span> Vector3& rkVector ) |
---|
204 | 00206 { |
---|
205 | 00207 Vector3 kProd; |
---|
206 | 00208 |
---|
207 | 00209 kProd.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> = fScalar * rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>; |
---|
208 | 00210 kProd.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> = fScalar * rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>; |
---|
209 | 00211 kProd.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> = fScalar * rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>; |
---|
210 | 00212 |
---|
211 | 00213 <span class="keywordflow">return</span> kProd; |
---|
212 | 00214 } |
---|
213 | 00215 |
---|
214 | 00216 <span class="comment">// arithmetic updates</span> |
---|
215 | <a name="l00217"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a18">00217</a> <span class="keyword">inline</span> Vector3& operator += ( <span class="keyword">const</span> Vector3& rkVector ) |
---|
216 | 00218 { |
---|
217 | 00219 x += rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>; |
---|
218 | 00220 y += rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>; |
---|
219 | 00221 z += rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>; |
---|
220 | 00222 |
---|
221 | 00223 <span class="keywordflow">return</span> *<span class="keyword">this</span>; |
---|
222 | 00224 } |
---|
223 | 00225 |
---|
224 | <a name="l00226"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a19">00226</a> <span class="keyword">inline</span> Vector3& operator -= ( <span class="keyword">const</span> Vector3& rkVector ) |
---|
225 | 00227 { |
---|
226 | 00228 x -= rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>; |
---|
227 | 00229 y -= rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>; |
---|
228 | 00230 z -= rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>; |
---|
229 | 00231 |
---|
230 | 00232 <span class="keywordflow">return</span> *<span class="keyword">this</span>; |
---|
231 | 00233 } |
---|
232 | 00234 |
---|
233 | <a name="l00235"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a20">00235</a> <span class="keyword">inline</span> Vector3& operator *= ( <a class="code" href="namespaceOgre.html#a420">Real</a> fScalar ) |
---|
234 | 00236 { |
---|
235 | 00237 x *= fScalar; |
---|
236 | 00238 y *= fScalar; |
---|
237 | 00239 z *= fScalar; |
---|
238 | 00240 <span class="keywordflow">return</span> *<span class="keyword">this</span>; |
---|
239 | 00241 } |
---|
240 | 00242 |
---|
241 | <a name="l00243"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a21">00243</a> <span class="keyword">inline</span> Vector3& operator *= ( <span class="keyword">const</span> Vector3& rkVector ) |
---|
242 | 00244 { |
---|
243 | 00245 x *= rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>; |
---|
244 | 00246 y *= rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>; |
---|
245 | 00247 z *= rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>; |
---|
246 | 00248 |
---|
247 | 00249 <span class="keywordflow">return</span> *<span class="keyword">this</span>; |
---|
248 | 00250 } |
---|
249 | 00251 |
---|
250 | <a name="l00252"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a22">00252</a> <span class="keyword">inline</span> Vector3& operator /= ( <a class="code" href="namespaceOgre.html#a420">Real</a> fScalar ) |
---|
251 | 00253 { |
---|
252 | 00254 assert( fScalar != 0.0 ); |
---|
253 | 00255 |
---|
254 | 00256 <a class="code" href="namespaceOgre.html#a420">Real</a> fInv = 1.0 / fScalar; |
---|
255 | 00257 |
---|
256 | 00258 x *= fInv; |
---|
257 | 00259 y *= fInv; |
---|
258 | 00260 z *= fInv; |
---|
259 | 00261 |
---|
260 | 00262 <span class="keywordflow">return</span> *<span class="keyword">this</span>; |
---|
261 | 00263 } |
---|
262 | 00264 |
---|
263 | <a name="l00265"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a23">00265</a> <span class="keyword">inline</span> Vector3& operator /= ( <span class="keyword">const</span> Vector3& rkVector ) |
---|
264 | 00266 { |
---|
265 | 00267 x /= rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>; |
---|
266 | 00268 y /= rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>; |
---|
267 | 00269 z /= rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>; |
---|
268 | 00270 |
---|
269 | 00271 <span class="keywordflow">return</span> *<span class="keyword">this</span>; |
---|
270 | 00272 } |
---|
271 | 00273 |
---|
272 | 00274 |
---|
273 | <a name="l00282"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a24">00282</a> <span class="keyword">inline</span> <a class="code" href="namespaceOgre.html#a420">Real</a> length ()<span class="keyword"> const</span> |
---|
274 | 00283 <span class="keyword"> </span>{ |
---|
275 | 00284 <span class="keywordflow">return</span> Math::Sqrt( x * x + y * y + z * z ); |
---|
276 | 00285 } |
---|
277 | 00286 |
---|
278 | <a name="l00297"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a25">00297</a> <span class="keyword">inline</span> <a class="code" href="namespaceOgre.html#a420">Real</a> squaredLength ()<span class="keyword"> const</span> |
---|
279 | 00298 <span class="keyword"> </span>{ |
---|
280 | 00299 <span class="keywordflow">return</span> x * x + y * y + z * z; |
---|
281 | 00300 } |
---|
282 | 00301 |
---|
283 | <a name="l00316"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a26">00316</a> <span class="keyword">inline</span> <a class="code" href="namespaceOgre.html#a420">Real</a> dotProduct(<span class="keyword">const</span> Vector3& vec)<span class="keyword"> const</span> |
---|
284 | 00317 <span class="keyword"> </span>{ |
---|
285 | 00318 <span class="keywordflow">return</span> x * vec.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> + y * vec.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> + z * vec.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>; |
---|
286 | 00319 } |
---|
287 | 00320 |
---|
288 | <a name="l00330"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a27">00330</a> <span class="keyword">inline</span> <a class="code" href="namespaceOgre.html#a420">Real</a> normalise() |
---|
289 | 00331 { |
---|
290 | 00332 <a class="code" href="namespaceOgre.html#a420">Real</a> fLength = Math::Sqrt( x * x + y * y + z * z ); |
---|
291 | 00333 |
---|
292 | 00334 <span class="comment">// Will also work for zero-sized vectors, but will change nothing</span> |
---|
293 | 00335 <span class="keywordflow">if</span> ( fLength > 1e-08 ) |
---|
294 | 00336 { |
---|
295 | 00337 <a class="code" href="namespaceOgre.html#a420">Real</a> fInvLength = 1.0 / fLength; |
---|
296 | 00338 x *= fInvLength; |
---|
297 | 00339 y *= fInvLength; |
---|
298 | 00340 z *= fInvLength; |
---|
299 | 00341 } |
---|
300 | 00342 |
---|
301 | 00343 <span class="keywordflow">return</span> fLength; |
---|
302 | 00344 } |
---|
303 | 00345 |
---|
304 | <a name="l00373"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a28">00373</a> <span class="keyword">inline</span> Vector3 crossProduct( <span class="keyword">const</span> Vector3& rkVector )<span class="keyword"> const</span> |
---|
305 | 00374 <span class="keyword"> </span>{ |
---|
306 | 00375 Vector3 kCross; |
---|
307 | 00376 |
---|
308 | 00377 kCross.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> = y * rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> - z * rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>; |
---|
309 | 00378 kCross.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> = z * rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> - x * rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>; |
---|
310 | 00379 kCross.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> = x * rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> - y * rkVector.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>; |
---|
311 | 00380 |
---|
312 | 00381 <span class="keywordflow">return</span> kCross; |
---|
313 | 00382 } |
---|
314 | 00383 |
---|
315 | <a name="l00387"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a29">00387</a> <span class="keyword">inline</span> Vector3 midPoint( <span class="keyword">const</span> Vector3& vec )<span class="keyword"> const</span> |
---|
316 | 00388 <span class="keyword"> </span>{ |
---|
317 | 00389 <span class="keywordflow">return</span> Vector3( |
---|
318 | 00390 ( x + vec.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> ) * 0.5, |
---|
319 | 00391 ( y + vec.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> ) * 0.5, |
---|
320 | 00392 ( z + vec.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> ) * 0.5 ); |
---|
321 | 00393 } |
---|
322 | 00394 |
---|
323 | <a name="l00398"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a30">00398</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator < ( <span class="keyword">const</span> Vector3& rhs )<span class="keyword"> const</span> |
---|
324 | 00399 <span class="keyword"> </span>{ |
---|
325 | 00400 <span class="keywordflow">if</span>( x < rhs.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> && y < rhs.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> && z < rhs.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> ) |
---|
326 | 00401 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
---|
327 | 00402 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
---|
328 | 00403 } |
---|
329 | 00404 |
---|
330 | <a name="l00408"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a31">00408</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator > ( <span class="keyword">const</span> Vector3& rhs )<span class="keyword"> const</span> |
---|
331 | 00409 <span class="keyword"> </span>{ |
---|
332 | 00410 <span class="keywordflow">if</span>( x > rhs.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> && y > rhs.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> && z > rhs.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> ) |
---|
333 | 00411 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
---|
334 | 00412 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
---|
335 | 00413 } |
---|
336 | 00414 |
---|
337 | <a name="l00422"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a32">00422</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> makeFloor( <span class="keyword">const</span> Vector3& cmp ) |
---|
338 | 00423 { |
---|
339 | 00424 <span class="keywordflow">if</span>( cmp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> < x ) x = cmp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>; |
---|
340 | 00425 <span class="keywordflow">if</span>( cmp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> < y ) y = cmp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>; |
---|
341 | 00426 <span class="keywordflow">if</span>( cmp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> < z ) z = cmp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>; |
---|
342 | 00427 } |
---|
343 | 00428 |
---|
344 | <a name="l00436"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a33">00436</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> makeCeil( <span class="keyword">const</span> Vector3& cmp ) |
---|
345 | 00437 { |
---|
346 | 00438 <span class="keywordflow">if</span>( cmp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> > x ) x = cmp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>; |
---|
347 | 00439 <span class="keywordflow">if</span>( cmp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> > y ) y = cmp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>; |
---|
348 | 00440 <span class="keywordflow">if</span>( cmp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> > z ) z = cmp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>; |
---|
349 | 00441 } |
---|
350 | 00442 |
---|
351 | <a name="l00450"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a34">00450</a> <span class="keyword">inline</span> Vector3 perpendicular(<span class="keywordtype">void</span>)<span class="keyword"> const</span> |
---|
352 | 00451 <span class="keyword"> </span>{ |
---|
353 | 00452 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="namespaceOgre.html#a420">Real</a> fSquareZero = 1e-06 * 1e-06; |
---|
354 | 00453 |
---|
355 | 00454 Vector3 perp = this->crossProduct( Vector3::UNIT_X ); |
---|
356 | 00455 |
---|
357 | 00456 <span class="comment">// Check length</span> |
---|
358 | 00457 <span class="keywordflow">if</span>( perp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a25">squaredLength</a>() < fSquareZero ) |
---|
359 | 00458 { |
---|
360 | 00459 <span class="comment">/* This vector is the Y axis multiplied by a scalar, so we have </span> |
---|
361 | 00460 <span class="comment"> to use another axis.</span> |
---|
362 | 00461 <span class="comment"> */</span> |
---|
363 | 00462 perp = this->crossProduct( Vector3::UNIT_Y ); |
---|
364 | 00463 } |
---|
365 | 00464 |
---|
366 | 00465 <span class="keywordflow">return</span> perp; |
---|
367 | 00466 } |
---|
368 | <a name="l00486"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a35">00486</a> <span class="keyword">inline</span> Vector3 randomDeviant( |
---|
369 | 00487 <span class="keyword">const</span> <a class="code" href="classOgre_1_1Radian.html">Radian</a>& angle, |
---|
370 | 00488 <span class="keyword">const</span> Vector3& up = Vector3::ZERO )<span class="keyword"> const</span> |
---|
371 | 00489 <span class="keyword"> </span>{ |
---|
372 | 00490 Vector3 newUp; |
---|
373 | 00491 |
---|
374 | 00492 <span class="keywordflow">if</span> (up == Vector3::ZERO) |
---|
375 | 00493 { |
---|
376 | 00494 <span class="comment">// Generate an up vector</span> |
---|
377 | 00495 newUp = this->perpendicular(); |
---|
378 | 00496 } |
---|
379 | 00497 <span class="keywordflow">else</span> |
---|
380 | 00498 { |
---|
381 | 00499 newUp = up; |
---|
382 | 00500 } |
---|
383 | 00501 |
---|
384 | 00502 <span class="comment">// Rotate up vector by random amount around this</span> |
---|
385 | 00503 <a class="code" href="classOgre_1_1Quaternion.html">Quaternion</a> q; |
---|
386 | 00504 q.<a class="code" href="classOgre_1_1Quaternion.html#Ogre_1_1Quaterniona8">FromAngleAxis</a>( <a class="code" href="classOgre_1_1Radian.html">Radian</a>(Math::UnitRandom() * Math::TWO_PI), *<span class="keyword">this</span> ); |
---|
387 | 00505 newUp = q * newUp; |
---|
388 | 00506 |
---|
389 | 00507 <span class="comment">// Finally rotate this by given angle around randomised up</span> |
---|
390 | 00508 q.<a class="code" href="classOgre_1_1Quaternion.html#Ogre_1_1Quaterniona8">FromAngleAxis</a>( angle, newUp ); |
---|
391 | 00509 <span class="keywordflow">return</span> q * (*this); |
---|
392 | 00510 } |
---|
393 | 00511 <span class="preprocessor">#ifndef OGRE_FORCE_ANGLE_TYPES</span> |
---|
394 | 00512 <span class="preprocessor"></span> <span class="keyword">inline</span> Vector3 randomDeviant( |
---|
395 | 00513 <a class="code" href="namespaceOgre.html#a420">Real</a> angle, |
---|
396 | 00514 <span class="keyword">const</span> Vector3& up = Vector3::ZERO )<span class="keyword"> const</span> |
---|
397 | 00515 <span class="keyword"> </span>{ |
---|
398 | 00516 <span class="keywordflow">return</span> randomDeviant ( <a class="code" href="classOgre_1_1Radian.html">Radian</a>(angle), up ); |
---|
399 | 00517 } |
---|
400 | 00518 <span class="preprocessor">#endif//OGRE_FORCE_ANGLE_TYPES</span> |
---|
401 | 00519 <span class="preprocessor"></span> |
---|
402 | <a name="l00526"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a36">00526</a> <a class="code" href="classOgre_1_1Quaternion.html">Quaternion</a> getRotationTo(<span class="keyword">const</span> Vector3& dest)<span class="keyword"> const</span> |
---|
403 | 00527 <span class="keyword"> </span>{ |
---|
404 | 00528 <span class="comment">// Based on Stan Melax's article in Game Programming Gems</span> |
---|
405 | 00529 <a class="code" href="classOgre_1_1Quaternion.html">Quaternion</a> q; |
---|
406 | 00530 <span class="comment">// Copy, since cannot modify local</span> |
---|
407 | 00531 Vector3 v0 = *<span class="keyword">this</span>; |
---|
408 | 00532 Vector3 v1 = dest; |
---|
409 | 00533 v0.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a27">normalise</a>(); |
---|
410 | 00534 v1.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a27">normalise</a>(); |
---|
411 | 00535 |
---|
412 | 00536 Vector3 c = v0.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a28">crossProduct</a>(v1); |
---|
413 | 00537 |
---|
414 | 00538 <a class="code" href="namespaceOgre.html#a420">Real</a> d = v0.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a26">dotProduct</a>(v1); |
---|
415 | 00539 <span class="comment">// If dot == 1, vectors are the same</span> |
---|
416 | 00540 <span class="keywordflow">if</span> (d >= 1.0f) |
---|
417 | 00541 { |
---|
418 | 00542 <span class="keywordflow">return</span> Quaternion::IDENTITY; |
---|
419 | 00543 } |
---|
420 | 00544 <span class="comment">// NB if the crossProduct approaches zero, we get unstable because ANY axis will do</span> |
---|
421 | 00545 <span class="comment">// when v0 == -v1</span> |
---|
422 | 00546 <span class="keywordflow">if</span> (c.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a37">isZeroLength</a>()) |
---|
423 | 00547 { |
---|
424 | 00548 Vector3 axis = Vector3::UNIT_X.crossProduct(*<span class="keyword">this</span>); |
---|
425 | 00549 <span class="keywordflow">if</span> (axis.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a37">isZeroLength</a>()) <span class="comment">// pick another if colinear</span> |
---|
426 | 00550 axis = Vector3::UNIT_Y.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a28">crossProduct</a>(*<span class="keyword">this</span>); |
---|
427 | 00551 axis.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a27">normalise</a>(); |
---|
428 | 00552 <a class="code" href="classOgre_1_1Quaternion.html">Quaternion</a> ret; |
---|
429 | 00553 ret.<a class="code" href="classOgre_1_1Quaternion.html#Ogre_1_1Quaterniona8">FromAngleAxis</a>(<a class="code" href="classOgre_1_1Radian.html">Radian</a>(Math::PI), axis); |
---|
430 | 00554 <span class="keywordflow">return</span> ret; |
---|
431 | 00555 } |
---|
432 | 00556 <a class="code" href="namespaceOgre.html#a420">Real</a> s = Math::Sqrt( (1+d)*2 ); |
---|
433 | 00557 assert (s != 0 && <span class="stringliteral">"Divide by zero!"</span>); |
---|
434 | 00558 <a class="code" href="namespaceOgre.html#a420">Real</a> invs = 1 / s; |
---|
435 | 00559 |
---|
436 | 00560 |
---|
437 | 00561 q.<a class="code" href="classOgre_1_1Quaternion.html#Ogre_1_1Quaterniono1">x</a> = c.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> * invs; |
---|
438 | 00562 q.<a class="code" href="classOgre_1_1Quaternion.html#Ogre_1_1Quaterniono2">y</a> = c.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> * invs; |
---|
439 | 00563 q.<a class="code" href="classOgre_1_1Quaternion.html#Ogre_1_1Quaterniono3">z</a> = c.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> * invs; |
---|
440 | 00564 q.<a class="code" href="classOgre_1_1Quaternion.html#Ogre_1_1Quaterniono0">w</a> = s * 0.5; |
---|
441 | 00565 <span class="keywordflow">return</span> q; |
---|
442 | 00566 } |
---|
443 | 00567 |
---|
444 | <a name="l00569"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a37">00569</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> isZeroLength(<span class="keywordtype">void</span>)<span class="keyword"> const</span> |
---|
445 | 00570 <span class="keyword"> </span>{ |
---|
446 | 00571 <a class="code" href="namespaceOgre.html#a420">Real</a> sqlen = (x * x) + (y * y) + (z * z); |
---|
447 | 00572 <span class="keywordflow">return</span> (sqlen < (1e-06 * 1e-06)); |
---|
448 | 00573 |
---|
449 | 00574 } |
---|
450 | 00575 |
---|
451 | <a name="l00578"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a38">00578</a> <span class="keyword">inline</span> Vector3 normalisedCopy(<span class="keywordtype">void</span>)<span class="keyword"> const</span> |
---|
452 | 00579 <span class="keyword"> </span>{ |
---|
453 | 00580 Vector3 ret = *<span class="keyword">this</span>; |
---|
454 | 00581 ret.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a27">normalise</a>(); |
---|
455 | 00582 <span class="keywordflow">return</span> ret; |
---|
456 | 00583 } |
---|
457 | 00584 |
---|
458 | <a name="l00588"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a39">00588</a> <span class="keyword">inline</span> Vector3 reflect(<span class="keyword">const</span> Vector3& normal)<span class="keyword"> const</span> |
---|
459 | 00589 <span class="keyword"> </span>{ |
---|
460 | 00590 <span class="keywordflow">return</span> Vector3( *<span class="keyword">this</span> - ( 2 * this->dotProduct(normal) * normal ) ); |
---|
461 | 00591 } |
---|
462 | 00592 |
---|
463 | <a name="l00599"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a40">00599</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> positionEquals(<span class="keyword">const</span> Vector3& rhs, <a class="code" href="namespaceOgre.html#a420">Real</a> tolerance = 1e-03)<span class="keyword"> const</span> |
---|
464 | 00600 <span class="keyword"> </span>{ |
---|
465 | 00601 <span class="keywordflow">return</span> Math::RealEqual(x, rhs.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>, tolerance) && |
---|
466 | 00602 Math::RealEqual(y, rhs.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>, tolerance) && |
---|
467 | 00603 Math::RealEqual(z, rhs.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>, tolerance); |
---|
468 | 00604 |
---|
469 | 00605 } |
---|
470 | <a name="l00612"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a41">00612</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> directionEquals(<span class="keyword">const</span> Vector3& rhs, |
---|
471 | 00613 <span class="keyword">const</span> <a class="code" href="classOgre_1_1Radian.html">Radian</a>& tolerance)<span class="keyword"> const</span> |
---|
472 | 00614 <span class="keyword"> </span>{ |
---|
473 | 00615 <a class="code" href="namespaceOgre.html#a420">Real</a> dot = dotProduct(rhs); |
---|
474 | 00616 <a class="code" href="classOgre_1_1Radian.html">Radian</a> angle = Math::ACos(dot); |
---|
475 | 00617 |
---|
476 | 00618 <span class="keywordflow">return</span> Math::Abs(angle.<a class="code" href="classOgre_1_1Radian.html#Ogre_1_1Radiana6">valueRadians</a>()) <= tolerance.<a class="code" href="classOgre_1_1Radian.html#Ogre_1_1Radiana6">valueRadians</a>(); |
---|
477 | 00619 |
---|
478 | 00620 } |
---|
479 | 00621 |
---|
480 | 00622 <span class="comment">// special points</span> |
---|
481 | <a name="l00623"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3s0">00623</a> <span class="keyword">static</span> <span class="keyword">const</span> Vector3 ZERO; |
---|
482 | <a name="l00624"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3s1">00624</a> <span class="keyword">static</span> <span class="keyword">const</span> Vector3 UNIT_X; |
---|
483 | <a name="l00625"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3s2">00625</a> <span class="keyword">static</span> <span class="keyword">const</span> Vector3 UNIT_Y; |
---|
484 | <a name="l00626"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3s3">00626</a> <span class="keyword">static</span> <span class="keyword">const</span> Vector3 UNIT_Z; |
---|
485 | <a name="l00627"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3s4">00627</a> <span class="keyword">static</span> <span class="keyword">const</span> Vector3 NEGATIVE_UNIT_X; |
---|
486 | <a name="l00628"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3s5">00628</a> <span class="keyword">static</span> <span class="keyword">const</span> Vector3 NEGATIVE_UNIT_Y; |
---|
487 | <a name="l00629"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3s6">00629</a> <span class="keyword">static</span> <span class="keyword">const</span> Vector3 NEGATIVE_UNIT_Z; |
---|
488 | <a name="l00630"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3s7">00630</a> <span class="keyword">static</span> <span class="keyword">const</span> Vector3 UNIT_SCALE; |
---|
489 | 00631 |
---|
490 | 00634 <span class="keyword">inline</span> <a class="code" href="class__OgreExport.html">_OgreExport</a> <span class="keyword">friend</span> std::ostream& <span class="keyword">operator</span> << |
---|
491 | <a name="l00635"></a><a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3n1">00635</a> ( std::ostream& o, <span class="keyword">const</span> Vector3& v ) |
---|
492 | 00636 { |
---|
493 | 00637 o << <span class="stringliteral">"Vector3("</span> << v.x << <span class="stringliteral">", "</span> << v.y << <span class="stringliteral">", "</span> << v.z << <span class="stringliteral">")"</span>; |
---|
494 | 00638 <span class="keywordflow">return</span> o; |
---|
495 | 00639 } |
---|
496 | 00640 }; |
---|
497 | 00641 |
---|
498 | 00642 } |
---|
499 | 00643 <span class="preprocessor">#endif</span> |
---|
500 | </pre></div><hr> |
---|
501 | <p> |
---|
502 | Copyright © 2000-2005 by The OGRE Team<br /> |
---|
503 | <!--Creative Commons License--><a rel="license" href="http://creativecommons.org/licenses/by-sa/2.5/"><img alt="Creative Commons License" border="0" src="http://creativecommons.org/images/public/somerights20.png"/></a><br/> |
---|
504 | This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/2.5/">Creative Commons Attribution-ShareAlike 2.5 License</a>.<br/> |
---|
505 | <!--/Creative Commons License--><!-- <rdf:RDF xmlns="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> |
---|
506 | <Work rdf:about=""> |
---|
507 | <license rdf:resource="http://creativecommons.org/licenses/by-sa/2.5/" /> |
---|
508 | <dc:type rdf:resource="http://purl.org/dc/dcmitype/Text" /> |
---|
509 | </Work> |
---|
510 | <License rdf:about="http://creativecommons.org/licenses/by-sa/2.5/"><permits rdf:resource="http://web.resource.org/cc/Reproduction"/><permits rdf:resource="http://web.resource.org/cc/Distribution"/><requires rdf:resource="http://web.resource.org/cc/Notice"/><requires rdf:resource="http://web.resource.org/cc/Attribution"/><permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/><requires rdf:resource="http://web.resource.org/cc/ShareAlike"/></License></rdf:RDF> --> |
---|
511 | |
---|
512 | Last modified Sun Feb 12 12:59:54 2006 |
---|
513 | </p> |
---|
514 | </body> |
---|
515 | </html> |
---|