Tanoda
VectorTests.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
9using NUnit.Framework;
10using System;
11
12namespace Leap.LeapCSharp.Tests {
13 [TestFixture()]
14 public class VectorTests {
15 Vector thisVector = Vector.Up;
16 Vector thatVector = Vector.Forward;
17 //Vector otherVector = Vector.Left;
18
19 [OneTimeSetUp]
20 public void Init() { }
21
22 [Test()]
23 public void Vector_Up() {
24 Vector vec = Vector.Up;
25 Assert.AreEqual(0, vec.x, "x");
26 Assert.AreEqual(1, vec.y, "y");
27 Assert.AreEqual(0, vec.z, "z");
28 }
29
30 [Test()]
31 public void Vector_Down() {
32 Vector vec = Vector.Down;
33 Assert.AreEqual(0, vec.x, "x");
34 Assert.AreEqual(-1, vec.y, "y");
35 Assert.AreEqual(0, vec.z, "z");
36 }
37
38 [Test()]
39 public void Vector_Forward() {
40 Vector vec = Vector.Forward;
41 Assert.AreEqual(0, vec.x, "x");
42 Assert.AreEqual(0, vec.y, "y");
43 Assert.AreEqual(-1, vec.z, "z");
44 }
45
46 [Test()]
47 public void Vector_Backward() {
49 Assert.AreEqual(0, vec.x, "x");
50 Assert.AreEqual(0, vec.y, "y");
51 Assert.AreEqual(1, vec.z, "z");
52 }
53
54 [Test()]
55 public void Vector_Left() {
56 Vector vec = Vector.Left;
57 Assert.AreEqual(-1, vec.x, "x");
58 Assert.AreEqual(0, vec.y, "y");
59 Assert.AreEqual(0, vec.z, "z");
60 }
61
62 [Test()]
63 public void Vector_Right() {
64 Vector vec = Vector.Right;
65 Assert.AreEqual(1, vec.x, "x");
66 Assert.AreEqual(0, vec.y, "y");
67 Assert.AreEqual(0, vec.z, "z");
68 }
69
70 [Test()]
71 public void Vector_Zero() {
72 Vector vec = Vector.Zero;
73 Assert.AreEqual(0, vec.x, "x");
74 Assert.AreEqual(0, vec.y, "y");
75 Assert.AreEqual(0, vec.z, "z");
76 }
77
78 [Test()]
79 public void Vector_XAxis() {
80 Vector vec = Vector.XAxis;
81 Assert.AreEqual(1, vec.x, "x");
82 Assert.AreEqual(0, vec.y, "y");
83 Assert.AreEqual(0, vec.z, "z");
84 }
85
86 [Test()]
87 public void Vector_YAxis() {
88 Vector vec = Vector.YAxis;
89 Assert.AreEqual(0, vec.x, "x");
90 Assert.AreEqual(1, vec.y, "y");
91 Assert.AreEqual(0, vec.z, "z");
92 }
93
94 [Test()]
95 public void Vector_ZAxis() {
96 Vector vec = Vector.ZAxis;
97 Assert.AreEqual(0, vec.x, "x");
98 Assert.AreEqual(0, vec.y, "y");
99 Assert.AreEqual(1, vec.z, "z");
100 }
101
102 [Test()]
103 public void Vector_Constructor_1() {
104 Vector vec = new Vector(0.5f, 200.3f, 67f);
105 Assert.AreEqual(0.5f, vec.x, "x");
106 Assert.AreEqual(200.3f, vec.y, "y");
107 Assert.AreEqual(67f, vec.z, "z");
108 vec = new Vector();
109 Assert.AreEqual(0, vec.x, "x");
110 Assert.AreEqual(0, vec.y, "y");
111 Assert.AreEqual(0, vec.z, "z");
112 }
113
114 [Test()]
115 public void Vector_Constructor_2() {
116 Vector baseVector = new Vector(3, 4, 5);
117 Vector vec = new Vector(baseVector);
118 Assert.AreEqual(3, vec.x, "x");
119 Assert.AreEqual(4, vec.y, "y");
120 Assert.AreEqual(5, vec.z, "z");
121 vec.x = 12;
122 Assert.AreEqual(3, baseVector.x, "z");
123 }
124
125 [Test()]
126 public void Vector_Magnitude() {
127 Assert.AreEqual(0, Vector.Zero.Magnitude, "Zero has 0 length");
128 Assert.AreEqual(1, Vector.Up.Magnitude, "Up has 1 length");
129 Assert.AreEqual(1, Vector.Down.Magnitude, "Down has 1 length");
130 Assert.AreEqual(1, Vector.Left.Magnitude, "Left has 1 length");
131 Assert.AreEqual(1, Vector.Right.Magnitude, "Right has 1 length");
132 Assert.AreEqual(1, Vector.Forward.Magnitude, "Forward has 1 length");
133 Assert.AreEqual(1, Vector.Backward.Magnitude, "Backward has 1 length");
134
135 float tooBig = new Vector(float.MaxValue, float.MaxValue, float.MaxValue).Magnitude;
136 Assert.IsTrue(float.IsInfinity(tooBig), "max value is too large");
137 float tooSmall = new Vector(float.MinValue, float.MinValue, float.MinValue).Magnitude;
138 Assert.IsTrue(float.IsInfinity(tooSmall), "min value is too large");
139 Assert.AreEqual((float)Math.Sqrt(3f), new Vector(1, 1, 1).Magnitude, "(1,1,1) has sqrt(3) length");
140 Assert.AreEqual((float)Math.Sqrt(3f), new Vector(-1, -1, -1).Magnitude, "(-1,-1,-1) has sqrt(3) length");
141 }
142
143 [Test()]
145 Assert.AreEqual(0, Vector.Zero.MagnitudeSquared, "Zero has 0 length");
146 Assert.AreEqual(1, Vector.Up.MagnitudeSquared, "Up has 1 length");
147 Assert.AreEqual(1, Vector.Down.MagnitudeSquared, "Down has 1 length");
148 Assert.AreEqual(1, Vector.Left.MagnitudeSquared, "Left has 1 length");
149 Assert.AreEqual(1, Vector.Right.MagnitudeSquared, "Right has 1 length");
150 Assert.AreEqual(1, Vector.Forward.MagnitudeSquared, "Forward has 1 length");
151 Assert.AreEqual(1, Vector.Backward.MagnitudeSquared, "Backward has 1 length");
152
153 float tooBig = new Vector(float.MaxValue, float.MaxValue, float.MaxValue).MagnitudeSquared;
154 Assert.IsTrue(float.IsInfinity(tooBig), "max value is too large");
155 float tooSmall = new Vector(float.MinValue, float.MinValue, float.MinValue).MagnitudeSquared;
156 Assert.IsTrue(float.IsInfinity(tooSmall), "min value is too large");
157 Assert.AreEqual(3, new Vector(1, 1, 1).MagnitudeSquared, "(1,1,1) has 3 length");
158 Assert.AreEqual(3, new Vector(-1, -1, -1).MagnitudeSquared, "(-1,-1,-1) 3 length");
159 }
160
161 [Test()]
162 public void Vector_DistanceTo() {
163 Vector origin = Vector.Zero;
164 Assert.AreEqual(0, origin.DistanceTo(Vector.Zero), "distance to 0 is 0");
165 Assert.AreEqual(1, origin.DistanceTo(Vector.Up), "distance to Up is 1");
166 Assert.AreEqual(1, origin.DistanceTo(Vector.Down), "distance to Down is 1");
167 Assert.AreEqual(1, origin.DistanceTo(Vector.Left), "distance to Left is 1");
168 Assert.AreEqual(1, origin.DistanceTo(Vector.Right), "distance to Right is 1");
169 Assert.AreEqual(1, origin.DistanceTo(Vector.Forward), "distance to Forward is 1");
170 Assert.AreEqual(1, origin.DistanceTo(Vector.Backward), "distance to Backward is 1");
171
172 float tooBig = origin.DistanceTo(new Vector(float.MaxValue, float.MaxValue, float.MaxValue));
173 Assert.IsTrue(float.IsInfinity(tooBig), "max value is too large");
174 float tooSmall = origin.DistanceTo(new Vector(float.MinValue, float.MinValue, float.MinValue));
175 Assert.IsTrue(float.IsInfinity(tooSmall), "min value is too large");
176 Assert.AreEqual((float)Math.Sqrt(3f), origin.DistanceTo(new Vector(1, 1, 1)), "distance to (1,1,1) is sqrt(3)");
177 Assert.AreEqual((float)Math.Sqrt(3f), origin.DistanceTo(new Vector(-1, -1, -1)), "distance to (-1,-1,-1) is sqrt(3)");
178 }
179
180 [Test()]
181 public void Vector_AngleTo() {
182 //The angle returned is always the smaller of the two conjugate angles. Thus A.angleTo(B) == B.angleTo(A) and is always a positive value less than or equal to pi radians (180 degrees).
183 Assert.AreEqual(0, new Vector(1, -3, 45).AngleTo(new Vector(1, -3, 45)), "angle to same");
184
185 Assert.AreEqual(90 * Constants.DEG_TO_RAD, Vector.Up.AngleTo(Vector.Left), "Up-Left");
186 Assert.AreEqual(90 * Constants.DEG_TO_RAD, Vector.Up.AngleTo(Vector.Right), "Up-Right");
187 Assert.AreEqual(90 * Constants.DEG_TO_RAD, Vector.Up.AngleTo(Vector.Forward), "Up-Forward");
188 Assert.AreEqual(90 * Constants.DEG_TO_RAD, Vector.Up.AngleTo(Vector.Backward), "Up-Backward");
189 Assert.AreEqual(90 * Constants.DEG_TO_RAD, Vector.Down.AngleTo(Vector.Left), "Down-Left");
190 Assert.AreEqual(90 * Constants.DEG_TO_RAD, Vector.Down.AngleTo(Vector.Right), "Down-Right");
191 Assert.AreEqual(90 * Constants.DEG_TO_RAD, Vector.Down.AngleTo(Vector.Forward), "Down-Forward");
192 Assert.AreEqual(90 * Constants.DEG_TO_RAD, Vector.Down.AngleTo(Vector.Backward), "Down-Backward");
193 Matrix rotator = Matrix.Identity;
194 Vector baseVec = Vector.Left;
195 Vector vec = new Vector(baseVec);
196 int count = 0;
197 for (; count <= 180; count++) {
198 rotator.SetRotation(Vector.Up, count * Constants.DEG_TO_RAD);
199 Vector rotated = rotator.TransformDirection(vec);
200 Assert.AreEqual(count * Constants.DEG_TO_RAD, baseVec.AngleTo(rotated), 12 * Constants.EPSILON, "0-180 Angle is " + baseVec.AngleTo(rotated) * Constants.RAD_TO_DEG);
201 Assert.AreEqual(rotated.AngleTo(baseVec), baseVec.AngleTo(rotated), Constants.EPSILON, "a to b == b to a");
202
203 }
204 for (; count <= 360; count++) {
205 rotator.SetRotation(Vector.Up, count * Constants.DEG_TO_RAD);
206 Vector rotated = rotator.TransformDirection(vec);
207
208 Assert.AreEqual((360 - count) * Constants.DEG_TO_RAD, baseVec.AngleTo(rotated), 12 * Constants.EPSILON, "180-360 Angle is " + baseVec.AngleTo(rotated) * Constants.RAD_TO_DEG);
209 Assert.AreEqual(rotated.AngleTo(baseVec), baseVec.AngleTo(rotated), Constants.EPSILON, "a to b == b to a");
210 }
211 for (; count <= 540; count++) {
212 rotator.SetRotation(Vector.Up, count * Constants.DEG_TO_RAD);
213 Vector rotated = rotator.TransformDirection(vec);
214 Assert.AreEqual((count - 360) * Constants.DEG_TO_RAD, baseVec.AngleTo(rotated), 12 * Constants.EPSILON, "360-540 Angle is " + baseVec.AngleTo(rotated) * Constants.RAD_TO_DEG);
215 Assert.AreEqual(rotated.AngleTo(baseVec), baseVec.AngleTo(rotated), Constants.EPSILON, "a to b == b to a");
216
217 }
218 for (; count <= 720; count++) {
219 rotator.SetRotation(Vector.Up, count * Constants.DEG_TO_RAD);
220 Vector rotated = rotator.TransformDirection(vec);
221
222 Assert.AreEqual((720 - count) * Constants.DEG_TO_RAD, baseVec.AngleTo(rotated), 12 * Constants.EPSILON, "540-720 Angle is " + baseVec.AngleTo(rotated) * Constants.RAD_TO_DEG);
223 Assert.AreEqual(rotated.AngleTo(baseVec), baseVec.AngleTo(rotated), Constants.EPSILON, "a to b == b to a");
224 }
225 }
226
227 [Test()]
228 public void Vector_Pitch() {
229 //If the vector points upward, the returned angle is between 0 and pi radians (180 degrees); if it points downward, the angle is between 0 and -pi radians
230 Matrix rotator = Matrix.Identity;
231 Vector baseVec = Vector.Forward;
232 Vector vec = new Vector(baseVec);
233 Vector axis = -Vector.XAxis;
234 int count = 0;
235 for (; count < 180; count++) {
236 rotator.SetRotation(axis, count * Constants.DEG_TO_RAD);
237 Vector rotated = rotator.TransformDirection(vec);
238 Assert.AreEqual(count * Constants.DEG_TO_RAD, rotated.Pitch, 12 * Constants.EPSILON, "0-180 Pitch is " + rotated.Pitch * Constants.RAD_TO_DEG);
239 }
240 for (; count <= 360; count++) {
241 rotator.SetRotation(axis, count * Constants.DEG_TO_RAD);
242 Vector rotated = rotator.TransformDirection(vec);
243 Assert.AreEqual((-360 + count) * Constants.DEG_TO_RAD, rotated.Pitch, 12 * Constants.EPSILON, "180-360 Pitch is " + rotated.Pitch * Constants.RAD_TO_DEG);
244 }
245 }
246
247 [Test()]
248 public void Vector_Yaw() {
249 //If the vector points to the right of the negative z-axis, then the returned angle is between 0 and pi radians (180 degrees); if it points to the left, the angle is between 0 and -pi radians.
250 Matrix rotator = Matrix.Identity;
251 Vector baseVec = Vector.Forward;
252 Vector vec = new Vector(baseVec);
253 Vector axis = Vector.YAxis;
254 int count = 0;
255 for (; count < 180; count++) {
256 rotator.SetRotation(axis, count * Constants.DEG_TO_RAD);
257 Vector rotated = rotator.TransformDirection(vec);
258 Assert.AreEqual(count * Constants.DEG_TO_RAD, rotated.Yaw, 12 * Constants.EPSILON, "0-180 Yaw is " + rotated.Yaw * Constants.RAD_TO_DEG);
259 }
260 for (; count <= 360; count++) {
261 rotator.SetRotation(axis, count * Constants.DEG_TO_RAD);
262 Vector rotated = rotator.TransformDirection(vec);
263 Assert.AreEqual((-360 + count) * Constants.DEG_TO_RAD, rotated.Yaw, 12 * Constants.EPSILON, "180-360 Yaw is " + rotated.Yaw * Constants.RAD_TO_DEG);
264 }
265 }
266
267 [Test()]
268 public void Vector_Roll() {
269 // If the vector points to the left of the y-axis, then the returned angle is between 0 and pi radians (180 degrees); if it points to the right, the angle is between 0 and -pi radians.
270 Matrix rotator = Matrix.Identity;
271 Vector baseVec = Vector.Down;
272 Vector vec = new Vector(baseVec);
273 Vector axis = -Vector.ZAxis;
274 int count = 0;
275 for (; count < 180; count++) {
276 rotator.SetRotation(axis, count * Constants.DEG_TO_RAD);
277 Vector rotated = rotator.TransformDirection(vec);
278 Assert.AreEqual(count * Constants.DEG_TO_RAD, rotated.Roll, 12 * Constants.EPSILON, "0-180 Roll is " + rotated.Roll * Constants.RAD_TO_DEG);
279 }
280 for (; count <= 360; count++) {
281 rotator.SetRotation(axis, count * Constants.DEG_TO_RAD);
282 Vector rotated = rotator.TransformDirection(vec);
283 Assert.AreEqual((-360 + count) * Constants.DEG_TO_RAD, rotated.Roll, 12 * Constants.EPSILON, "180-360 Roll is " + rotated.Roll * Constants.RAD_TO_DEG);
284 }
285 }
286
287 [Test()]
288 public void Vector_Dot() {
289 Assert.AreEqual(0, Vector.Up.Dot(Vector.Forward), "Orthogonal");
290 Assert.AreEqual(1, Vector.Up.Dot(Vector.Up), "Parallel");
291 Assert.AreEqual(-1, Vector.Up.Dot(Vector.Down), "Opposite");
292 Assert.AreEqual(1, Vector.Backward.Dot(new Vector(0, 1, 1)), "Hypoteneuse of right isoscelese");
293 Assert.AreEqual((float)Math.Sqrt(2) / 2, Vector.Backward.Dot(new Vector(0, 1, 1).Normalized), "45 degree unit vectors");
294 }
295
296 [Test()]
297 public void Vector_Cross() {
298 Vector v1 = new Vector(1, 2, 3);
299 Vector v2 = new Vector(3, 2, 1);
300 Vector expected = new Vector(-4, 8, -4);
301 Assert.AreEqual(expected, v1.Cross(v2), "v1 x v2");
302 Assert.AreEqual(-expected, v2.Cross(v1), "v1 x v2");
303 Assert.AreEqual(0, v1.Dot(v1.Cross(v2)), "Orthogonal with v1");
304 Assert.AreEqual(0, v2.Dot(v1.Cross(v2)), "Orthogonal with v2");
305
306 }
307
308 [Test()]
309 public void Vector_Normalized() {
310 Vector v1 = new Vector(1, 2, 3);
311 Vector v2 = new Vector(0, 0, 0);
312 Vector v3 = new Vector(-4, 8, -4);
313 Vector v4 = new Vector(99999999, 99999999, 99999999);
314 Vector v5 = new Vector(-99999999, -99999999, -99999999);
315 Assert.AreEqual(1.0f, v1.Normalized.Magnitude, Constants.EPSILON, "small");
316 Assert.AreEqual(0.0f, v2.Normalized.Magnitude, Constants.EPSILON, "zero");
317 Assert.AreEqual(1.0f, v3.Normalized.Magnitude, Constants.EPSILON, "small negative");
318 Assert.AreEqual(1.0f, v4.Normalized.Magnitude, Constants.EPSILON, "large");
319 Assert.AreEqual(1.0f, v5.Normalized.Magnitude, Constants.EPSILON, "large negative");
320 }
321
322 [Test()]
323 public void Vector_Plus() {
324 Vector v1 = new Vector(1, 2, 3);
325 Vector v2 = new Vector(-4, 8, -4);
326 Assert.AreEqual(new Vector(-3, 10, -1), v1 + v2);
327 }
328
329 [Test()]
330 public void Vector_Minus() {
331 Vector v1 = new Vector(1, 2, 3);
332 Vector v2 = new Vector(-4, 8, -4);
333 Assert.AreEqual(new Vector(5, -6, 7), v1 - v2);
334 }
335
336 [Test()]
337 public void Vector_Negate() {
338 Vector v1 = new Vector(1, 2, -3);
339 Assert.AreEqual(new Vector(-1, -2, 3), -v1);
340 }
341
342 [Test()]
343 public void Vector_Times() {
344 Vector v1 = new Vector(1, 2, -3);
345 Assert.AreEqual(new Vector(5.2f, 10.4f, -15.6f), (v1 * 5.2f));
346 }
347
348 [Test()]
349 public void Vector_Divide() {
350 Vector v1 = new Vector(25, 150, -300);
351 Assert.AreEqual(new Vector(5f, 30f, -60f), (v1 / 5.0f));
352 }
353
354 [Test()]
355 public void Vector_Equals() {
356 Vector v1 = new Vector(1, 2, 3);
357 Vector v2 = new Vector(0, 0, 0);
358 Vector v3 = new Vector(1, 2, 3);
359 Assert.IsTrue(v1.Equals(v3), "simple integers 1");
360 Assert.IsTrue(v3.Equals(v1), "simple integers 2");
361 Assert.IsTrue(v1.Equals(v1), "simple integers 3");
362 Assert.IsTrue(v1 == v3, "simple integers 4");
363 Assert.IsTrue(v3 == v1, "simple integers 5");
364 Assert.IsFalse(v1.Equals(v2), "simple integers 6");
365 Assert.IsFalse(v2.Equals(v1), "simple integers 7");
366 Assert.IsFalse(v1 == v2, "simple integers 8");
367 Assert.IsFalse(v2 == v1, "simple integers 9");
368
369 Vector v4 = new Vector(float.MinValue, float.MinValue, float.MinValue);
370 Vector v5 = new Vector(float.MinValue, float.MinValue, float.MinValue);
371 Assert.IsTrue(v4 == v5, "MinValue");
372
373 Vector v6 = new Vector(float.MaxValue, float.MaxValue, float.MaxValue);
374 Vector v7 = new Vector(float.MaxValue, float.MaxValue, float.MaxValue);
375 Assert.IsTrue(v6 == v7, "MaxValue");
376
377 Vector v8 = new Vector(float.Epsilon, float.Epsilon, float.Epsilon);
378 Vector v9 = new Vector(float.Epsilon, float.Epsilon, float.Epsilon);
379 Assert.IsTrue(v8 == v9, "Epsilon");
380
381 Vector v10 = new Vector(float.PositiveInfinity, float.PositiveInfinity, float.NegativeInfinity);
382 Vector v11 = new Vector(float.PositiveInfinity, float.PositiveInfinity, float.NegativeInfinity);
383 Assert.IsTrue(v10 == v11, "Infinity");
384
385 Vector v12 = new Vector(float.NaN, float.NaN, float.NaN);
386 Vector v13 = new Vector(float.NaN, float.NaN, float.NaN);
387 Assert.IsFalse(v12 == v13, "NaN");
388
389 Vector v14 = new Vector(5 + float.Epsilon, -124.34f + float.Epsilon, float.MaxValue - float.Epsilon);
390 Vector v15 = new Vector(5 - float.Epsilon, -124.34f - float.Epsilon, float.MaxValue);
391 Assert.IsTrue(v14 == v15, "+- Epsilon");
392
393 Vector v16 = new Vector(5 + Constants.EPSILON, -124.34f + Constants.EPSILON, float.MaxValue - Constants.EPSILON);
394 Vector v17 = new Vector(5 - Constants.EPSILON, -124.34f - Constants.EPSILON, float.MaxValue);
395 Assert.IsTrue(v16 == v17, "+- Leap Epsilon");
396
397 float epsilonMultiplier = 11; //TODO figure out why this error is so high
398 Vector v18 = new Vector(5 + Constants.EPSILON * epsilonMultiplier, -124.34f + Constants.EPSILON * epsilonMultiplier, float.MaxValue - Constants.EPSILON * epsilonMultiplier);
399 Vector v19 = new Vector(5, -124.34f, float.MaxValue);
400 Assert.IsFalse(v18 == v19, "Diff > Leap Epsilon");
401
402 }
403
404 [Test()]
405 public void Vector_NotEqual() {
406 // !!!Vector_NotEqual
407 bool vectorsNotEqual = thisVector != thatVector;
408 // !!!END
409 Assert.IsTrue(vectorsNotEqual);
410 }
411
412 [Test()]
413 public void Vector_IsValid() {
414 Vector xInvalid = new Vector(float.NaN, 3f, 45f);
415 Assert.IsFalse(xInvalid.IsValid());
416 Vector yInvalid = new Vector(32.1f, float.NaN, 45f);
417 Assert.IsFalse(yInvalid.IsValid());
418 Vector zInvalid = new Vector(-345.32f, -78.67f, float.NaN);
419 Assert.IsFalse(zInvalid.IsValid());
420 Vector xInfinite = new Vector(float.PositiveInfinity, 3f, 45f);
421 Assert.IsFalse(xInfinite.IsValid());
422 Vector yInfinite = new Vector(-23.7f, float.NegativeInfinity, 3f);
423 Assert.IsFalse(yInfinite.IsValid());
424 Vector zInfinite = new Vector(3f, 45f, float.PositiveInfinity);
425 Assert.IsFalse(zInfinite.IsValid());
426 Vector mixed = new Vector(float.NaN, float.NegativeInfinity, float.PositiveInfinity);
427 Assert.IsFalse(mixed.IsValid());
428 }
429 }
430}
431
Es.InkPainter.Math Math
Definition: PaintTest.cs:7
The Matrix struct represents a transformation matrix.
Definition: Matrix.cs:23
void SetRotation(Vector axis, float angleRadians)
Sets this transformation matrix to represent a rotation around the specified vector.
Definition: Matrix.cs:230
static readonly Matrix Identity
Returns the identity matrix specifying no translation, rotation, and scale.
Definition: Matrix.cs:337
Vector TransformDirection(Vector direction)
Transforms a vector with this matrix by transforming its rotation and scale only.
Definition: Matrix.cs:258
The Vector struct represents a three-component mathematical vector or point such as a direction or po...
Definition: Vector.cs:36
static readonly Vector Zero
The zero vector: (0, 0, 0)
Definition: Vector.cs:313
Vector Normalized
A normalized copy of this vector.
Definition: Vector.cs:299
static readonly Vector ZAxis
The z-axis unit vector: (0, 0, 1)
Definition: Vector.cs:333
static readonly Vector Forward
The unit vector pointing forward along the negative z-axis: (0, 0, -1)
Definition: Vector.cs:338
float y
Definition: Vector.cs:219
float AngleTo(Vector other)
The angle between this vector and the specified vector in radians.
Definition: Vector.cs:120
static readonly Vector Down
The unit vector pointing down along the negative y-axis: (0, -1, 0)
Definition: Vector.cs:363
static readonly Vector Left
The unit vector pointing left along the negative x-axis: (-1, 0, 0)
Definition: Vector.cs:348
float Dot(Vector other)
The dot product of this vector with another vector.
Definition: Vector.cs:141
float DistanceTo(Vector other)
The distance between the point represented by this Vector object and a point represented by the speci...
Definition: Vector.cs:102
static readonly Vector Right
The unit vector pointing right along the positive x-axis: (1, 0, 0)
Definition: Vector.cs:353
float x
Definition: Vector.cs:218
bool IsValid()
Returns true if all of the vector's components are finite. If any component is NaN or infinite,...
Definition: Vector.cs:186
bool Equals(Vector v)
Compare Vector equality component-wise.
Definition: Vector.cs:173
static readonly Vector YAxis
The y-axis unit vector: (0, 1, 0)
Definition: Vector.cs:328
float Yaw
The yaw angle in radians.
Definition: Vector.cs:287
float Pitch
The pitch angle in radians.
Definition: Vector.cs:252
Vector Cross(Vector other)
The cross product of this vector and the specified vector.
Definition: Vector.cs:155
static readonly Vector XAxis
The x-axis unit vector: (1, 0, 0)
Definition: Vector.cs:323
static readonly Vector Backward
The unit vector pointing backward along the positive z-axis: (0, 0, 1)
Definition: Vector.cs:343
static readonly Vector Up
The unit vector pointing up along the positive y-axis: (0, 1, 0)
Definition: Vector.cs:358
float MagnitudeSquared
The square of the magnitude, or length, of this vector.
Definition: Vector.cs:237
float Roll
The roll angle in radians.
Definition: Vector.cs:272
float z
Definition: Vector.cs:220
float Magnitude
The magnitude, or length, of this vector.
Definition: Vector.cs:229