2 * Copyright (c) 2007-2010 SlimDX Group
\r
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
\r
5 * of this software and associated documentation files (the "Software"), to deal
\r
6 * in the Software without restriction, including without limitation the rights
\r
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
8 * copies of the Software, and to permit persons to whom the Software is
\r
9 * furnished to do so, subject to the following conditions:
\r
11 * The above copyright notice and this permission notice shall be included in
\r
12 * all copies or substantial portions of the Software.
\r
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
\r
24 #include "../design/Vector3Converter.h"
\r
26 #include "Vector4.h"
\r
28 using System::Runtime::InteropServices::OutAttribute;
\r
32 value class Viewport;
\r
34 value class Vector2;
\r
37 /// Defines a three component vector.
\r
39 /// <unmanaged>D3DXVECTOR3</unmanaged>
\r
40 [System::Serializable]
\r
41 [System::Runtime::InteropServices::StructLayout( System::Runtime::InteropServices::LayoutKind::Sequential, Pack = 4 )]
\r
42 [System::ComponentModel::TypeConverter( SlimDX::Design::Vector3Converter::typeid )]
\r
43 public value class Vector3 : System::IEquatable<Vector3>
\r
47 /// Gets or sets the X component of the vector.
\r
49 /// <value>The X component of the vector.</value>
\r
53 /// Gets or sets the Y component of the vector.
\r
55 /// <value>The Y component of the vector.</value>
\r
59 /// Gets or sets the Z component of the vector.
\r
61 /// <value>The Z component of the vector.</value>
\r
64 property float default[int]
\r
66 float get( int index );
\r
67 void set( int index, float value );
\r
71 /// Gets a <see cref="Vector3"/> with all of its components set to zero.
\r
73 /// <value>A <see cref="Vector3"/> that has all of its components set to zero.</value>
\r
74 static property Vector3 Zero { Vector3 get() { return Vector3(0, 0, 0); } }
\r
77 /// Gets the X unit <see cref="Vector3"/> (1, 0, 0).
\r
79 /// <value>A <see cref="Vector3"/> that has a value of (1, 0, 0).</value>
\r
80 static property Vector3 UnitX { Vector3 get() { return Vector3(1, 0, 0); } }
\r
83 /// Gets the Y unit <see cref="Vector3"/> (0, 1, 0).
\r
85 /// <value>A <see cref="Vector3"/> that has a value of (0, 1, 0).</value>
\r
86 static property Vector3 UnitY { Vector3 get() { return Vector3(0, 1, 0); } }
\r
89 /// Gets the Z unit <see cref="Vector3"/> (0, 0, 1).
\r
91 /// <value>A <see cref="Vector3"/> that has a value of (0, 0, 1).</value>
\r
92 static property Vector3 UnitZ { Vector3 get() { return Vector3(0, 0, 1); } }
\r
95 /// Gets the size of the <see cref="Vector3"/> type, in bytes.
\r
97 static property int SizeInBytes { int get() { return System::Runtime::InteropServices::Marshal::SizeOf(Vector3::typeid); } }
\r
100 /// Initializes a new instance of the <see cref="Vector3"/> class.
\r
102 /// <param name="value">The value that will be assigned to all components.</param>
\r
103 Vector3( float value );
\r
106 /// Initializes a new instance of the <see cref="Vector3"/> class.
\r
108 /// <param name="value">A vector containing the values with which to initialize the X and Y components</param>
\r
109 /// <param name="z">Initial value for the Z component of the vector.</param>
\r
110 Vector3( Vector2 value, float z );
\r
113 /// Initializes a new instance of the <see cref="Vector3"/> class.
\r
115 /// <param name="x">Initial value for the X component of the vector.</param>
\r
116 /// <param name="y">Initial value for the Y component of the vector.</param>
\r
117 /// <param name="z">Initial value for the Z component of the vector.</param>
\r
118 Vector3( float x, float y, float z );
\r
121 /// Calculates the length of the vector.
\r
123 /// <returns>The length of the vector.</returns>
\r
127 /// Calculates the squared length of the vector.
\r
129 /// <returns>The squared length of the vector.</returns>
\r
130 float LengthSquared();
\r
133 /// Converts the vector into a unit vector.
\r
138 /// Adds two vectors.
\r
140 /// <param name="left">The first vector to add.</param>
\r
141 /// <param name="right">The second vector to add.</param>
\r
142 /// <returns>The sum of the two vectors.</returns>
\r
143 static Vector3 Add( Vector3 left, Vector3 right );
\r
146 /// Adds two vectors.
\r
148 /// <param name="left">The first vector to add.</param>
\r
149 /// <param name="right">The second vector to add.</param>
\r
150 /// <param name="result">When the method completes, contains the sum of the two vectors.</param>
\r
151 static void Add( Vector3% left, Vector3% right, [Out] Vector3% result );
\r
154 /// Subtracts two vectors.
\r
156 /// <param name="left">The first vector to subtract.</param>
\r
157 /// <param name="right">The second vector to subtract.</param>
\r
158 /// <returns>The difference of the two vectors.</returns>
\r
159 static Vector3 Subtract( Vector3 left, Vector3 right );
\r
162 /// Subtracts two vectors.
\r
164 /// <param name="left">The first vector to subtract.</param>
\r
165 /// <param name="right">The second vector to subtract.</param>
\r
166 /// <param name="result">When the method completes, contains the difference of the two vectors.</param>
\r
167 static void Subtract( Vector3% left, Vector3% right, [Out] Vector3% result );
\r
170 /// Scales a vector by the given value.
\r
172 /// <param name="value">The vector to scale.</param>
\r
173 /// <param name="scale">The amount by which to scale the vector.</param>
\r
174 /// <returns>The scaled vector.</returns>
\r
175 static Vector3 Multiply( Vector3 value, float scale );
\r
178 /// Scales a vector by the given value.
\r
180 /// <param name="vector">The vector to scale.</param>
\r
181 /// <param name="scale">The amount by which to scale the vector.</param>
\r
182 /// <param name="result">When the method completes, contains the scaled vector.</param>
\r
183 static void Multiply( Vector3% vector, float scale, [Out] Vector3% result );
\r
186 /// Modulates a vector by another.
\r
188 /// <param name="left">The first vector to modulate.</param>
\r
189 /// <param name="right">The second vector to modulate.</param>
\r
190 /// <returns>The modulated vector.</returns>
\r
191 static Vector3 Modulate( Vector3 left, Vector3 right );
\r
194 /// Modulates a vector by another.
\r
196 /// <param name="left">The first vector to modulate.</param>
\r
197 /// <param name="right">The second vector to modulate.</param>
\r
198 /// <param name="result">When the moethod completes, contains the modulated vector.</param>
\r
199 static void Modulate( Vector3% left, Vector3% right, [Out] Vector3% result );
\r
202 /// Scales a vector by the given value.
\r
204 /// <param name="value">The vector to scale.</param>
\r
205 /// <param name="scale">The amount by which to scale the vector.</param>
\r
206 /// <returns>The scaled vector.</returns>
\r
207 static Vector3 Divide( Vector3 value, float scale );
\r
210 /// Scales a vector by the given value.
\r
212 /// <param name="vector">The vector to scale.</param>
\r
213 /// <param name="scale">The amount by which to scale the vector.</param>
\r
214 /// <param name="result">When the method completes, contains the scaled vector.</param>
\r
215 static void Divide( Vector3% vector, float scale, [Out] Vector3% result );
\r
218 /// Reverses the direction of a given vector.
\r
220 /// <param name="value">The vector to negate.</param>
\r
221 /// <returns>A vector facing in the opposite direction.</returns>
\r
222 static Vector3 Negate( Vector3 value );
\r
225 /// Reverses the direction of a given vector.
\r
227 /// <param name="value">The vector to negate.</param>
\r
228 /// <param name="result">When the method completes, contains a vector facing in the opposite direction.</param>
\r
229 static void Negate( Vector3% value, [Out] Vector3% result );
\r
232 /// Returns a <see cref="Vector3"/> containing the 3D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 3D triangle.
\r
234 /// <param name="value1">A <see cref="Vector3"/> containing the 3D Cartesian coordinates of vertex 1 of the triangle.</param>
\r
235 /// <param name="value2">A <see cref="Vector3"/> containing the 3D Cartesian coordinates of vertex 2 of the triangle.</param>
\r
236 /// <param name="value3">A <see cref="Vector3"/> containing the 3D Cartesian coordinates of vertex 3 of the triangle.</param>
\r
237 /// <param name="amount1">Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in <paramref name="value2"/>).</param>
\r
238 /// <param name="amount2">Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in <paramref name="value3"/>).</param>
\r
239 /// <returns>A new <see cref="Vector3"/> containing the 3D Cartesian coordinates of the specified point.</returns>
\r
240 static Vector3 Barycentric( Vector3 value1, Vector3 value2, Vector3 value3, float amount1, float amount2 );
\r
243 /// Returns a <see cref="Vector3"/> containing the 3D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 3D triangle.
\r
245 /// <param name="value1">A <see cref="Vector3"/> containing the 3D Cartesian coordinates of vertex 1 of the triangle.</param>
\r
246 /// <param name="value2">A <see cref="Vector3"/> containing the 3D Cartesian coordinates of vertex 2 of the triangle.</param>
\r
247 /// <param name="value3">A <see cref="Vector3"/> containing the 3D Cartesian coordinates of vertex 3 of the triangle.</param>
\r
248 /// <param name="amount1">Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in <paramref name="value2"/>).</param>
\r
249 /// <param name="amount2">Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in <paramref name="value3"/>).</param>
\r
250 /// <param name="result">When the method completes, contains the 3D Cartesian coordinates of the specified point.</param>
\r
251 static void Barycentric( Vector3% value1, Vector3% value2, Vector3% value3, float amount1, float amount2, [Out] Vector3% result );
\r
254 /// Performs a Catmull-Rom interpolation using the specified positions.
\r
256 /// <param name="value1">The first position in the interpolation.</param>
\r
257 /// <param name="value2">The second position in the interpolation.</param>
\r
258 /// <param name="value3">The third position in the interpolation.</param>
\r
259 /// <param name="value4">The fourth position in the interpolation.</param>
\r
260 /// <param name="amount">Weighting factor.</param>
\r
261 /// <returns>A vector that is the result of the Catmull-Rom interpolation.</returns>
\r
262 static Vector3 CatmullRom( Vector3 value1, Vector3 value2, Vector3 value3, Vector3 value4, float amount );
\r
265 /// Performs a Catmull-Rom interpolation using the specified positions.
\r
267 /// <param name="value1">The first position in the interpolation.</param>
\r
268 /// <param name="value2">The second position in the interpolation.</param>
\r
269 /// <param name="value3">The third position in the interpolation.</param>
\r
270 /// <param name="value4">The fourth position in the interpolation.</param>
\r
271 /// <param name="amount">Weighting factor.</param>
\r
272 /// <param name="result">When the method completes, contains the result of the Catmull-Rom interpolation.</param>
\r
273 static void CatmullRom( Vector3% value1, Vector3% value2, Vector3% value3, Vector3% value4, float amount, [Out] Vector3% result );
\r
276 /// Restricts a value to be within a specified range.
\r
278 /// <param name="value">The value to clamp.</param>
\r
279 /// <param name="min">The minimum value.</param>
\r
280 /// <param name="max">The maximum value.</param>
\r
281 /// <returns>The clamped value.</returns>
\r
282 static Vector3 Clamp( Vector3 value, Vector3 min, Vector3 max );
\r
285 /// Restricts a value to be within a specified range.
\r
287 /// <param name="value">The value to clamp.</param>
\r
288 /// <param name="min">The minimum value.</param>
\r
289 /// <param name="max">The maximum value.</param>
\r
290 /// <param name="result">When the method completes, contains the clamped value.</param>
\r
291 static void Clamp( Vector3% value, Vector3% min, Vector3% max, [Out] Vector3% result );
\r
294 /// Performs a Hermite spline interpolation.
\r
296 /// <param name="value1">First source position vector.</param>
\r
297 /// <param name="tangent1">First source tangent vector.</param>
\r
298 /// <param name="value2">Second source position vector.</param>
\r
299 /// <param name="tangent2">Second source tangent vector.</param>
\r
300 /// <param name="amount">Weighting factor.</param>
\r
301 /// <returns>The result of the Hermite spline interpolation.</returns>
\r
302 static Vector3 Hermite( Vector3 value1, Vector3 tangent1, Vector3 value2, Vector3 tangent2, float amount );
\r
305 /// Performs a Hermite spline interpolation.
\r
307 /// <param name="value1">First source position vector.</param>
\r
308 /// <param name="tangent1">First source tangent vector.</param>
\r
309 /// <param name="value2">Second source position vector.</param>
\r
310 /// <param name="tangent2">Second source tangent vector.</param>
\r
311 /// <param name="amount">Weighting factor.</param>
\r
312 /// <param name="result">When the method completes, contains the result of the Hermite spline interpolation.</param>
\r
313 static void Hermite( Vector3% value1, Vector3% tangent1, Vector3% value2, Vector3% tangent2, float amount, [Out] Vector3% result );
\r
316 /// Performs a linear interpolation between two vectors.
\r
318 /// <param name="start">Start vector.</param>
\r
319 /// <param name="end">End vector.</param>
\r
320 /// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end"/>.</param>
\r
321 /// <returns>The linear interpolation of the two vectors.</returns>
\r
323 /// This method performs the linear interpolation based on the following formula.
\r
324 /// <code>start + (end - start) * amount</code>
\r
325 /// Passing <paramref name="amount"/> a value of 0 will cause <paramref name="start"/> to be returned; a value of 1 will cause <paramref name="end"/> to be returned.
\r
327 static Vector3 Lerp( Vector3 start, Vector3 end, float amount );
\r
330 /// Performs a linear interpolation between two vectors.
\r
332 /// <param name="start">Start vector.</param>
\r
333 /// <param name="end">End vector.</param>
\r
334 /// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end"/>.</param>
\r
335 /// <param name="result">When the method completes, contains the linear interpolation of the two vectors.</param>
\r
337 /// This method performs the linear interpolation based on the following formula.
\r
338 /// <code>start + (end - start) * amount</code>
\r
339 /// Passing <paramref name="amount"/> a value of 0 will cause <paramref name="start"/> to be returned; a value of 1 will cause <paramref name="end"/> to be returned.
\r
341 static void Lerp( Vector3% start, Vector3% end, float amount, [Out] Vector3% result );
\r
344 /// Performs a cubic interpolation between two vectors.
\r
346 /// <param name="start">Start vector.</param>
\r
347 /// <param name="end">End vector.</param>
\r
348 /// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end"/>.</param>
\r
349 /// <returns>The cubic interpolation of the two vectors.</returns>
\r
350 static Vector3 SmoothStep( Vector3 start, Vector3 end, float amount );
\r
353 /// Performs a cubic interpolation between two vectors.
\r
355 /// <param name="start">Start vector.</param>
\r
356 /// <param name="end">End vector.</param>
\r
357 /// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end"/>.</param>
\r
358 /// <param name="result">When the method completes, contains the cubic interpolation of the two vectors.</param>
\r
359 static void SmoothStep( Vector3% start, Vector3% end, float amount, [Out] Vector3% result );
\r
362 /// Calculates the distance between two vectors.
\r
364 /// <param name="value1">The first vector.</param>
\r
365 /// <param name="value2">The second vector.</param>
\r
366 /// <returns>The distance between the two vectors.</returns>
\r
367 static float Distance( Vector3 value1, Vector3 value2 );
\r
370 /// Calculates the squared distance between two vectors.
\r
372 /// <param name="value1">The first vector.</param>
\r
373 /// <param name="value2">The second vector.</param>
\r
374 /// <returns>The squared distance between the two vectors.</returns>
\r
375 /// <remarks>Distance squared is the value before taking the square root.
\r
376 /// Distance squared can often be used in place of distance if relative comparisons are being made.
\r
377 /// For example, consider three points A, B, and C. To determine whether B or C is further from A,
\r
378 /// compare the distance between A and B to the distance between A and C. Calculating the two distances
\r
379 /// involves two square roots, which are computationally expensive. However, using distance squared
\r
380 /// provides the same information and avoids calculating two square roots.
\r
382 static float DistanceSquared( Vector3 value1, Vector3 value2 );
\r
385 /// Calculates the dot product of two vectors.
\r
387 /// <param name="left">First source vector.</param>
\r
388 /// <param name="right">Second source vector.</param>
\r
389 /// <returns>The dot product of the two vectors.</returns>
\r
390 static float Dot( Vector3 left, Vector3 right );
\r
393 /// Calculates the cross product of two vectors.
\r
395 /// <param name="left">First source vector.</param>
\r
396 /// <param name="right">Second source vector.</param>
\r
397 /// <returns>The cross product of the two vectors.</returns>
\r
398 static Vector3 Cross( Vector3 left, Vector3 right );
\r
401 /// Calculates the cross product of two vectors.
\r
403 /// <param name="left">First source vector.</param>
\r
404 /// <param name="right">Second source vector.</param>
\r
405 /// <param name="result">The cross product of the two vectors.</param>
\r
406 static void Cross( Vector3% left, Vector3% right, [Out] Vector3% result );
\r
409 /// Returns the reflection of a vector off a surface that has the specified normal.
\r
411 /// <param name="vector">The source vector.</param>
\r
412 /// <param name="normal">Normal of the surface.</param>
\r
413 /// <returns>The reflected vector.</returns>
\r
414 /// <remarks>Reflect only gives the direction of a reflection off a surface, it does not determine
\r
415 /// whether the original vector was close enough to the surface to hit it.</remarks>
\r
416 static Vector3 Reflect( Vector3 vector, Vector3 normal );
\r
419 /// Returns the reflection of a vector off a surface that has the specified normal.
\r
421 /// <param name="vector">The source vector.</param>
\r
422 /// <param name="normal">Normal of the surface.</param>
\r
423 /// <param name="result">When the method completes, contains the reflected vector.</param>
\r
424 /// <remarks>Reflect only gives the direction of a reflection off a surface, it does not determine
\r
425 /// whether the original vector was close enough to the surface to hit it.</remarks>
\r
426 static void Reflect( Vector3% vector, Vector3% normal, [Out] Vector3% result );
\r
429 /// Converts the vector into a unit vector.
\r
431 /// <param name="vector">The vector to normalize.</param>
\r
432 /// <returns>The normalized vector.</returns>
\r
433 static Vector3 Normalize( Vector3 vector );
\r
436 /// Converts the vector into a unit vector.
\r
438 /// <param name="vector">The vector to normalize.</param>
\r
439 /// <param name="result">When the method completes, contains the normalized vector.</param>
\r
440 static void Normalize( Vector3% vector, [Out] Vector3% result );
\r
443 /// Transforms a 3D vector by the given <see cref="SlimDX::Matrix"/>.
\r
445 /// <param name="vector">The source vector.</param>
\r
446 /// <param name="transformation">The transformation <see cref="SlimDX::Matrix"/>.</param>
\r
447 /// <returns>The transformed <see cref="SlimDX::Vector4"/>.</returns>
\r
448 static Vector4 Transform( Vector3 vector, Matrix transformation );
\r
451 /// Transforms a 3D vector by the given <see cref="SlimDX::Matrix"/>.
\r
453 /// <param name="vector">The source vector.</param>
\r
454 /// <param name="transformation">The transformation <see cref="SlimDX::Matrix"/>.</param>
\r
455 /// <param name="result">When the method completes, contains the transformed <see cref="SlimDX::Vector4"/>.</param>
\r
456 static void Transform( Vector3% vector, Matrix% transformation, [Out] Vector4% result );
\r
459 /// Transforms an array of 3D vectors by the given <see cref="SlimDX::Matrix"/>.
\r
461 /// <param name="vectorsIn">The source vectors.</param>
\r
462 /// <param name="inputStride">The stride in bytes between vectors in the input.</param>
\r
463 /// <param name="transformation">The transformation <see cref="SlimDX::Matrix"/>.</param>
\r
464 /// <param name="vectorsOut">The transformed <see cref="SlimDX::Vector4"/>s.</param>
\r
465 /// <param name="outputStride">The stride in bytes between vectors in the output.</param>
\r
466 /// <param name="count">The number of vectors to transform.</param>
\r
467 static void Transform( Vector3* vectorsIn, int inputStride, Matrix* transformation, Vector4* vectorsOut, int outputStride, int count );
\r
470 /// Transforms an array of 3D vectors by the given <see cref="SlimDX::Matrix"/>.
\r
472 /// <param name="vectorsIn">The source vectors.</param>
\r
473 /// <param name="transformation">The transformation <see cref="SlimDX::Matrix"/>.</param>
\r
474 /// <param name="vectorsOut">The transformed <see cref="SlimDX::Vector4"/>s.</param>
\r
475 /// <param name="count">The number of vectors to transform.</param>
\r
476 static void Transform( Vector3* vectorsIn, Matrix* transformation, Vector4* vectorsOut, int count ) { Transform( vectorsIn, (int) sizeof(Vector3), transformation, vectorsOut, (int) sizeof(Vector4), count ); }
\r
479 /// Transforms an array of 3D vectors by the given <see cref="SlimDX::Matrix"/>.
\r
481 /// <param name="vectorsIn">The source vectors.</param>
\r
482 /// <param name="transformation">The transformation <see cref="SlimDX::Matrix"/>.</param>
\r
483 /// <param name="vectorsOut">The transformed <see cref="SlimDX::Vector4"/>s.</param>
\r
484 /// <param name="offset">The offset at which to begin transforming.</param>
\r
485 /// <param name="count">The number of vectors to transform, or 0 to process the whole array.</param>
\r
486 static void Transform( array<Vector3>^ vectorsIn, Matrix% transformation, array<Vector4>^ vectorsOut, int offset, int count );
\r
489 /// Transforms an array of 3D vectors by the given <see cref="SlimDX::Matrix"/>.
\r
491 /// <param name="vectorsIn">The source vectors.</param>
\r
492 /// <param name="transformation">The transformation <see cref="SlimDX::Matrix"/>.</param>
\r
493 /// <param name="vectorsOut">The transformed <see cref="SlimDX::Vector4"/>s.</param>
\r
494 static void Transform( array<Vector3>^ vectorsIn, Matrix% transformation, array<Vector4>^ vectorsOut ) { Transform( vectorsIn, transformation, vectorsOut, 0, 0 ); }
\r
497 /// Transforms an array of 3D vectors by the given <see cref="SlimDX::Matrix"/>.
\r
499 /// <param name="vectors">The source vectors.</param>
\r
500 /// <param name="transformation">The transformation <see cref="SlimDX::Matrix"/>.</param>
\r
501 /// <returns>The transformed <see cref="SlimDX::Vector4"/>s.</returns>
\r
502 static array<Vector4>^ Transform( array<Vector3>^ vectors, Matrix% transformation );
\r
505 /// Transforms a 3D vector by the given <see cref="SlimDX::Quaternion"/> rotation.
\r
507 /// <param name="vector">The vector to rotate.</param>
\r
508 /// <param name="rotation">The <see cref="SlimDX::Quaternion"/> rotation to apply.</param>
\r
509 /// <returns>The transformed <see cref="SlimDX::Vector4"/>.</returns>
\r
510 static Vector4 Transform( Vector3 vector, Quaternion rotation );
\r
513 /// Transforms a 3D vector by the given <see cref="SlimDX::Quaternion"/> rotation.
\r
515 /// <param name="vector">The vector to rotate.</param>
\r
516 /// <param name="rotation">The <see cref="SlimDX::Quaternion"/> rotation to apply.</param>
\r
517 /// <param name="result">When the method completes, contains the transformed <see cref="SlimDX::Vector4"/>.</param>
\r
518 static void Transform( Vector3% vector, Quaternion% rotation, [Out] Vector4% result );
\r
521 /// Transforms an array of 3D vectors by the given <see cref="SlimDX::Quaternion"/> rotation.
\r
523 /// <param name="vectors">The vectors to rotate.</param>
\r
524 /// <param name="rotation">The <see cref="SlimDX::Quaternion"/> rotation to apply.</param>
\r
525 /// <returns>The transformed <see cref="SlimDX::Vector4"/>.</returns>
\r
526 static array<Vector4>^ Transform( array<Vector3>^ vectors, Quaternion% rotation );
\r
529 /// Performs a coordinate transformation using the given <see cref="SlimDX::Matrix"/>.
\r
531 /// <param name="coordinate">The coordinate vector to transform.</param>
\r
532 /// <param name="transformation">The transformation <see cref="SlimDX::Matrix"/>.</param>
\r
533 /// <returns>The transformed coordinates.</returns>
\r
534 static Vector3 TransformCoordinate( Vector3 coordinate, Matrix transformation );
\r
537 /// Performs a coordinate transformation using the given <see cref="SlimDX::Matrix"/>.
\r
539 /// <param name="coordinate">The coordinate vector to transform.</param>
\r
540 /// <param name="transformation">The transformation <see cref="SlimDX::Matrix"/>.</param>
\r
541 /// <param name="result">When the method completes, contains the transformed coordinates.</param>
\r
542 static void TransformCoordinate( Vector3% coordinate, Matrix% transformation, [Out] Vector3% result );
\r
545 /// Performs a coordinate transformation using the given <see cref="SlimDX::Matrix"/>.
\r
547 /// <param name="coordinatesIn">The source coordinate vectors.</param>
\r
548 /// <param name="inputStride">The stride in bytes between vectors in the input.</param>
\r
549 /// <param name="transformation">The transformation <see cref="SlimDX::Matrix"/>.</param>
\r
550 /// <param name="coordinatesOut">The transformed coordinate <see cref="SlimDX::Vector3"/>s.</param>
\r
551 /// <param name="outputStride">The stride in bytes between vectors in the output.</param>
\r
552 /// <param name="count">The number of coordinate vectors to transform.</param>
\r
553 static void TransformCoordinate( Vector3* coordinatesIn, int inputStride, Matrix* transformation, Vector3* coordinatesOut, int outputStride, int count );
\r
556 /// Performs a coordinate transformation using the given <see cref="SlimDX::Matrix"/>.
\r
558 /// <param name="coordinatesIn">The source coordinate vectors.</param>
\r
559 /// <param name="transformation">The transformation <see cref="SlimDX::Matrix"/>.</param>
\r
560 /// <param name="coordinatesOut">The transformed coordinate <see cref="SlimDX::Vector3"/>s.</param>
\r
561 /// <param name="count">The number of coordinate vectors to transform.</param>
\r
562 static void TransformCoordinate( Vector3* coordinatesIn, Matrix* transformation, Vector3* coordinatesOut, int count ) { TransformCoordinate( coordinatesIn, (int) sizeof(Vector3), transformation, coordinatesOut, (int) sizeof(Vector3), count ); }
\r
565 /// Performs a coordinate transformation using the given <see cref="SlimDX::Matrix"/>.
\r
567 /// <param name="coordinatesIn">The source coordinate vectors.</param>
\r
568 /// <param name="transformation">The transformation <see cref="SlimDX::Matrix"/>.</param>
\r
569 /// <param name="coordinatesOut">The transformed coordinate <see cref="SlimDX::Vector3"/>s.</param>
\r
570 /// <param name="offset">The offset at which to begin transforming.</param>
\r
571 /// <param name="count">The number of coordinate vectors to transform, or 0 to process the whole array.</param>
\r
572 static void TransformCoordinate( array<Vector3>^ coordinatesIn, Matrix% transformation, array<Vector3>^ coordinatesOut, int offset, int count );
\r
575 /// Performs a coordinate transformation using the given <see cref="SlimDX::Matrix"/>.
\r
577 /// <param name="coordinatesIn">The source coordinate vectors.</param>
\r
578 /// <param name="transformation">The transformation <see cref="SlimDX::Matrix"/>.</param>
\r
579 /// <param name="coordinatesOut">The transformed coordinate <see cref="SlimDX::Vector3"/>s.</param>
\r
580 static void TransformCoordinate( array<Vector3>^ coordinatesIn, Matrix% transformation, array<Vector3>^ coordinatesOut ) { TransformCoordinate( coordinatesIn, transformation, coordinatesOut, 0, 0 ); }
\r
583 /// Performs a coordinate transformation using the given <see cref="SlimDX::Matrix"/>.
\r
585 /// <param name="coordinates">The coordinate vectors to transform.</param>
\r
586 /// <param name="transformation">The transformation <see cref="SlimDX::Matrix"/>.</param>
\r
587 /// <returns>The transformed coordinates.</returns>
\r
588 static array<Vector3>^ TransformCoordinate( array<Vector3>^ coordinates, Matrix% transformation );
\r
591 /// Performs a normal transformation using the given <see cref="SlimDX::Matrix"/>.
\r
593 /// <param name="normal">The normal vector to transform.</param>
\r
594 /// <param name="transformation">The transformation <see cref="SlimDX::Matrix"/>.</param>
\r
595 /// <returns>The transformed normal.</returns>
\r
596 static Vector3 TransformNormal( Vector3 normal, Matrix transformation );
\r
599 /// Performs a normal transformation using the given <see cref="SlimDX::Matrix"/>.
\r
601 /// <param name="normal">The normal vector to transform.</param>
\r
602 /// <param name="transformation">The transformation <see cref="SlimDX::Matrix"/>.</param>
\r
603 /// <param name="result">When the method completes, contains the transformed normal.</param>
\r
604 static void TransformNormal( Vector3% normal, Matrix% transformation, [Out] Vector3% result );
\r
607 /// Performs a normal transformation using the given <see cref="SlimDX::Matrix"/>.
\r
609 /// <param name="normalsIn">The source normals to transform.</param>
\r
610 /// <param name="inputStride">The stride in bytes between normals in the input.</param>
\r
611 /// <param name="transformation">The transformation <see cref="SlimDX::Matrix"/>.</param>
\r
612 /// <param name="normalsOut">The transformed <see cref="SlimDX::Vector3"/>s.</param>
\r
613 /// <param name="outputStride">The stride in bytes between vectors in the output.</param>
\r
614 /// <param name="count">The number of vectors to transform.</param>
\r
615 static void TransformNormal( Vector3* normalsIn, int inputStride, Matrix* transformation, Vector3* normalsOut, int outputStride, int count );
\r
618 /// Performs a normal transformation using the given <see cref="SlimDX::Matrix"/>.
\r
620 /// <param name="normalsIn">The source normals to transform.</param>
\r
621 /// <param name="transformation">The transformation <see cref="SlimDX::Matrix"/>.</param>
\r
622 /// <param name="normalsOut">The transformed <see cref="SlimDX::Vector3"/>s.</param>
\r
623 /// <param name="count">The number of vectors to transform.</param>
\r
624 static void TransformNormal( Vector3* normalsIn, Matrix* transformation, Vector3* normalsOut, int count ) { TransformNormal( normalsIn, (int) sizeof(Vector3), transformation, normalsOut, (int) sizeof(Vector3), count ); }
\r
627 /// Performs a normal transformation using the given <see cref="SlimDX::Matrix"/>.
\r
629 /// <param name="normalsIn">The source vectors.</param>
\r
630 /// <param name="transformation">The transformation <see cref="SlimDX::Matrix"/>.</param>
\r
631 /// <param name="normalsOut">The transformed <see cref="SlimDX::Vector3"/>s.</param>
\r
632 /// <param name="offset">The offset at which to begin transforming.</param>
\r
633 /// <param name="count">The number of vectors to transform, or 0 to process the whole array.</param>
\r
634 static void TransformNormal( array<Vector3>^ normalsIn, Matrix% transformation, array<Vector3>^ normalsOut, int offset, int count );
\r
637 /// Performs a normal transformation using the given <see cref="SlimDX::Matrix"/>.
\r
639 /// <param name="normalsIn">The source vectors.</param>
\r
640 /// <param name="transformation">The transformation <see cref="SlimDX::Matrix"/>.</param>
\r
641 /// <param name="normalsOut">The transformed <see cref="SlimDX::Vector3"/>s.</param>
\r
642 static void TransformNormal( array<Vector3>^ normalsIn, Matrix% transformation, array<Vector3>^ normalsOut ) { TransformNormal( normalsIn, transformation, normalsOut, 0, 0 ); }
\r
645 /// Performs a normal transformation using the given <see cref="SlimDX::Matrix"/>.
\r
647 /// <param name="normals">The normal vectors to transform.</param>
\r
648 /// <param name="transformation">The transformation <see cref="SlimDX::Matrix"/>.</param>
\r
649 /// <returns>The transformed normals.</returns>
\r
650 static array<Vector3>^ TransformNormal( array<Vector3>^ normals, Matrix% transformation );
\r
653 /// Projects a 3D vector from object space into screen space.
\r
655 /// <param name="vector">The vector to project.</param>
\r
656 /// <param name="x">The X position of the viewport.</param>
\r
657 /// <param name="y">The Y position of the viewport.</param>
\r
658 /// <param name="width">The width of the viewport.</param>
\r
659 /// <param name="height">The height of the viewport.</param>
\r
660 /// <param name="minZ">The minimum depth of the viewport.</param>
\r
661 /// <param name="maxZ">The maximum depth of the viewport.</param>
\r
662 /// <param name="worldViewProjection">The combined world-view-projection matrix.</param>
\r
663 /// <returns>The vector in screen space.</returns>
\r
664 static Vector3 Project( Vector3 vector, float x, float y, float width, float height, float minZ, float maxZ, Matrix worldViewProjection );
\r
667 /// Projects a 3D vector from object space into screen space.
\r
669 /// <param name="vector">The vector to project.</param>
\r
670 /// <param name="x">The X position of the viewport.</param>
\r
671 /// <param name="y">The Y position of the viewport.</param>
\r
672 /// <param name="width">The width of the viewport.</param>
\r
673 /// <param name="height">The height of the viewport.</param>
\r
674 /// <param name="minZ">The minimum depth of the viewport.</param>
\r
675 /// <param name="maxZ">The maximum depth of the viewport.</param>
\r
676 /// <param name="worldViewProjection">The combined world-view-projection matrix.</param>
\r
677 /// <param name="result">When the method completes, contains the vector in screen space.</param>
\r
678 static void Project( Vector3% vector, float x, float y, float width, float height, float minZ, float maxZ, Matrix% worldViewProjection, [Out] Vector3% result );
\r
681 /// Projects a 3D vector from screen space into object space.
\r
683 /// <param name="vector">The vector to project.</param>
\r
684 /// <param name="x">The X position of the viewport.</param>
\r
685 /// <param name="y">The Y position of the viewport.</param>
\r
686 /// <param name="width">The width of the viewport.</param>
\r
687 /// <param name="height">The height of the viewport.</param>
\r
688 /// <param name="minZ">The minimum depth of the viewport.</param>
\r
689 /// <param name="maxZ">The maximum depth of the viewport.</param>
\r
690 /// <param name="worldViewProjection">The combined world-view-projection matrix.</param>
\r
691 /// <returns>The vector in object space.</returns>
\r
692 static Vector3 Unproject( Vector3 vector, float x, float y, float width, float height, float minZ, float maxZ, Matrix worldViewProjection );
\r
695 /// Projects a 3D vector from screen space into object space.
\r
697 /// <param name="vector">The vector to project.</param>
\r
698 /// <param name="x">The X position of the viewport.</param>
\r
699 /// <param name="y">The Y position of the viewport.</param>
\r
700 /// <param name="width">The width of the viewport.</param>
\r
701 /// <param name="height">The height of the viewport.</param>
\r
702 /// <param name="minZ">The minimum depth of the viewport.</param>
\r
703 /// <param name="maxZ">The maximum depth of the viewport.</param>
\r
704 /// <param name="worldViewProjection">The combined world-view-projection matrix.</param>
\r
705 /// <param name="result">When the method completes, contains the vector in object space.</param>
\r
706 static void Unproject( Vector3% vector, float x, float y, float width, float height, float minZ, float maxZ, Matrix% worldViewProjection, [Out] Vector3% result );
\r
709 /// Returns a vector containing the smallest components of the specified vectors.
\r
711 /// <param name="value1">The first source vector.</param>
\r
712 /// <param name="value2">The second source vector.</param>
\r
713 /// <returns>A vector containing the smallest components of the source vectors.</returns>
\r
714 static Vector3 Minimize( Vector3 value1, Vector3 value2 );
\r
717 /// Returns a vector containing the smallest components of the specified vectors.
\r
719 /// <param name="value1">The first source vector.</param>
\r
720 /// <param name="value2">The second source vector.</param>
\r
721 /// <param name="result">When the method completes, contains an new vector composed of the smallest components of the source vectors.</param>
\r
722 static void Minimize( Vector3% value1, Vector3% value2, [Out] Vector3% result );
\r
725 /// Returns a vector containing the largest components of the specified vectors.
\r
727 /// <param name="value1">The first source vector.</param>
\r
728 /// <param name="value2">The second source vector.</param>
\r
729 /// <returns>A vector containing the largest components of the source vectors.</returns>
\r
730 static Vector3 Maximize( Vector3 value1, Vector3 value2 );
\r
733 /// Returns a vector containing the smallest components of the specified vectors.
\r
735 /// <param name="value1">The first source vector.</param>
\r
736 /// <param name="value2">The second source vector.</param>
\r
737 /// <param name="result">When the method completes, contains an new vector composed of the largest components of the source vectors.</param>
\r
738 static void Maximize( Vector3% value1, Vector3% value2, [Out] Vector3% result );
\r
741 /// Adds two vectors.
\r
743 /// <param name="left">The first vector to add.</param>
\r
744 /// <param name="right">The second vector to add.</param>
\r
745 /// <returns>The sum of the two vectors.</returns>
\r
746 static Vector3 operator + ( Vector3 left, Vector3 right );
\r
749 /// Subtracts two vectors.
\r
751 /// <param name="left">The first vector to subtract.</param>
\r
752 /// <param name="right">The second vector to subtract.</param>
\r
753 /// <returns>The difference of the two vectors.</returns>
\r
754 static Vector3 operator - ( Vector3 left, Vector3 right );
\r
757 /// Reverses the direction of a given vector.
\r
759 /// <param name="value">The vector to negate.</param>
\r
760 /// <returns>A vector facing in the opposite direction.</returns>
\r
761 static Vector3 operator - ( Vector3 value );
\r
764 /// Scales a vector by the given value.
\r
766 /// <param name="vector">The vector to scale.</param>
\r
767 /// <param name="scale">The amount by which to scale the vector.</param>
\r
768 /// <returns>The scaled vector.</returns>
\r
769 static Vector3 operator * ( Vector3 vector, float scale );
\r
772 /// Scales a vector by the given value.
\r
774 /// <param name="vector">The vector to scale.</param>
\r
775 /// <param name="scale">The amount by which to scale the vector.</param>
\r
776 /// <returns>The scaled vector.</returns>
\r
777 static Vector3 operator * ( float scale, Vector3 vector );
\r
780 /// Scales a vector by the given value.
\r
782 /// <param name="vector">The vector to scale.</param>
\r
783 /// <param name="scale">The amount by which to scale the vector.</param>
\r
784 /// <returns>The scaled vector.</returns>
\r
785 static Vector3 operator / ( Vector3 vector, float scale );
\r
788 /// Tests for equality between two objects.
\r
790 /// <param name="left">The first value to compare.</param>
\r
791 /// <param name="right">The second value to compare.</param>
\r
792 /// <returns><c>true</c> if <paramref name="left"/> has the same value as <paramref name="right"/>; otherwise, <c>false</c>.</returns>
\r
793 static bool operator == ( Vector3 left, Vector3 right );
\r
796 /// Tests for inequality between two objects.
\r
798 /// <param name="left">The first value to compare.</param>
\r
799 /// <param name="right">The second value to compare.</param>
\r
800 /// <returns><c>true</c> if <paramref name="left"/> has a different value than <paramref name="right"/>; otherwise, <c>false</c>.</returns>
\r
801 static bool operator != ( Vector3 left, Vector3 right );
\r
804 /// Converts the value of the object to its equivalent string representation.
\r
806 /// <returns>The string representation of the value of this instance.</returns>
\r
807 virtual System::String^ ToString() override;
\r
810 /// Returns the hash code for this instance.
\r
812 /// <returns>A 32-bit signed integer hash code.</returns>
\r
813 virtual int GetHashCode() override;
\r
816 /// Returns a value that indicates whether the current instance is equal to a specified object.
\r
818 /// <param name="obj">Object to make the comparison with.</param>
\r
819 /// <returns><c>true</c> if the current instance is equal to the specified object; <c>false</c> otherwise.</returns>
\r
820 virtual bool Equals( System::Object^ obj ) override;
\r
823 /// Returns a value that indicates whether the current instance is equal to the specified object.
\r
825 /// <param name="other">Object to make the comparison with.</param>
\r
826 /// <returns><c>true</c> if the current instance is equal to the specified object; <c>false</c> otherwise.</returns>
\r
827 virtual bool Equals( Vector3 other );
\r
830 /// Determines whether the specified object instances are considered equal.
\r
832 /// <param name="value1">The first value to compare.</param>
\r
833 /// <param name="value2">The second value to compare.</param>
\r
834 /// <returns><c>true</c> if <paramref name="value1"/> is the same instance as <paramref name="value2"/> or
\r
835 /// if both are <c>null</c> references or if <c>value1.Equals(value2)</c> returns <c>true</c>; otherwise, <c>false</c>.</returns>
\r
836 static bool Equals( Vector3% value1, Vector3% value2 );
\r