Jypeli 10
The simple game programming library
Vector4D.cs
Siirry tämän tiedoston dokumentaatioon.
1#region MIT License
2/*
3 * Copyright (c) 2005-2008 Jonathan Mark Porter. http://physics2d.googlepages.com/
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17 * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22#endregion
23
24
25#if UseDouble
26using Scalar = System.Double;
27#else
28using Scalar = System.Single;
29#endif
30using System;
31using System.Runtime.InteropServices;
33using System.Xml.Serialization;
34namespace AdvanceMath
35{
40 //[StructLayout(LayoutKind.Sequential), Serializable]
41 [StructLayout(LayoutKind.Sequential, Size = Vector4D.Size)]
42 [AdvBrowsableOrder("X,Y,Z,W")]
43#if !CompactFramework && !WindowsCE && !PocketPC && !XBOX360 && !SILVERLIGHT && !WINDOWS_PHONE && !NETFX_CORE
44 [Serializable]
45 [System.ComponentModel.TypeConverter(typeof(AdvTypeConverter<Vector4D>))]
46#endif
47 public struct Vector4D : IVector<Vector4D>
48 {
49 #region const fields
53 public const int Count = 4;
57 public const int Size = sizeof(Scalar) * Count;
58 #endregion
59 #region readonly fields
63 public static readonly Vector4D One = new Vector4D(1, 1, 1, 1);
67 public static readonly Vector4D Zero = new Vector4D();
71 public static readonly Vector4D XAxis = new Vector4D(1, 0, 0, 0);
75 public static readonly Vector4D YAxis = new Vector4D(0, 1, 0, 0);
79 public static readonly Vector4D ZAxis = new Vector4D(0, 0, 1, 0);
83 public static readonly Vector4D WAxis = new Vector4D(0, 0, 0, 1);
84
85 private static readonly string FormatString = MatrixHelper.CreateVectorFormatString(Count);
87
88 #endregion
89 #region static methods
90 public static void Copy(ref Vector4D vector, Scalar[] destArray)
91 {
92 Copy(ref vector, destArray, 0);
93 }
94 public static void Copy(ref Vector4D vector, Scalar[] destArray, int index)
95 {
96 ThrowHelper.CheckCopy(destArray, index, Count);
97
98 destArray[index] = vector.X;
99 destArray[++index] = vector.Y;
100 destArray[++index] = vector.Z;
101 destArray[++index] = vector.W;
102 }
103 public static void Copy(Scalar[] sourceArray, out Vector4D result)
104 {
105 Copy(sourceArray, 0, out result);
106 }
107 public static void Copy(Scalar[] sourceArray, int index, out Vector4D result)
108 {
109 ThrowHelper.CheckCopy(sourceArray, index, Count);
110
111 result.X = sourceArray[index];
112 result.Y = sourceArray[++index];
113 result.Z = sourceArray[++index];
114 result.W = sourceArray[++index];
115 }
116 public static void Copy(ref Vector3D source, ref Vector4D dest)
117 {
118 dest.X = source.X;
119 dest.Y = source.Y;
120 dest.Z = source.Z;
121 }
122 public static void Copy(ref Vector2D source, ref Vector4D dest)
123 {
124 dest.X = source.X;
125 dest.Y = source.Y;
126 }
127
128 public static Vector4D Clamp(Vector4D value, Vector4D min, Vector4D max)
129 {
130 Vector4D result;
131 MathHelper.Clamp(ref value.X, ref min.X, ref max.X, out result.X);
132 MathHelper.Clamp(ref value.Y, ref min.Y, ref max.Y, out result.Y);
133 MathHelper.Clamp(ref value.Z, ref min.Z, ref max.Z, out result.Z);
134 MathHelper.Clamp(ref value.W, ref min.W, ref max.W, out result.W);
135 return result;
136 }
137 public static void Clamp(ref Vector4D value, ref Vector4D min, ref Vector4D max, out Vector4D result)
138 {
139 MathHelper.Clamp(ref value.X, ref min.X, ref max.X, out result.X);
140 MathHelper.Clamp(ref value.Y, ref min.Y, ref max.Y, out result.Y);
141 MathHelper.Clamp(ref value.Z, ref min.Z, ref max.Z, out result.Z);
142 MathHelper.Clamp(ref value.W, ref min.W, ref max.W, out result.W);
143 }
144
145
146 public static Vector4D Lerp(Vector4D left, Vector4D right, Scalar amount)
147 {
148 Vector4D result;
149 Lerp(ref left, ref right, ref amount, out result);
150 return result;
151 }
152 public static void Lerp(ref Vector4D left, ref Vector4D right, ref Scalar amount, out Vector4D result)
153 {
154 result.X = (right.X - left.X) * amount + left.X;
155 result.Y = (right.Y - left.Y) * amount + left.Y;
156 result.Z = (right.Z - left.Z) * amount + left.Z;
157 result.W = (right.W - left.W) * amount + left.W;
158 }
159 public static Vector4D Lerp(Vector4D left, Vector4D right, Vector4D amount)
160 {
161 Vector4D result;
162 Lerp(ref left, ref right, ref amount, out result);
163 return result;
164 }
165 public static void Lerp(ref Vector4D left, ref Vector4D right, ref Vector4D amount, out Vector4D result)
166 {
167 result.X = (right.X - left.X) * amount.X + left.X;
168 result.Y = (right.Y - left.Y) * amount.Y + left.Y;
169 result.Z = (right.Z - left.Z) * amount.Z + left.Z;
170 result.W = (right.W - left.W) * amount.W + left.W;
171 }
172
173 public static Scalar Distance(Vector4D left, Vector4D right)
174 {
175 Scalar result;
176 Distance(ref left, ref right, out result);
177 return result;
178 }
179 public static void Distance(ref Vector4D left, ref Vector4D right, out Scalar result)
180 {
181 Vector4D diff;
182 Subtract(ref left, ref right, out diff);
183 GetMagnitude(ref diff, out result);
184 }
185 public static Scalar DistanceSq(Vector4D left, Vector4D right)
186 {
187 Scalar result;
188 DistanceSq(ref left, ref right, out result);
189 return result;
190 }
191 public static void DistanceSq(ref Vector4D left, ref Vector4D right, out Scalar result)
192 {
193 Vector4D diff;
194 Subtract(ref left, ref right, out diff);
195 GetMagnitudeSq(ref diff, out result);
196 }
197
205 public static Vector4D Add(Vector4D left, Vector4D right)
206 {
207 Vector4D result;
208 result.X = left.X + right.X;
209 result.Y = left.Y + right.Y;
210 result.Z = left.Z + right.Z;
211 result.W = left.W + right.W;
212 return result;
213 }
214 public static void Add(ref Vector4D left, ref Vector4D right, out Vector4D result)
215 {
216 result.X = left.X + right.X;
217 result.Y = left.Y + right.Y;
218 result.Z = left.Z + right.Z;
219 result.W = left.W + right.W;
220 }
221
222 public static Vector4D Add(Vector3D left, Vector4D right)
223 {
224 Vector4D result;
225 Add(ref left, ref right, out result);
226 return result;
227 }
228 public static void Add(ref Vector3D left, ref Vector4D right, out Vector4D result)
229 {
230 result.X = left.X + right.X;
231 result.Y = left.Y + right.Y;
232 result.Z = left.Z + right.Z;
233 result.W = right.W;
234 }
235 public static Vector4D Add(Vector2D left, Vector4D right)
236 {
237 Vector4D result;
238 Add(ref left, ref right, out result);
239 return result;
240 }
241 public static void Add(ref Vector2D left, ref Vector4D right, out Vector4D result)
242 {
243 result.X = left.X + right.X;
244 result.Y = left.Y + right.Y;
245 result.Z = right.Z;
246 result.W = right.W;
247 }
248 public static Vector4D Add(Vector4D left, Vector3D right)
249 {
250 Vector4D result;
251 Add(ref left, ref right, out result);
252 return result;
253 }
254 public static void Add(ref Vector4D left, ref Vector3D right, out Vector4D result)
255 {
256 result.X = left.X + right.X;
257 result.Y = left.Y + right.Y;
258 result.Z = left.Z + right.Z;
259 result.W = left.W;
260 }
261 public static Vector4D Add(Vector4D left, Vector2D right)
262 {
263 Vector4D result;
264 Add(ref left, ref right, out result);
265 return result;
266 }
267 public static void Add(ref Vector4D left, ref Vector2D right, out Vector4D result)
268 {
269 result.X = left.X + right.X;
270 result.Y = left.Y + right.Y;
271 result.Z = left.Z;
272 result.W = left.W;
273 }
274
275
276
284 public static Vector4D Subtract(Vector4D left, Vector4D right)
285 {
286 Vector4D result;
287 result.X = left.X - right.X;
288 result.Y = left.Y - right.Y;
289 result.Z = left.Z - right.Z;
290 result.W = left.W - right.W;
291 return result;
292 }
293 public static void Subtract(ref Vector4D left, ref Vector4D right, out Vector4D result)
294 {
295 result.X = left.X - right.X;
296 result.Y = left.Y - right.Y;
297 result.Z = left.Z - right.Z;
298 result.W = left.W - right.W;
299 }
300
301
302 public static Vector4D Subtract(Vector3D left, Vector4D right)
303 {
304 Vector4D result;
305 Subtract(ref left, ref right, out result);
306 return result;
307 }
308 public static void Subtract(ref Vector3D left, ref Vector4D right, out Vector4D result)
309 {
310 result.X = left.X - right.X;
311 result.Y = left.Y - right.Y;
312 result.Z = left.Z - right.Z;
313 result.W = -right.W;
314 }
315 public static Vector4D Subtract(Vector2D left, Vector4D right)
316 {
317 Vector4D result;
318 Subtract(ref left, ref right, out result);
319 return result;
320 }
321 public static void Subtract(ref Vector2D left, ref Vector4D right, out Vector4D result)
322 {
323 result.X = left.X - right.X;
324 result.Y = left.Y - right.Y;
325 result.Z = -right.Z;
326 result.W = -right.W;
327 }
328 public static Vector4D Subtract(Vector4D left, Vector3D right)
329 {
330 Vector4D result;
331 Subtract(ref left, ref right, out result);
332 return result;
333 }
334 public static void Subtract(ref Vector4D left, ref Vector3D right, out Vector4D result)
335 {
336 result.X = left.X - right.X;
337 result.Y = left.Y - right.Y;
338 result.Z = left.Z - right.Z;
339 result.W = left.W;
340 }
341 public static Vector4D Subtract(Vector4D left, Vector2D right)
342 {
343 Vector4D result;
344 Subtract(ref left, ref right, out result);
345 return result;
346 }
347 public static void Subtract(ref Vector4D left, ref Vector2D right, out Vector4D result)
348 {
349 result.X = left.X - right.X;
350 result.Y = left.Y - right.Y;
351 result.Z = left.Z;
352 result.W = left.W;
353 }
354
355
363 public static Vector4D Multiply(Vector4D source, Scalar scalar)
364 {
365 Vector4D result;
366 result.X = source.X * scalar;
367 result.Y = source.Y * scalar;
368 result.Z = source.Z * scalar;
369 result.W = source.W * scalar;
370 return result;
371 }
372 public static void Multiply(ref Vector4D source, ref Scalar scalar, out Vector4D result)
373 {
374 result.X = source.X * scalar;
375 result.Y = source.Y * scalar;
376 result.Z = source.Z * scalar;
377 result.W = source.W * scalar;
378 }
386 public static Vector4D Multiply(Scalar scalar, Vector4D source)
387 {
388 Vector4D result;
389 result.X = scalar * source.X;
390 result.Y = scalar * source.Y;
391 result.Z = scalar * source.Z;
392 result.W = scalar * source.W;
393 return result;
394 }
395 public static void Multiply(ref Scalar scalar, ref Vector4D source, out Vector4D result)
396 {
397 result.X = scalar * source.X;
398 result.Y = scalar * source.Y;
399 result.Z = scalar * source.Z;
400 result.W = scalar * source.W;
401 }
402
403 public static Vector4D Transform(Matrix4x4 matrix, Vector4D vector)
404 {
405 Vector4D result;
406
407 result.X = vector.X * matrix.m00 + vector.Y * matrix.m01 + vector.Z * matrix.m02 + vector.W * matrix.m03;
408 result.Y = vector.X * matrix.m10 + vector.Y * matrix.m11 + vector.Z * matrix.m12 + vector.W * matrix.m13;
409 result.Z = vector.X * matrix.m20 + vector.Y * matrix.m21 + vector.Z * matrix.m22 + vector.W * matrix.m23;
410 result.W = vector.X * matrix.m30 + vector.Y * matrix.m31 + vector.Z * matrix.m32 + vector.W * matrix.m33;
411
412 return result;
413 }
414 public static void Transform(ref Matrix4x4 matrix, ref Vector4D vector, out Vector4D result)
415 {
416 Scalar X = vector.X;
417 Scalar Y = vector.Y;
418 Scalar Z = vector.Z;
419 result.X = X * matrix.m00 + Y * matrix.m01 + Z * matrix.m02 + vector.W * matrix.m03;
420 result.Y = X * matrix.m10 + Y * matrix.m11 + Z * matrix.m12 + vector.W * matrix.m13;
421 result.Z = X * matrix.m20 + Y * matrix.m21 + Z * matrix.m22 + vector.W * matrix.m23;
422 result.W = X * matrix.m30 + Y * matrix.m31 + Z * matrix.m32 + vector.W * matrix.m33;
423 }
424
425 public static Vector4D Transform(Vector4D vector, Matrix4x4 matrix)
426 {
427 Vector4D result;
428
429 result.X = vector.X * matrix.m00 + vector.Y * matrix.m10 + vector.Z * matrix.m20 + vector.W * matrix.m30;
430 result.Y = vector.X * matrix.m01 + vector.Y * matrix.m11 + vector.Z * matrix.m21 + vector.W * matrix.m31;
431 result.Z = vector.X * matrix.m02 + vector.Y * matrix.m12 + vector.Z * matrix.m22 + vector.W * matrix.m32;
432 result.W = vector.X * matrix.m03 + vector.Y * matrix.m13 + vector.Z * matrix.m23 + vector.W * matrix.m33;
433
434 return result;
435 }
436 public static void Transform(ref Vector4D vector, ref Matrix4x4 matrix, out Vector4D result)
437 {
438 Scalar X = vector.X;
439 Scalar Y = vector.Y;
440 Scalar Z = vector.Z;
441 result.X = X * matrix.m00 + Y * matrix.m10 + Z * matrix.m20 + vector.W * matrix.m30;
442 result.Y = X * matrix.m01 + Y * matrix.m11 + Z * matrix.m21 + vector.W * matrix.m31;
443 result.Z = X * matrix.m02 + Y * matrix.m12 + Z * matrix.m22 + vector.W * matrix.m32;
444 result.W = X * matrix.m03 + Y * matrix.m13 + Z * matrix.m23 + vector.W * matrix.m33;
445 }
446
454 public static Scalar Dot(Vector4D left, Vector4D right)
455 {
456 return left.Y * right.Y + left.X * right.X + left.Z * right.Z + left.W * right.W;
457 }
458 public static void Dot(ref Vector4D left, ref Vector4D right, out Scalar result)
459 {
460 result = left.Y * right.Y + left.X * right.X + left.Z * right.Z + left.W * right.W;
461 }
467 public static Scalar GetMagnitudeSq(Vector4D source)
468 {
469 return source.X * source.X + source.Y * source.Y + source.Z * source.Z + source.W * source.W;
470 }
471 public static void GetMagnitudeSq(ref Vector4D source, out Scalar result)
472 {
473 result = source.X * source.X + source.Y * source.Y + source.Z * source.Z + source.W * source.W;
474 }
480 public static Scalar GetMagnitude(Vector4D source)
481 {
482 return MathHelper.Sqrt(source.X * source.X + source.Y * source.Y + source.Z * source.Z + source.W * source.W);
483 }
484 public static void GetMagnitude(ref Vector4D source, out Scalar result)
485 {
486 result = MathHelper.Sqrt(source.X * source.X + source.Y * source.Y + source.Z * source.Z + source.W * source.W);
487 }
494 public static Vector4D SetMagnitude(Vector4D source, Scalar magnitude)
495 {
496 Vector4D result;
497 SetMagnitude(ref source, ref magnitude, out result);
498 return result;
499 }
500 public static void SetMagnitude(ref Vector4D source, ref Scalar magnitude, out Vector4D result)
501 {
502 Scalar oldmagnitude;
503 GetMagnitude(ref source, out oldmagnitude);
504 if (oldmagnitude > 0 && magnitude != 0)
505 {
506 oldmagnitude = (magnitude / oldmagnitude);
507 Multiply(ref source, ref oldmagnitude, out result);
508 }
509 else
510 {
511 result = Zero;
512 }
513 }
519 public static Vector4D Negate(Vector4D source)
520 {
521 Vector4D result;
522 result.X = -source.X;
523 result.Y = -source.Y;
524 result.Z = -source.Z;
525 result.W = -source.W;
526 return result;
527 }
528 public static void Negate(ref Vector4D source)
529 {
530 Negate(ref source, out source);
531 }
532 public static void Negate(ref Vector4D source, out Vector4D result)
533 {
534 result.X = -source.X;
535 result.Y = -source.Y;
536 result.Z = -source.Z;
537 result.W = -source.W;
538 }
545 public static Vector4D Normalize(Vector4D source)
546 {
547 Scalar oldmagnitude;
548 GetMagnitude(ref source, out oldmagnitude);
549 if (oldmagnitude == 0) { return Zero; }
550 oldmagnitude = (1 / oldmagnitude);
551 Vector4D result;
552 result.X = source.X * oldmagnitude;
553 result.Y = source.Y * oldmagnitude;
554 result.Z = source.Z * oldmagnitude;
555 result.W = source.W * oldmagnitude;
556 return result;
557 }
558 public static void Normalize(ref Vector4D source, out Vector4D result)
559 {
560 Scalar oldmagnitude;
561 GetMagnitude(ref source, out oldmagnitude);
562 if (oldmagnitude == 0) { result = Zero; return; }
563 oldmagnitude = (1 / oldmagnitude);
564 result.X = source.X * oldmagnitude;
565 result.Y = source.Y * oldmagnitude;
566 result.Z = source.Z * oldmagnitude;
567 result.W = source.W * oldmagnitude;
568 }
569 public static void Normalize(ref Vector4D source)
570 {
571 Normalize(ref source, out source);
572 }
580 public static Vector4D Project(Vector4D left, Vector4D right)
581 {
582 Vector4D result;
583 Project(ref left, ref right, out result);
584 return result;
585 }
586 public static void Project(ref Vector4D left, ref Vector4D right, out Vector4D result)
587 {
588 Scalar tmp, magsq;
589 Dot(ref left, ref right, out tmp);
590 GetMagnitudeSq(ref right, out magsq);
591 tmp /= magsq;
592 Multiply(ref right, ref tmp, out result);
593 }
594
595
596
597 public static Vector4D TripleCross(Vector4D top, Vector4D middle, Vector4D bottom)
598 {
599 Vector4D result;
600
601 result.X = Matrix3x3.GetDeterminant(
602 top.Y, top.Z, top.W,
603 middle.Y, middle.Z, middle.W,
604 bottom.Y, bottom.Z, bottom.W);
605
606 result.Y = -Matrix3x3.GetDeterminant(
607 top.X, top.Z, top.W,
608 middle.X, middle.Z, middle.W,
609 bottom.X, bottom.Z, bottom.W);
610
611 result.Z = Matrix3x3.GetDeterminant(
612 top.X, top.Y, top.W,
613 middle.X, middle.Y, middle.W,
614 bottom.X, bottom.Y, bottom.W);
615
616 result.W = -Matrix3x3.GetDeterminant(
617 top.X, top.Y, top.Z,
618 middle.X, middle.Y, middle.Z,
619 bottom.X, bottom.Y, bottom.Z);
620
621 return result;
622 }
623
624 public static Vector4D CatmullRom( Vector4D value1, Vector4D value2, Vector4D value3, Vector4D value4, Scalar amount)
625 {
626 Vector4D result;
627 CatmullRom(ref value1, ref value2, ref value3, ref value4, amount, out result);
628 return result;
629 }
630 public static void CatmullRom(ref Vector4D value1, ref Vector4D value2, ref Vector4D value3, ref Vector4D value4, Scalar amount, out Vector4D result)
631 {
632 Scalar amountSq = amount * amount;
633 Scalar amountCu = amountSq * amount;
634 result.X =
635 0.5f * ((2 * value2.X) +
636 (-value1.X + value3.X) * amount +
637 (2 * value1.X - 5 * value2.X + 4 * value3.X - value4.X) * amountSq +
638 (-value1.X + 3 * value2.X - 3 * value3.X + value4.X) * amountCu);
639 result.Y =
640 0.5f * ((2 * value2.Y) +
641 (-value1.Y + value3.Y) * amount +
642 (2 * value1.Y - 5 * value2.Y + 4 * value3.Y - value4.Y) * amountSq +
643 (-value1.Y + 3 * value2.Y - 3 * value3.Y + value4.Y) * amountCu);
644 result.Z =
645 0.5f * ((2 * value2.Z) +
646 (-value1.Z + value3.Z) * amount +
647 (2 * value1.Z - 5 * value2.Z + 4 * value3.Z - value4.Z) * amountSq +
648 (-value1.Z + 3 * value2.Z - 3 * value3.Z + value4.Z) * amountCu);
649 result.W =
650 0.5f * ((2 * value2.W) +
651 (-value1.W + value3.W) * amount +
652 (2 * value1.W - 5 * value2.W + 4 * value3.W - value4.W) * amountSq +
653 (-value1.W + 3 * value2.W - 3 * value3.W + value4.W) * amountCu);
654 }
655
656 public static Vector4D Max(Vector4D value1, Vector4D value2)
657 {
658 Vector4D result;
659 Max(ref value1, ref value2, out result);
660 return result;
661 }
662 public static void Max(ref Vector4D value1,ref Vector4D value2,out Vector4D result)
663 {
664 result.X = (value1.X < value2.X) ? (value2.X) : (value1.X);
665 result.Y = (value1.Y < value2.Y) ? (value2.Y) : (value1.Y);
666 result.Z = (value1.Z < value2.Z) ? (value2.Z) : (value1.Z);
667 result.W = (value1.W < value2.W) ? (value2.W) : (value1.W);
668 }
669
670 public static Vector4D Min(Vector4D value1, Vector4D value2)
671 {
672 Vector4D result;
673 Min(ref value1, ref value2, out result);
674 return result;
675 }
676 public static void Min(ref Vector4D value1, ref Vector4D value2, out Vector4D result)
677 {
678 result.X = (value1.X > value2.X) ? (value2.X) : (value1.X);
679 result.Y = (value1.Y > value2.Y) ? (value2.Y) : (value1.Y);
680 result.Z = (value1.Z > value2.Z) ? (value2.Z) : (value1.Z);
681 result.W = (value1.W > value2.W) ? (value2.W) : (value1.W);
682 }
683
684 public static Vector4D Hermite(Vector4D value1, Vector4D tangent1, Vector4D value2, Vector4D tangent2, Scalar amount)
685 {
686 Vector4D result;
687 Hermite(ref value1, ref tangent1, ref value2, ref tangent2, amount, out result);
688 return result;
689 }
690 public static void Hermite(ref Vector4D value1, ref Vector4D tangent1, ref Vector4D value2, ref Vector4D tangent2, Scalar amount, out Vector4D result)
691 {
692 Scalar h1, h2, h3, h4;
693 MathHelper.HermiteHelper(amount, out h1, out h2, out h3, out h4);
694 result.X = h1 * value1.X + h2 * value2.X + h3 * tangent1.X + h4 * tangent2.X;
695 result.Y = h1 * value1.Y + h2 * value2.Y + h3 * tangent1.Y + h4 * tangent2.Y;
696 result.Z = h1 * value1.Z + h2 * value2.Z + h3 * tangent1.Z + h4 * tangent2.Z;
697 result.W = h1 * value1.W + h2 * value2.W + h3 * tangent1.W + h4 * tangent2.W;
698 }
699
700 #endregion
701 #region fields
705 [AdvBrowsable]
706 [XmlAttribute]
707#if !WINDOWS_STOREAPP
708 [System.ComponentModel.Description("The Magnitude on the X-Axis")]
709#endif
710 public Scalar X;
714 [AdvBrowsable]
715 [XmlAttribute]
716#if !WINDOWS_STOREAPP
717 [System.ComponentModel.Description("The Magnitude on the Y-Axis")]
718#endif
719 public Scalar Y;
723 [AdvBrowsable]
724 [XmlAttribute]
725#if !WINDOWS_STOREAPP
726 [System.ComponentModel.Description("The Magnitude on the Z-Axis")]
727#endif
728 public Scalar Z;
732 [AdvBrowsable]
733 [XmlAttribute]
734#if !WINDOWS_STOREAPP
735 [System.ComponentModel.Description("The Magnitude on the W-Axis")]
736#endif
737 public Scalar W;
738
739 #endregion
740 #region constructors
748 [InstanceConstructor("X,Y,Z,W")]
750 {
751 this.X = X;
752 this.Y = Y;
753 this.Z = Z;
754 this.W = W;
755 }
756 public Vector4D(Scalar[] vals) : this(vals, 0) { }
757 public Vector4D(Scalar[] vals, int index)
758 {
759 Copy(vals, index, out this);
760 }
761 #endregion
762 #region indexers
763#if UNSAFE
771 public Scalar this[int index]
772 {
773 get
774 {
775 ThrowHelper.CheckIndex("index", index, Count);
776 unsafe
777 {
778 fixed (Scalar* ptr = &this.X)
779 {
780 return ptr[index];
781 }
782 }
783 }
784 set
785 {
786 ThrowHelper.CheckIndex("index", index, Count);
787 unsafe
788 {
789 fixed (Scalar* ptr = &this.X)
790 {
791 ptr[index] = value;
792 }
793 }
794 }
795 }
796#endif
797 #endregion
798 #region properties
799
800
805 [XmlIgnore]
807 {
808 get
809 {
810 return MathHelper.Sqrt(this.X * this.X + this.Y * this.Y + this.Z * this.Z + this.W * this.W);
811 }
812 set
813 {
814 this = SetMagnitude(this, value);
815 }
816 }
821 {
822 get
823 {
824 return this.X * this.X + this.Y * this.Y + this.Z * this.Z + this.W * this.W;
825 }
826 }
832 {
833 get
834 {
835 return Normalize(this);
836 }
837 }
841 int IAdvanceValueType.Count { get { return Count; } }
842 #endregion
843 #region public methods
844 public Scalar[] ToArray()
845 {
846 Scalar[] array = new Scalar[Count];
847 Copy(ref this, array, 0);
848 return array;
849 }
850 public void CopyFrom(Scalar[] array, int index)
851 {
852 Copy(array, index, out this);
853 }
854 public void CopyTo(Scalar[] array, int index)
855 {
856 Copy(ref this, array, index);
857 }
858 #endregion
859 #region operators
867 public static Vector4D operator +(Vector4D left, Vector4D right)
868 {
869 Vector4D result;
870 result.X = left.X + right.X;
871 result.Y = left.Y + right.Y;
872 result.Z = left.Z + right.Z;
873 result.W = left.W + right.W;
874 return result;
875 }
876 public static Vector4D operator +(Vector3D left, Vector4D right)
877 {
878 Vector4D result;
879 Add(ref left, ref right, out result);
880 return result;
881 }
882 public static Vector4D operator +(Vector2D left, Vector4D right)
883 {
884 Vector4D result;
885 Add(ref left, ref right, out result);
886 return result;
887 }
888 public static Vector4D operator +(Vector4D left, Vector3D right)
889 {
890 Vector4D result;
891 Add(ref left, ref right, out result);
892 return result;
893 }
894 public static Vector4D operator +(Vector4D left, Vector2D right)
895 {
896 Vector4D result;
897 Add(ref left, ref right, out result);
898 return result;
899 }
907 public static Vector4D operator -(Vector4D left, Vector4D right)
908 {
909 Vector4D result;
910 result.X = left.X - right.X;
911 result.Y = left.Y - right.Y;
912 result.Z = left.Z - right.Z;
913 result.W = left.W - right.W;
914 return result;
915 }
916 public static Vector4D operator -(Vector3D left, Vector4D right)
917 {
918 Vector4D result;
919 Subtract(ref left, ref right, out result);
920 return result;
921 }
922 public static Vector4D operator -(Vector2D left, Vector4D right)
923 {
924 Vector4D result;
925 Subtract(ref left, ref right, out result);
926 return result;
927 }
928 public static Vector4D operator -(Vector4D left, Vector3D right)
929 {
930 Vector4D result;
931 Subtract(ref left, ref right, out result);
932 return result;
933 }
934 public static Vector4D operator -(Vector4D left, Vector2D right)
935 {
936 Vector4D result;
937 Subtract(ref left, ref right, out result);
938 return result;
939 }
947 public static Vector4D operator *(Vector4D source, Scalar scalar)
948 {
949 Vector4D result;
950 result.X = source.X * scalar;
951 result.Y = source.Y * scalar;
952 result.Z = source.Z * scalar;
953 result.W = source.W * scalar;
954 return result;
955 }
963 public static Vector4D operator *(Scalar scalar, Vector4D source)
964 {
965 Vector4D result;
966 result.X = scalar * source.X;
967 result.Y = scalar * source.Y;
968 result.Z = scalar * source.Z;
969 result.W = scalar * source.W;
970 return result;
971 }
979 public static Scalar operator *(Vector4D left, Vector4D right)
980 {
981 return left.X * right.X + left.Y * right.Y + left.Z * right.Z + left.W * right.W;
982 }
983
984
985 public static Vector4D operator *(Matrix4x4 matrix, Vector4D vector)
986 {
987 Vector4D result;
988
989 result.X = vector.X * matrix.m00 + vector.Y * matrix.m01 + vector.Z * matrix.m02 + vector.W * matrix.m03;
990 result.Y = vector.X * matrix.m10 + vector.Y * matrix.m11 + vector.Z * matrix.m12 + vector.W * matrix.m13;
991 result.Z = vector.X * matrix.m20 + vector.Y * matrix.m21 + vector.Z * matrix.m22 + vector.W * matrix.m23;
992 result.W = vector.X * matrix.m30 + vector.Y * matrix.m31 + vector.Z * matrix.m32 + vector.W * matrix.m33;
993
994 return result;
995 }
996
997 public static Vector4D operator *(Vector4D vector, Matrix4x4 matrix)
998 {
999 Vector4D result;
1000
1001 result.X = vector.X * matrix.m00 + vector.Y * matrix.m10 + vector.Z * matrix.m20 + vector.W * matrix.m30;
1002 result.Y = vector.X * matrix.m01 + vector.Y * matrix.m11 + vector.Z * matrix.m21 + vector.W * matrix.m31;
1003 result.Z = vector.X * matrix.m02 + vector.Y * matrix.m12 + vector.Z * matrix.m22 + vector.W * matrix.m32;
1004 result.W = vector.X * matrix.m03 + vector.Y * matrix.m13 + vector.Z * matrix.m23 + vector.W * matrix.m33;
1005
1006 return result;
1007 }
1008
1014 public static Vector4D operator -(Vector4D source)
1015 {
1016 Vector4D result;
1017 result.X = -source.X;
1018 result.Y = -source.Y;
1019 result.Z = -source.Z;
1020 result.W = -source.W;
1021 return result;
1022 }
1029 public static bool operator ==(Vector4D left, Vector4D right)
1030 {
1031 return left.X == right.X && left.Y == right.Y && left.Z == right.Z && left.W == right.W;
1032 }
1039 public static bool operator !=(Vector4D left, Vector4D right)
1040 {
1041 return !(left.X == right.X && left.Y == right.Y && left.Z == right.Z && left.W == right.W);
1042 }
1043
1044
1045 public static explicit operator Vector4D(Vector3D source)
1046 {
1047 Vector4D result;
1048 result.X = source.X;
1049 result.Y = source.Y;
1050 result.Z = source.Z;
1051 result.W = 1;
1052 return result;
1053 }
1054
1055 #endregion
1056 #region overrides
1057 private string ToStringInternal(string FormatString)
1058 {
1059 return string.Format(FormatString, X, Y, Z, W);
1060 }
1061 public string ToString(string format)
1062 {
1063 return ToStringInternal(string.Format(FormatableString, format));
1064 }
1065 public override string ToString()
1066 {
1068 }
1069
1070
1071#if !CompactFramework && !WindowsCE && !PocketPC && !XBOX360 && !SILVERLIGHT
1072 public static bool TryParse(string s, out Vector4D result)
1073 {
1074 if (s == null)
1075 {
1076 result = Zero;
1077 return false;
1078 }
1079 string[] vals = ParseHelper.SplitStringVector(s);
1080 if (vals.Length != Count)
1081 {
1082 result = Zero;
1083 return false;
1084 }
1085 if (Scalar.TryParse(vals[0], out result.X) &&
1086 Scalar.TryParse(vals[1], out result.Y) &&
1087 Scalar.TryParse(vals[2], out result.Z) &&
1088 Scalar.TryParse(vals[3], out result.W))
1089 {
1090 return true;
1091 }
1092 else
1093 {
1094 result = Zero;
1095 return false;
1096 }
1097 }
1098#endif
1099 [ParseMethod]
1100 public static Vector4D Parse(string s)
1101 {
1102 if (s == null)
1103 {
1104 throw new ArgumentNullException("s");
1105 }
1106 string[] vals = ParseHelper.SplitStringVector(s);
1107 if (vals.Length != Count)
1108 {
1110 }
1111 Vector4D value;
1112 value.X = Scalar.Parse(vals[0]);
1113 value.Y = Scalar.Parse(vals[1]);
1114 value.Z = Scalar.Parse(vals[2]);
1115 value.W = Scalar.Parse(vals[3]);
1116 return value;
1117 }
1118
1119
1129 public override int GetHashCode()
1130 {
1131 return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode() ^ W.GetHashCode();
1132 }
1133
1140 public override bool Equals(object obj)
1141 {
1142 return (obj is Vector4D) && Equals((Vector4D)obj);
1143 }
1144 public bool Equals(Vector4D other)
1145 {
1146 return Equals(ref this, ref other);
1147 }
1148 public static bool Equals(Vector4D left, Vector4D right)
1149 {
1150 return
1151 left.X == right.X &&
1152 left.Y == right.Y &&
1153 left.Z == right.Z &&
1154 left.W == right.W;
1155 }
1156 public static bool Equals(ref Vector4D left, ref Vector4D right)
1157 {
1158 return
1159 left.X == right.X &&
1160 left.Y == right.Y &&
1161 left.Z == right.Z &&
1162 left.W == right.W;
1163 }
1164 #endregion
1165 }
1166}
System.Single Scalar
Definition: Clamped.cs:29
System.Single Scalar
Definition: Vector4D.cs:28
static Scalar Clamp(Scalar value, Scalar min, Scalar max)
Definition: MathHelper.cs:111
static Scalar Sqrt(Scalar d)
Definition: MathHelper.cs:314
static void HermiteHelper(Scalar amount, out Scalar h1, out Scalar h2, out Scalar h3, out Scalar h4)
Definition: MathHelper.cs:86
static string CreateVectorFormatableString(int Count)
Definition: MatrixHelper.cs:51
static string CreateVectorFormatString(int Count)
Definition: MatrixHelper.cs:47
static string[] SplitStringVector(string s)
Definition: ParseHelper.cs:39
static void ThrowVectorFormatException(string value, int count, string format)
Definition: ThrowHelper.cs:54
static void CheckCopy(Scalar[] array, int index, int count)
Definition: ThrowHelper.cs:35
int Count
Gets a 32-bit integer that represents the total number of elements in all the dimensions of IAdvanceV...
Definition: Interfaces.cs:41
A 3x3 matrix which can represent rotations around axes.
Definition: Matrix3x3.cs:62
static Scalar GetDeterminant(Matrix3x3 source)
Definition: Matrix3x3.cs:681
This is the Vector Class.
Definition: Vector2D.cs:50
A Vector with 3 dimensions.
Definition: Vector3D.cs:47
Scalar X
This is the X value.
Definition: Vector3D.cs:692
Scalar Y
This is the Y value.
Definition: Vector3D.cs:701
Scalar Z
This is the Z value.
Definition: Vector3D.cs:710
A Vector with 4 dimensions.
Definition: Vector4D.cs:48
static readonly Vector4D WAxis
Vector4D(0,0,0,1)
Definition: Vector4D.cs:83
static void Project(ref Vector4D left, ref Vector4D right, out Vector4D result)
Definition: Vector4D.cs:586
Scalar[] ToArray()
Definition: Vector4D.cs:844
static readonly Vector4D Zero
Vector4D(0,0,0,0)
Definition: Vector4D.cs:67
static void GetMagnitude(ref Vector4D source, out Scalar result)
Definition: Vector4D.cs:484
string ToString(string format)
Definition: Vector4D.cs:1061
static void Lerp(ref Vector4D left, ref Vector4D right, ref Scalar amount, out Vector4D result)
Definition: Vector4D.cs:152
Vector4D(Scalar X, Scalar Y, Scalar Z, Scalar W)
Creates a New Vector4D Instance on the Stack.
Definition: Vector4D.cs:749
static Vector4D Add(Vector4D left, Vector3D right)
Definition: Vector4D.cs:248
static readonly string FormatableString
Definition: Vector4D.cs:86
static Scalar DistanceSq(Vector4D left, Vector4D right)
Definition: Vector4D.cs:185
static Vector4D Add(Vector4D left, Vector2D right)
Definition: Vector4D.cs:261
static bool TryParse(string s, out Vector4D result)
Definition: Vector4D.cs:1072
Scalar MagnitudeSq
Gets the Squared Magnitude of the Vector4D.
Definition: Vector4D.cs:821
static readonly string FormatString
Definition: Vector4D.cs:85
Scalar X
This is the X value.
Definition: Vector4D.cs:710
static void Add(ref Vector4D left, ref Vector4D right, out Vector4D result)
Definition: Vector4D.cs:214
Scalar Y
This is the Y value.
Definition: Vector4D.cs:719
static void Add(ref Vector4D left, ref Vector3D right, out Vector4D result)
Definition: Vector4D.cs:254
static void Copy(Scalar[] sourceArray, int index, out Vector4D result)
Definition: Vector4D.cs:107
static void SetMagnitude(ref Vector4D source, ref Scalar magnitude, out Vector4D result)
Definition: Vector4D.cs:500
bool Equals(Vector4D other)
Definition: Vector4D.cs:1144
static void Subtract(ref Vector4D left, ref Vector3D right, out Vector4D result)
Definition: Vector4D.cs:334
void CopyTo(Scalar[] array, int index)
Definition: Vector4D.cs:854
static void Copy(Scalar[] sourceArray, out Vector4D result)
Definition: Vector4D.cs:103
static Vector4D Add(Vector4D left, Vector4D right)
Adds 2 Vectors2Ds.
Definition: Vector4D.cs:205
string ToStringInternal(string FormatString)
Definition: Vector4D.cs:1057
static Vector4D Negate(Vector4D source)
Negates a Vector4D.
Definition: Vector4D.cs:519
static Vector4D operator+(Vector4D left, Vector4D right)
Adds 2 Vectors2Ds.
Definition: Vector4D.cs:867
static Vector4D Subtract(Vector4D left, Vector2D right)
Definition: Vector4D.cs:341
static void Add(ref Vector4D left, ref Vector2D right, out Vector4D result)
Definition: Vector4D.cs:267
static void Subtract(ref Vector4D left, ref Vector2D right, out Vector4D result)
Definition: Vector4D.cs:347
static Scalar GetMagnitudeSq(Vector4D source)
Gets the Squared Magnitude of the Vector4D that is passed.
Definition: Vector4D.cs:467
Vector4D Normalized
Gets the Normalized Vector4D. (Unit Vector)
Definition: Vector4D.cs:832
static void Add(ref Vector2D left, ref Vector4D right, out Vector4D result)
Definition: Vector4D.cs:241
static Vector4D Subtract(Vector3D left, Vector4D right)
Definition: Vector4D.cs:302
static void Subtract(ref Vector3D left, ref Vector4D right, out Vector4D result)
Definition: Vector4D.cs:308
static Vector4D Lerp(Vector4D left, Vector4D right, Scalar amount)
Definition: Vector4D.cs:146
static void Subtract(ref Vector2D left, ref Vector4D right, out Vector4D result)
Definition: Vector4D.cs:321
static void Lerp(ref Vector4D left, ref Vector4D right, ref Vector4D amount, out Vector4D result)
Definition: Vector4D.cs:165
static void Clamp(ref Vector4D value, ref Vector4D min, ref Vector4D max, out Vector4D result)
Definition: Vector4D.cs:137
override int GetHashCode()
Provides a unique hash code based on the member variables of this class. This should be done because ...
Definition: Vector4D.cs:1129
static void Copy(ref Vector4D vector, Scalar[] destArray)
Definition: Vector4D.cs:90
static void Transform(ref Vector4D vector, ref Matrix4x4 matrix, out Vector4D result)
Definition: Vector4D.cs:436
override string ToString()
Definition: Vector4D.cs:1065
static void Multiply(ref Vector4D source, ref Scalar scalar, out Vector4D result)
Definition: Vector4D.cs:372
static void CatmullRom(ref Vector4D value1, ref Vector4D value2, ref Vector4D value3, ref Vector4D value4, Scalar amount, out Vector4D result)
Definition: Vector4D.cs:630
static void Copy(ref Vector3D source, ref Vector4D dest)
Definition: Vector4D.cs:116
static Vector4D Hermite(Vector4D value1, Vector4D tangent1, Vector4D value2, Vector4D tangent2, Scalar amount)
Definition: Vector4D.cs:684
static void Multiply(ref Scalar scalar, ref Vector4D source, out Vector4D result)
Definition: Vector4D.cs:395
static Vector4D CatmullRom(Vector4D value1, Vector4D value2, Vector4D value3, Vector4D value4, Scalar amount)
Definition: Vector4D.cs:624
const int Size
The Size of the class in bytes;
Definition: Vector4D.cs:57
static readonly Vector4D YAxis
Vector4D(0,1,0,0)
Definition: Vector4D.cs:75
static void Subtract(ref Vector4D left, ref Vector4D right, out Vector4D result)
Definition: Vector4D.cs:293
static Vector4D Lerp(Vector4D left, Vector4D right, Vector4D amount)
Definition: Vector4D.cs:159
static void DistanceSq(ref Vector4D left, ref Vector4D right, out Scalar result)
Definition: Vector4D.cs:191
static Vector4D Parse(string s)
Definition: Vector4D.cs:1100
Vector4D(Scalar[] vals, int index)
Definition: Vector4D.cs:757
static Vector4D Add(Vector2D left, Vector4D right)
Definition: Vector4D.cs:235
static Vector4D Normalize(Vector4D source)
This returns the Normalized Vector4D that is passed. This is also known as a Unit Vector.
Definition: Vector4D.cs:545
Scalar Z
This is the Z value.
Definition: Vector4D.cs:728
static Scalar GetMagnitude(Vector4D source)
Gets the Magnitude of the Vector4D that is passed.
Definition: Vector4D.cs:480
static bool operator==(Vector4D left, Vector4D right)
Specifies whether the Vector4Ds contain the same coordinates.
Definition: Vector4D.cs:1029
static void Distance(ref Vector4D left, ref Vector4D right, out Scalar result)
Definition: Vector4D.cs:179
static void Copy(ref Vector4D vector, Scalar[] destArray, int index)
Definition: Vector4D.cs:94
static void Hermite(ref Vector4D value1, ref Vector4D tangent1, ref Vector4D value2, ref Vector4D tangent2, Scalar amount, out Vector4D result)
Definition: Vector4D.cs:690
static Vector4D Clamp(Vector4D value, Vector4D min, Vector4D max)
Definition: Vector4D.cs:128
static Vector4D Multiply(Scalar scalar, Vector4D source)
Does Scaler Multiplication on a Vector4D.
Definition: Vector4D.cs:386
static Vector4D TripleCross(Vector4D top, Vector4D middle, Vector4D bottom)
Definition: Vector4D.cs:597
static Vector4D Transform(Matrix4x4 matrix, Vector4D vector)
Definition: Vector4D.cs:403
static Vector4D Project(Vector4D left, Vector4D right)
Thie Projects the left Vector4D onto the Right Vector4D.
Definition: Vector4D.cs:580
static Vector4D Multiply(Vector4D source, Scalar scalar)
Does Scaler Multiplication on a Vector4D.
Definition: Vector4D.cs:363
static readonly Vector4D One
Vector4D(1,1,1,1)
Definition: Vector4D.cs:63
static Vector4D Max(Vector4D value1, Vector4D value2)
Definition: Vector4D.cs:656
static void Add(ref Vector3D left, ref Vector4D right, out Vector4D result)
Definition: Vector4D.cs:228
static bool Equals(ref Vector4D left, ref Vector4D right)
Definition: Vector4D.cs:1156
static Vector4D Subtract(Vector4D left, Vector3D right)
Definition: Vector4D.cs:328
static void Normalize(ref Vector4D source)
Definition: Vector4D.cs:569
static void GetMagnitudeSq(ref Vector4D source, out Scalar result)
Definition: Vector4D.cs:471
override bool Equals(object obj)
Compares this Vector to another object. This should be done because the equality operators (==,...
Definition: Vector4D.cs:1140
static Vector4D Subtract(Vector2D left, Vector4D right)
Definition: Vector4D.cs:315
static Vector4D Transform(Vector4D vector, Matrix4x4 matrix)
Definition: Vector4D.cs:425
static void Dot(ref Vector4D left, ref Vector4D right, out Scalar result)
Definition: Vector4D.cs:458
static Vector4D operator-(Vector4D left, Vector4D right)
Subtracts 2 Vector4Ds.
Definition: Vector4D.cs:907
static readonly Vector4D XAxis
Vector4D(1,0,0,0)
Definition: Vector4D.cs:71
int IAdvanceValueType. Count
The Number of Variables accesable though the indexer.
Definition: Vector4D.cs:841
static Scalar Distance(Vector4D left, Vector4D right)
Definition: Vector4D.cs:173
static Scalar Dot(Vector4D left, Vector4D right)
Does a Dot Operation Also know as an Inner Product.
Definition: Vector4D.cs:454
Scalar Magnitude
Gets or Sets the Magnitude (Length) of the Vector4D.
Definition: Vector4D.cs:807
Scalar W
This is the W value.
Definition: Vector4D.cs:737
static Vector4D Add(Vector3D left, Vector4D right)
Definition: Vector4D.cs:222
static void Min(ref Vector4D value1, ref Vector4D value2, out Vector4D result)
Definition: Vector4D.cs:676
static void Negate(ref Vector4D source)
Definition: Vector4D.cs:528
const int Count
The number of Scalar values in the class.
Definition: Vector4D.cs:53
static Vector4D Subtract(Vector4D left, Vector4D right)
Subtracts 2 Vector4Ds.
Definition: Vector4D.cs:284
static Vector4D SetMagnitude(Vector4D source, Scalar magnitude)
Sets the Magnitude of a Vector4D.
Definition: Vector4D.cs:494
Vector4D(Scalar[] vals)
Definition: Vector4D.cs:756
static void Max(ref Vector4D value1, ref Vector4D value2, out Vector4D result)
Definition: Vector4D.cs:662
static void Negate(ref Vector4D source, out Vector4D result)
Definition: Vector4D.cs:532
static bool Equals(Vector4D left, Vector4D right)
Definition: Vector4D.cs:1148
void CopyFrom(Scalar[] array, int index)
Definition: Vector4D.cs:850
static void Normalize(ref Vector4D source, out Vector4D result)
Definition: Vector4D.cs:558
static void Transform(ref Matrix4x4 matrix, ref Vector4D vector, out Vector4D result)
Definition: Vector4D.cs:414
static Vector4D operator*(Vector4D source, Scalar scalar)
Does Scaler Multiplication on a Vector4D.
Definition: Vector4D.cs:947
static void Copy(ref Vector2D source, ref Vector4D dest)
Definition: Vector4D.cs:122
static Vector4D Min(Vector4D value1, Vector4D value2)
Definition: Vector4D.cs:670
static bool operator!=(Vector4D left, Vector4D right)
Specifies whether the Vector4Ds do not contain the same coordinates.
Definition: Vector4D.cs:1039
static readonly Vector4D ZAxis
Vector4D(0,0,1,0)
Definition: Vector4D.cs:79