aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ModifiedBulletX/MonoXnaCompactMaths/Quaternion.cs
diff options
context:
space:
mode:
authorMW2007-07-13 17:03:59 +0000
committerMW2007-07-13 17:03:59 +0000
commit540549bd897baaa83b72bc3234ef6243009592e8 (patch)
tree4bbf1f4c8880263c14c2b7d74bb493615e374e2b /libraries/ModifiedBulletX/MonoXnaCompactMaths/Quaternion.cs
parentThink SceneObject/Primitive copying should now work, just need to hook it up ... (diff)
downloadopensim-SC_OLD-540549bd897baaa83b72bc3234ef6243009592e8.zip
opensim-SC_OLD-540549bd897baaa83b72bc3234ef6243009592e8.tar.gz
opensim-SC_OLD-540549bd897baaa83b72bc3234ef6243009592e8.tar.bz2
opensim-SC_OLD-540549bd897baaa83b72bc3234ef6243009592e8.tar.xz
Stage 1 of adding Darok's bulletX plugin: adding the ModifiedBulletX project (which is based on the BulletXNA project, but modified to not use XNA).
Diffstat (limited to '')
-rw-r--r--libraries/ModifiedBulletX/MonoXnaCompactMaths/Quaternion.cs346
1 files changed, 346 insertions, 0 deletions
diff --git a/libraries/ModifiedBulletX/MonoXnaCompactMaths/Quaternion.cs b/libraries/ModifiedBulletX/MonoXnaCompactMaths/Quaternion.cs
new file mode 100644
index 0000000..6ed1443
--- /dev/null
+++ b/libraries/ModifiedBulletX/MonoXnaCompactMaths/Quaternion.cs
@@ -0,0 +1,346 @@
1#region License
2/*
3MIT License
4Copyright © 2006 The Mono.Xna Team
5
6All rights reserved.
7
8Permission is hereby granted, free of charge, to any person obtaining a copy
9of this software and associated documentation files (the "Software"), to deal
10in the Software without restriction, including without limitation the rights
11to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12copies of the Software, and to permit persons to whom the Software is
13furnished to do so, subject to the following conditions:
14
15The above copyright notice and this permission notice shall be included in all
16copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24SOFTWARE.
25*/
26#endregion License
27
28using System;
29using System.ComponentModel;
30
31namespace MonoXnaCompactMaths
32{
33 [Serializable]
34 //[TypeConverter(typeof(QuaternionConverter))]
35 public struct Quaternion : IEquatable<Quaternion>
36 {
37 public float X;
38 public float Y;
39 public float Z;
40 public float W;
41 static Quaternion identity = new Quaternion(0, 0, 0, 1);
42
43
44 public Quaternion(float x, float y, float z, float w)
45 {
46 this.X = x;
47 this.Y = y;
48 this.Z = z;
49 this.W = w;
50 }
51
52
53 public Quaternion(Vector3 vectorPart, float scalarPart)
54 {
55 this.X = vectorPart.X;
56 this.Y = vectorPart.Y;
57 this.Z = vectorPart.Z;
58 this.W = scalarPart;
59 }
60
61 public static Quaternion Identity
62 {
63 get{ return identity; }
64 }
65
66
67 public static Quaternion Add(Quaternion quaternion1, Quaternion quaternion2)
68 {
69 throw new NotImplementedException();
70 }
71
72
73 public static void Add(ref Quaternion quaternion1, ref Quaternion quaternion2, out Quaternion result)
74 {
75 throw new NotImplementedException();
76 }
77
78
79 public static Quaternion CreateFromAxisAngle(Vector3 axis, float angle)
80 {
81 throw new NotImplementedException();
82 }
83
84
85 public static void CreateFromAxisAngle(ref Vector3 axis, float angle, out Quaternion result)
86 {
87 throw new NotImplementedException();
88 }
89
90
91 public static Quaternion CreateFromRotationMatrix(Matrix matrix)
92 {
93 throw new NotImplementedException();
94 }
95
96
97 public static void CreateFromRotationMatrix(ref Matrix matrix, out Quaternion result)
98 {
99 throw new NotImplementedException();
100 }
101
102
103 public static Quaternion Divide(Quaternion quaternion1, Quaternion quaternion2)
104 {
105 throw new NotImplementedException();
106 }
107
108
109 public static void Divide(ref Quaternion quaternion1, ref Quaternion quaternion2, out Quaternion result)
110 {
111 throw new NotImplementedException();
112 }
113
114
115 public static float Dot(Quaternion quaternion1, Quaternion quaternion2)
116 {
117 throw new NotImplementedException();
118 }
119
120
121 public static void Dot(ref Quaternion quaternion1, ref Quaternion quaternion2, out float result)
122 {
123 throw new NotImplementedException();
124 }
125
126
127 public override bool Equals(object obj)
128 {
129 throw new NotImplementedException();
130 }
131
132
133 public bool Equals(Quaternion other)
134 {
135 throw new NotImplementedException();
136 }
137
138
139 public override int GetHashCode()
140 {
141 throw new NotImplementedException();
142 }
143
144
145 public static Quaternion Inverse(Quaternion quaternion)
146 {
147 throw new NotImplementedException();
148 }
149
150
151 public static void Inverse(ref Quaternion quaternion, out Quaternion result)
152 {
153 throw new NotImplementedException();
154 }
155
156
157 public float Length()
158 {
159 //---
160 return (float)Math.Sqrt(Math.Pow(this.W, 2.0) + Math.Pow(this.X, 2.0) + Math.Pow(this.Y, 2.0) + Math.Pow(this.Z, 2.0));
161 //---
162 //throw new NotImplementedException();
163 }
164
165
166 public float LengthSquared()
167 {
168 //---
169 return (float)(Math.Pow(this.W, 2.0) + Math.Pow(this.X, 2.0) + Math.Pow(this.Y, 2.0) + Math.Pow(this.Z, 2.0));
170 //---
171 //throw new NotImplementedException();
172 }
173
174
175 public static Quaternion Lerp(Quaternion quaternion1, Quaternion quaternion2, float amount)
176 {
177 throw new NotImplementedException();
178 }
179
180
181 public static void Lerp(ref Quaternion quaternion1, ref Quaternion quaternion2, float amount, out Quaternion result)
182 {
183 throw new NotImplementedException();
184 }
185
186
187 public static Quaternion Slerp(Quaternion quaternion1, Quaternion quaternion2, float amount)
188 {
189 throw new NotImplementedException();
190 }
191
192
193 public static void Slerp(ref Quaternion quaternion1, ref Quaternion quaternion2, float amount, out Quaternion result)
194 {
195 throw new NotImplementedException();
196 }
197
198
199 public static Quaternion Subtract(Quaternion quaternion1, Quaternion quaternion2)
200 {
201 throw new NotImplementedException();
202 }
203
204
205 public static void Subtract(ref Quaternion quaternion1, ref Quaternion quaternion2, out Quaternion result)
206 {
207 throw new NotImplementedException();
208 }
209
210
211 public static Quaternion Multiply(Quaternion quaternion1, Quaternion quaternion2)
212 {
213 throw new NotImplementedException();
214 }
215
216
217 public static Quaternion Multiply(Quaternion quaternion1, float scaleFactor)
218 {
219 throw new NotImplementedException();
220 }
221
222
223 public static void Multiply(ref Quaternion quaternion1, float scaleFactor, out Quaternion result)
224 {
225 throw new NotImplementedException();
226 }
227
228
229 public static void Multiply(ref Quaternion quaternion1, ref Quaternion quaternion2, out Quaternion result)
230 {
231 throw new NotImplementedException();
232 }
233
234
235 public static Quaternion Negate(Quaternion quaternion)
236 {
237 throw new NotImplementedException();
238 }
239
240
241 public static void Negate(ref Quaternion quaternion, out Quaternion result)
242 {
243 throw new NotImplementedException();
244 }
245
246
247 public void Normalize()
248 {
249 //---
250 this = Normalize(this);
251 //---
252 //throw new NotImplementedException();
253 }
254
255
256 public static Quaternion Normalize(Quaternion quaternion)
257 {
258 //---
259 return quaternion / quaternion.Length();
260 //---
261 //throw new NotImplementedException();
262 }
263
264
265 public static void Normalize(ref Quaternion quaternion, out Quaternion result)
266 {
267 throw new NotImplementedException();
268 }
269
270
271 public static Quaternion operator +(Quaternion quaternion1, Quaternion quaternion2)
272 {
273 throw new NotImplementedException();
274 }
275
276
277 public static Quaternion operator /(Quaternion quaternion1, Quaternion quaternion2)
278 {
279 throw new NotImplementedException();
280 }
281 public static Quaternion operator /(Quaternion quaternion, float factor)
282 {
283 quaternion.W /= factor;
284 quaternion.X /= factor;
285 quaternion.Y /= factor;
286 quaternion.Z /= factor;
287 return quaternion;
288 }
289
290 public static bool operator ==(Quaternion quaternion1, Quaternion quaternion2)
291 {
292 throw new NotImplementedException();
293 }
294
295
296 public static bool operator !=(Quaternion quaternion1, Quaternion quaternion2)
297 {
298 throw new NotImplementedException();
299 }
300
301
302 public static Quaternion operator *(Quaternion quaternion1, Quaternion quaternion2)
303 {
304 //---
305 //Grassmann product
306 Quaternion quaternionProduct = new Quaternion();
307
308 quaternionProduct.W = quaternion1.W * quaternion2.W - quaternion1.X * quaternion2.X - quaternion1.Y * quaternion2.Y - quaternion1.Z * quaternion2.Z;
309 quaternionProduct.X = quaternion1.W * quaternion2.X + quaternion1.X * quaternion2.W + quaternion1.Y * quaternion2.Z - quaternion1.Z * quaternion2.Y;
310 quaternionProduct.Y = quaternion1.W * quaternion2.Y - quaternion1.X * quaternion2.Z + quaternion1.Y * quaternion2.W + quaternion1.Z * quaternion2.X;
311 quaternionProduct.Z = quaternion1.W * quaternion2.Z + quaternion1.X * quaternion2.Y - quaternion1.Y * quaternion2.X + quaternion1.Z * quaternion2.W;
312 return quaternionProduct;
313 //---
314 //throw new NotImplementedException();
315 }
316
317
318 public static Quaternion operator *(Quaternion quaternion1, float scaleFactor)
319 {
320 throw new NotImplementedException();
321 }
322
323
324 public static Quaternion operator -(Quaternion quaternion1, Quaternion quaternion2)
325 {
326 throw new NotImplementedException();
327 }
328
329
330 public static Quaternion operator -(Quaternion quaternion)
331 {
332 throw new NotImplementedException();
333 }
334
335
336 public override string ToString()
337 {
338 throw new NotImplementedException();
339 }
340
341 private static void Conjugate(ref Quaternion quaternion, out Quaternion result)
342 {
343 throw new NotImplementedException();
344 }
345 }
346}