OSDN Git Service

Merge branch 'feature/#36529_SlimDXからSharpDXへの移行' into develop
[dtxmania/dtxmania.git] / SlimDXc_Jun2010(VC++2008) / source / math / Vector3.cpp
diff --git a/SlimDXc_Jun2010(VC++2008)/source/math/Vector3.cpp b/SlimDXc_Jun2010(VC++2008)/source/math/Vector3.cpp
deleted file mode 100644 (file)
index e777a4b..0000000
+++ /dev/null
@@ -1,829 +0,0 @@
-#include "stdafx.h"\r
-/*\r
-* Copyright (c) 2007-2010 SlimDX Group\r
-* \r
-* Permission is hereby granted, free of charge, to any person obtaining a copy\r
-* of this software and associated documentation files (the "Software"), to deal\r
-* in the Software without restriction, including without limitation the rights\r
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
-* copies of the Software, and to permit persons to whom the Software is\r
-* furnished to do so, subject to the following conditions:\r
-* \r
-* The above copyright notice and this permission notice shall be included in\r
-* all copies or substantial portions of the Software.\r
-* \r
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
-* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
-* THE SOFTWARE.\r
-*/\r
-\r
-#include <d3dx9.h>\r
-\r
-#include "../Utilities.h"\r
-\r
-#include "Quaternion.h"\r
-#include "Matrix.h"\r
-#include "Vector2.h"\r
-#include "Vector3.h"\r
-\r
-using namespace System;\r
-using namespace System::Globalization;\r
-\r
-namespace SlimDX\r
-{\r
-       Vector3::Vector3( float value )\r
-       {\r
-               X = value;\r
-               Y = value;\r
-               Z = value;\r
-       }\r
-       \r
-       Vector3::Vector3( Vector2 value, float z )\r
-       {\r
-               X = value.X;\r
-               Y = value.Y;\r
-               Z = z;\r
-       }\r
-       \r
-       Vector3::Vector3( float x, float y, float z )\r
-       {\r
-               X = x;\r
-               Y = y;\r
-               Z = z;\r
-       }\r
-       \r
-       float Vector3::default::get( int index )\r
-       {\r
-               switch( index )\r
-               {\r
-               case 0:\r
-                       return X;\r
-\r
-               case 1:\r
-                       return Y;\r
-\r
-               case 2:\r
-                       return Z;\r
-\r
-               default:\r
-                       throw gcnew ArgumentOutOfRangeException( "index", "Indices for Vector3 run from 0 to 2, inclusive." );\r
-               }\r
-       }\r
-       \r
-       void Vector3::default::set( int index, float value )\r
-       {\r
-               switch( index )\r
-               {\r
-               case 0:\r
-                       X = value;\r
-                       break;\r
-\r
-               case 1:\r
-                       Y = value;\r
-                       break;\r
-\r
-               case 2:\r
-                       Z = value;\r
-                       break;\r
-\r
-               default:\r
-                       throw gcnew ArgumentOutOfRangeException( "index", "Indices for Vector3 run from 0 to 2, inclusive." );\r
-               }\r
-       }\r
-       \r
-       float Vector3::Length()\r
-       {\r
-               return static_cast<float>( Math::Sqrt( (X * X) + (Y * Y) + (Z * Z) ) );\r
-       }\r
-       \r
-       float Vector3::LengthSquared()\r
-       {\r
-               return (X * X) + (Y * Y) + (Z * Z);\r
-       }\r
-\r
-       void Vector3::Normalize()\r
-       {\r
-               float length = Length();\r
-               if( length == 0 )\r
-                       return;\r
-               float num = 1 / length;\r
-               X *= num;\r
-               Y *= num;\r
-               Z *= num;\r
-       }\r
-       \r
-       Vector3 Vector3::Add( Vector3 left, Vector3 right )\r
-       {\r
-               return Vector3( left.X + right.X, left.Y + right.Y, left.Z + right.Z );\r
-       }\r
-       \r
-       void Vector3::Add( Vector3% left, Vector3% right, [Out] Vector3% result )\r
-       {\r
-               result = Vector3( left.X + right.X, left.Y + right.Y, left.Z + right.Z );\r
-       }\r
-       \r
-       Vector3 Vector3::Subtract( Vector3 left, Vector3 right )\r
-       {\r
-               return Vector3( left.X - right.X, left.Y - right.Y, left.Z - right.Z );\r
-       }\r
-       \r
-       void Vector3::Subtract( Vector3% left, Vector3% right, [Out] Vector3% result )\r
-       {\r
-               result = Vector3( left.X - right.X, left.Y - right.Y, left.Z - right.Z );\r
-       }\r
-       \r
-       Vector3 Vector3::Modulate( Vector3 left, Vector3 right )\r
-       {\r
-               return Vector3( left.X * right.X, left.Y * right.Y, left.Z * right.Z );\r
-       }\r
-       \r
-       void Vector3::Modulate( Vector3% left, Vector3% right, [Out] Vector3% result )\r
-       {\r
-               result = Vector3( left.X * right.X, left.Y * right.Y, left.Z * right.Z );\r
-       }\r
-       \r
-       Vector3 Vector3::Multiply( Vector3 value, float scale )\r
-       {\r
-               return Vector3( value.X * scale, value.Y * scale, value.Z * scale );\r
-       }\r
-       \r
-       void Vector3::Multiply( Vector3% value, float scale, [Out] Vector3% result )\r
-       {\r
-               result = Vector3( value.X * scale, value.Y * scale, value.Z * scale );\r
-       }\r
-       \r
-       Vector3 Vector3::Divide( Vector3 value, float scale )\r
-       {\r
-               return Vector3( value.X / scale, value.Y / scale, value.Z / scale );\r
-       }\r
-       \r
-       void Vector3::Divide( Vector3% value, float scale, [Out] Vector3% result )\r
-       {\r
-               result = Vector3( value.X / scale, value.Y / scale, value.Z / scale );\r
-       }\r
-       \r
-       Vector3 Vector3::Negate( Vector3 value )\r
-       {\r
-               return Vector3( -value.X, -value.Y, -value.Z );\r
-       }\r
-       \r
-       void Vector3::Negate( Vector3% value, [Out] Vector3% result )\r
-       {\r
-               result = Vector3( -value.X, -value.Y, -value.Z );\r
-       }\r
-       \r
-       Vector3 Vector3::Barycentric( Vector3 value1, Vector3 value2, Vector3 value3, float amount1, float amount2 )\r
-       {\r
-               Vector3 vector;\r
-               vector.X = (value1.X + (amount1 * (value2.X - value1.X))) + (amount2 * (value3.X - value1.X));\r
-               vector.Y = (value1.Y + (amount1 * (value2.Y - value1.Y))) + (amount2 * (value3.Y - value1.Y));\r
-               vector.Z = (value1.Z + (amount1 * (value2.Z - value1.Z))) + (amount2 * (value3.Z - value1.Z));\r
-               return vector;\r
-       }\r
-       \r
-       void Vector3::Barycentric( Vector3% value1, Vector3% value2, Vector3% value3, float amount1, float amount2, [Out] Vector3% result )\r
-       {\r
-               result = Vector3((value1.X + (amount1 * (value2.X - value1.X))) + (amount2 * (value3.X - value1.X)),\r
-                       (value1.Y + (amount1 * (value2.Y - value1.Y))) + (amount2 * (value3.Y - value1.Y)),\r
-                       (value1.Z + (amount1 * (value2.Z - value1.Z))) + (amount2 * (value3.Z - value1.Z)) );\r
-       }\r
-       \r
-       Vector3 Vector3::CatmullRom( Vector3 value1, Vector3 value2, Vector3 value3, Vector3 value4, float amount )\r
-       {\r
-               Vector3 vector;\r
-               float squared = amount * amount;\r
-               float cubed = amount * squared;\r
-\r
-               vector.X = 0.5f * ((((2.0f * value2.X) + ((-value1.X + value3.X) * amount)) + \r
-                       (((((2.0f * value1.X) - (5.0f * value2.X)) + (4.0f * value3.X)) - value4.X) * squared)) + \r
-                       ((((-value1.X + (3.0f * value2.X)) - (3.0f * value3.X)) + value4.X) * cubed));\r
-\r
-               vector.Y = 0.5f * ((((2.0f * value2.Y) + ((-value1.Y + value3.Y) * amount)) + \r
-                       (((((2.0f * value1.Y) - (5.0f * value2.Y)) + (4.0f * value3.Y)) - value4.Y) * squared)) + \r
-                       ((((-value1.Y + (3.0f * value2.Y)) - (3.0f * value3.Y)) + value4.Y) * cubed));\r
-\r
-               vector.Z = 0.5f * ((((2.0f * value2.Z) + ((-value1.Z + value3.Z) * amount)) + \r
-                       (((((2.0f * value1.Z) - (5.0f * value2.Z)) + (4.0f * value3.Z)) - value4.Z) * squared)) + \r
-                       ((((-value1.Z + (3.0f * value2.Z)) - (3.0f * value3.Z)) + value4.Z) * cubed));\r
-\r
-               return vector;\r
-       }\r
-       \r
-       void Vector3::CatmullRom( Vector3% value1, Vector3% value2, Vector3% value3, Vector3% value4, float amount, [Out] Vector3% result )\r
-       {\r
-               float squared = amount * amount;\r
-               float cubed = amount * squared;\r
-               \r
-               Vector3 r;\r
-\r
-               r.X = 0.5f * ((((2.0f * value2.X) + ((-value1.X + value3.X) * amount)) + \r
-                       (((((2.0f * value1.X) - (5.0f * value2.X)) + (4.0f * value3.X)) - value4.X) * squared)) + \r
-                       ((((-value1.X + (3.0f * value2.X)) - (3.0f * value3.X)) + value4.X) * cubed));\r
-\r
-               r.Y = 0.5f * ((((2.0f * value2.Y) + ((-value1.Y + value3.Y) * amount)) + \r
-                       (((((2.0f * value1.Y) - (5.0f * value2.Y)) + (4.0f * value3.Y)) - value4.Y) * squared)) + \r
-                       ((((-value1.Y + (3.0f * value2.Y)) - (3.0f * value3.Y)) + value4.Y) * cubed));\r
-\r
-               r.Z = 0.5f * ((((2.0f * value2.Z) + ((-value1.Z + value3.Z) * amount)) + \r
-                       (((((2.0f * value1.Z) - (5.0f * value2.Z)) + (4.0f * value3.Z)) - value4.Z) * squared)) + \r
-                       ((((-value1.Z + (3.0f * value2.Z)) - (3.0f * value3.Z)) + value4.Z) * cubed));\r
-\r
-               result = r;\r
-       }\r
-       \r
-       Vector3 Vector3::Clamp( Vector3 value, Vector3 min, Vector3 max )\r
-       {\r
-               float x = value.X;\r
-               x = (x > max.X) ? max.X : x;\r
-               x = (x < min.X) ? min.X : x;\r
-\r
-               float y = value.Y;\r
-               y = (y > max.Y) ? max.Y : y;\r
-               y = (y < min.Y) ? min.Y : y;\r
-\r
-               float z = value.Z;\r
-               z = (z > max.Z) ? max.Z : z;\r
-               z = (z < min.Z) ? min.Z : z;\r
-\r
-               return Vector3( x, y, z );\r
-       }\r
-       \r
-       void Vector3::Clamp( Vector3% value, Vector3% min, Vector3% max, [Out] Vector3% result )\r
-       {\r
-               float x = value.X;\r
-               x = (x > max.X) ? max.X : x;\r
-               x = (x < min.X) ? min.X : x;\r
-\r
-               float y = value.Y;\r
-               y = (y > max.Y) ? max.Y : y;\r
-               y = (y < min.Y) ? min.Y : y;\r
-\r
-               float z = value.Z;\r
-               z = (z > max.Z) ? max.Z : z;\r
-               z = (z < min.Z) ? min.Z : z;\r
-\r
-               result = Vector3( x, y, z );\r
-       }\r
-       \r
-       Vector3 Vector3::Hermite( Vector3 value1, Vector3 tangent1, Vector3 value2, Vector3 tangent2, float amount )\r
-       {\r
-               Vector3 vector;\r
-               float squared = amount * amount;\r
-               float cubed = amount * squared;\r
-               float part1 = ((2.0f * cubed) - (3.0f * squared)) + 1.0f;\r
-               float part2 = (-2.0f * cubed) + (3.0f * squared);\r
-               float part3 = (cubed - (2.0f * squared)) + amount;\r
-               float part4 = cubed - squared;\r
-\r
-               vector.X = (((value1.X * part1) + (value2.X * part2)) + (tangent1.X * part3)) + (tangent2.X * part4);\r
-               vector.Y = (((value1.Y * part1) + (value2.Y * part2)) + (tangent1.Y * part3)) + (tangent2.Y * part4);\r
-               vector.Z = (((value1.Z * part1) + (value2.Z * part2)) + (tangent1.Z * part3)) + (tangent2.Z * part4);\r
-\r
-               return vector;\r
-       }\r
-       \r
-       void Vector3::Hermite( Vector3% value1, Vector3% tangent1, Vector3% value2, Vector3% tangent2, float amount, [Out] Vector3% result )\r
-       {\r
-               float squared = amount * amount;\r
-               float cubed = amount * squared;\r
-               float part1 = ((2.0f * cubed) - (3.0f * squared)) + 1.0f;\r
-               float part2 = (-2.0f * cubed) + (3.0f * squared);\r
-               float part3 = (cubed - (2.0f * squared)) + amount;\r
-               float part4 = cubed - squared;\r
-\r
-               result.X = (((value1.X * part1) + (value2.X * part2)) + (tangent1.X * part3)) + (tangent2.X * part4);\r
-               result.Y = (((value1.Y * part1) + (value2.Y * part2)) + (tangent1.Y * part3)) + (tangent2.Y * part4);\r
-               result.Z = (((value1.Z * part1) + (value2.Z * part2)) + (tangent1.Z * part3)) + (tangent2.Z * part4);\r
-       }\r
-       \r
-       Vector3 Vector3::Lerp( Vector3 start, Vector3 end, float factor )\r
-       {\r
-               Vector3 vector;\r
-\r
-               vector.X = start.X + ((end.X - start.X) * factor);\r
-               vector.Y = start.Y + ((end.Y - start.Y) * factor);\r
-               vector.Z = start.Z + ((end.Z - start.Z) * factor);\r
-\r
-               return vector;\r
-       }\r
-       \r
-       void Vector3::Lerp( Vector3% start, Vector3% end, float factor, [Out] Vector3% result )\r
-       {\r
-               result.X = start.X + ((end.X - start.X) * factor);\r
-               result.Y = start.Y + ((end.Y - start.Y) * factor);\r
-               result.Z = start.Z + ((end.Z - start.Z) * factor);\r
-       }\r
-       \r
-       Vector3 Vector3::SmoothStep( Vector3 start, Vector3 end, float amount )\r
-       {\r
-               Vector3 vector;\r
-\r
-               amount = (amount > 1.0f) ? 1.0f : ((amount < 0.0f) ? 0.0f : amount);\r
-               amount = (amount * amount) * (3.0f - (2.0f * amount));\r
-\r
-               vector.X = start.X + ((end.X - start.X) * amount);\r
-               vector.Y = start.Y + ((end.Y - start.Y) * amount);\r
-               vector.Z = start.Z + ((end.Z - start.Z) * amount);\r
-\r
-               return vector;\r
-       }\r
-       \r
-       void Vector3::SmoothStep( Vector3% start, Vector3% end, float amount, [Out] Vector3% result )\r
-       {\r
-               amount = (amount > 1.0f) ? 1.0f : ((amount < 0.0f) ? 0.0f : amount);\r
-               amount = (amount * amount) * (3.0f - (2.0f * amount));\r
-\r
-               result.X = start.X + ((end.X - start.X) * amount);\r
-               result.Y = start.Y + ((end.Y - start.Y) * amount);\r
-               result.Z = start.Z + ((end.Z - start.Z) * amount);\r
-       }\r
-       \r
-       float Vector3::Distance( Vector3 value1, Vector3 value2 )\r
-       {\r
-               float x = value1.X - value2.X;\r
-               float y = value1.Y - value2.Y;\r
-               float z = value1.Z - value2.Z;\r
-\r
-               return static_cast<float>( Math::Sqrt( (x * x) + (y * y) + (z * z) ) );\r
-       }\r
-       \r
-       float Vector3::DistanceSquared( Vector3 value1, Vector3 value2 )\r
-       {\r
-               float x = value1.X - value2.X;\r
-               float y = value1.Y - value2.Y;\r
-               float z = value1.Z - value2.Z;\r
-\r
-               return (x * x) + (y * y) + (z * z);\r
-       }\r
-       \r
-       float Vector3::Dot( Vector3 left, Vector3 right )\r
-       {\r
-               return (left.X * right.X + left.Y * right.Y + left.Z * right.Z);\r
-       }\r
-       \r
-       Vector3 Vector3::Cross( Vector3 left, Vector3 right )\r
-       {\r
-               Vector3 result;\r
-               result.X = left.Y * right.Z - left.Z * right.Y;\r
-               result.Y = left.Z * right.X - left.X * right.Z;\r
-               result.Z = left.X * right.Y - left.Y * right.X;\r
-               return result;\r
-       }\r
-       \r
-       void Vector3::Cross( Vector3% left, Vector3% right, [Out] Vector3% result )\r
-       {\r
-               Vector3 r;\r
-               r.X = left.Y * right.Z - left.Z * right.Y;\r
-               r.Y = left.Z * right.X - left.X * right.Z;\r
-               r.Z = left.X * right.Y - left.Y * right.X; \r
-\r
-               result = r;\r
-       }\r
-       \r
-       Vector3 Vector3::Reflect( Vector3 vector, Vector3 normal )\r
-       {\r
-               Vector3 result;\r
-               float dot = ((vector.X * normal.X) + (vector.Y * normal.Y)) + (vector.Z * normal.Z);\r
-\r
-               result.X = vector.X - ((2.0f * dot) * normal.X);\r
-               result.Y = vector.Y - ((2.0f * dot) * normal.Y);\r
-               result.Z = vector.Z - ((2.0f * dot) * normal.Z);\r
-\r
-               return result;\r
-       }\r
-       \r
-       void Vector3::Reflect( Vector3% vector, Vector3% normal, [Out] Vector3% result )\r
-       {\r
-               float dot = ((vector.X * normal.X) + (vector.Y * normal.Y)) + (vector.Z * normal.Z);\r
-\r
-               result.X = vector.X - ((2.0f * dot) * normal.X);\r
-               result.Y = vector.Y - ((2.0f * dot) * normal.Y);\r
-               result.Z = vector.Z - ((2.0f * dot) * normal.Z);\r
-       }\r
-       \r
-       Vector3 Vector3::Normalize( Vector3 vector )\r
-       {\r
-               vector.Normalize();\r
-               return vector;\r
-       }\r
-       \r
-       void Vector3::Normalize( Vector3% vector, [Out] Vector3% result )\r
-       {\r
-               result = Vector3(vector);\r
-               result.Normalize();\r
-       }\r
-       \r
-       Vector4 Vector3::Transform( Vector3 vector, Matrix transform )\r
-       {\r
-               Vector4 result;\r
-\r
-               result.X = (((vector.X * transform.M11) + (vector.Y * transform.M21)) + (vector.Z * transform.M31)) + transform.M41;\r
-               result.Y = (((vector.X * transform.M12) + (vector.Y * transform.M22)) + (vector.Z * transform.M32)) + transform.M42;\r
-               result.Z = (((vector.X * transform.M13) + (vector.Y * transform.M23)) + (vector.Z * transform.M33)) + transform.M43;\r
-               result.W = (((vector.X * transform.M14) + (vector.Y * transform.M24)) + (vector.Z * transform.M34)) + transform.M44;\r
-\r
-               return result;\r
-       }\r
-       \r
-       void Vector3::Transform( Vector3% vector, Matrix% transform, [Out] Vector4% result )\r
-       {\r
-               result = Vector4();\r
-               result.X = (((vector.X * transform.M11) + (vector.Y * transform.M21)) + (vector.Z * transform.M31)) + transform.M41;\r
-               result.Y = (((vector.X * transform.M12) + (vector.Y * transform.M22)) + (vector.Z * transform.M32)) + transform.M42;\r
-               result.Z = (((vector.X * transform.M13) + (vector.Y * transform.M23)) + (vector.Z * transform.M33)) + transform.M43;\r
-               result.W = (((vector.X * transform.M14) + (vector.Y * transform.M24)) + (vector.Z * transform.M34)) + transform.M44;\r
-       }\r
-       \r
-       void Vector3::Transform( Vector3* vectorsIn, int inputStride, Matrix* transformation, Vector4* vectorsOut, int outputStride, int count )\r
-       {\r
-               D3DXVec3TransformArray( reinterpret_cast<D3DXVECTOR4*>( vectorsOut ), outputStride,\r
-                       reinterpret_cast<const D3DXVECTOR3*>( vectorsIn ), inputStride,\r
-                       reinterpret_cast<const D3DXMATRIX*>( transformation ), count );\r
-       }\r
-\r
-       void Vector3::Transform( array<Vector3>^ vectorsIn, Matrix% transformation, array<Vector4>^ vectorsOut, int offset, int count )\r
-       {\r
-               if(vectorsIn->Length != vectorsOut->Length)\r
-                       throw gcnew ArgumentException( "Input and output arrays must be the same size.", "vectorsOut" );\r
-               Utilities::CheckArrayBounds( vectorsIn, offset, count );\r
-\r
-               pin_ptr<Vector3> pinnedIn = &vectorsIn[offset];\r
-               pin_ptr<Matrix> pinnedMatrix = &transformation;\r
-               pin_ptr<Vector4> pinnedOut = &vectorsOut[offset];\r
-\r
-               Transform( pinnedIn, pinnedMatrix, pinnedOut, count );\r
-       }\r
-\r
-       array<Vector4>^ Vector3::Transform( array<Vector3>^ vectors, Matrix% transform )\r
-       {\r
-               int count = vectors->Length;\r
-               array<Vector4>^ results = gcnew array<Vector4>( count );\r
-\r
-               /*for( int i = 0; i < count; i++ )\r
-               {\r
-                       Vector4 r;\r
-                       r.X = (((vectors[i].X * transform.M11) + (vectors[i].Y * transform.M21)) + (vectors[i].Z * transform.M31)) + transform.M41;\r
-                       r.Y = (((vectors[i].X * transform.M12) + (vectors[i].Y * transform.M22)) + (vectors[i].Z * transform.M32)) + transform.M42;\r
-                       r.Z = (((vectors[i].X * transform.M13) + (vectors[i].Y * transform.M23)) + (vectors[i].Z * transform.M33)) + transform.M43;\r
-                       r.W = (((vectors[i].X * transform.M14) + (vectors[i].Y * transform.M24)) + (vectors[i].Z * transform.M34)) + transform.M44;\r
-               \r
-                       results[i] = r;\r
-               }*/\r
-               Transform( vectors, transform, results );\r
-               return results;\r
-       }\r
-       \r
-       Vector4 Vector3::Transform( Vector3 value, Quaternion rotation )\r
-       {\r
-               Vector4 vector;\r
-               float x = rotation.X + rotation.X;\r
-               float y = rotation.Y + rotation.Y;\r
-               float z = rotation.Z + rotation.Z;\r
-               float wx = rotation.W * x;\r
-               float wy = rotation.W * y;\r
-               float wz = rotation.W * z;\r
-               float xx = rotation.X * x;\r
-               float xy = rotation.X * y;\r
-               float xz = rotation.X * z;\r
-               float yy = rotation.Y * y;\r
-               float yz = rotation.Y * z;\r
-               float zz = rotation.Z * z;\r
-\r
-               vector.X = ((value.X * ((1.0f - yy) - zz)) + (value.Y * (xy - wz))) + (value.Z * (xz + wy));\r
-               vector.Y = ((value.X * (xy + wz)) + (value.Y * ((1.0f - xx) - zz))) + (value.Z * (yz - wx));\r
-               vector.Z = ((value.X * (xz - wy)) + (value.Y * (yz + wx))) + (value.Z * ((1.0f - xx) - yy));\r
-               vector.W = 1.0f;\r
-\r
-               return vector;\r
-       }\r
-       \r
-       void Vector3::Transform( Vector3% value, Quaternion% rotation, [Out] Vector4% result )\r
-       {\r
-               float x = rotation.X + rotation.X;\r
-               float y = rotation.Y + rotation.Y;\r
-               float z = rotation.Z + rotation.Z;\r
-               float wx = rotation.W * x;\r
-               float wy = rotation.W * y;\r
-               float wz = rotation.W * z;\r
-               float xx = rotation.X * x;\r
-               float xy = rotation.X * y;\r
-               float xz = rotation.X * z;\r
-               float yy = rotation.Y * y;\r
-               float yz = rotation.Y * z;\r
-               float zz = rotation.Z * z;\r
-\r
-               result = Vector4();\r
-               result.X = ((value.X * ((1.0f - yy) - zz)) + (value.Y * (xy - wz))) + (value.Z * (xz + wy));\r
-               result.Y = ((value.X * (xy + wz)) + (value.Y * ((1.0f - xx) - zz))) + (value.Z * (yz - wx));\r
-               result.Z = ((value.X * (xz - wy)) + (value.Y * (yz + wx))) + (value.Z * ((1.0f - xx) - yy));\r
-               result.W = 1.0f;\r
-       }\r
-       \r
-       array<Vector4>^ Vector3::Transform( array<Vector3>^ vectors, Quaternion% rotation )\r
-       {\r
-               if( vectors == nullptr )\r
-                       throw gcnew ArgumentNullException( "vectors" );\r
-\r
-               int count = vectors->Length;\r
-               array<Vector4>^ results = gcnew array<Vector4>( count );\r
-\r
-               float x = rotation.X + rotation.X;\r
-               float y = rotation.Y + rotation.Y;\r
-               float z = rotation.Z + rotation.Z;\r
-               float wx = rotation.W * x;\r
-               float wy = rotation.W * y;\r
-               float wz = rotation.W * z;\r
-               float xx = rotation.X * x;\r
-               float xy = rotation.X * y;\r
-               float xz = rotation.X * z;\r
-               float yy = rotation.Y * y;\r
-               float yz = rotation.Y * z;\r
-               float zz = rotation.Z * z;\r
-\r
-               for( int i = 0; i < count; i++ )\r
-               {\r
-                       Vector4 r;\r
-                       r.X = ((vectors[i].X * ((1.0f - yy) - zz)) + (vectors[i].Y * (xy - wz))) + (vectors[i].Z * (xz + wy));\r
-                       r.Y = ((vectors[i].X * (xy + wz)) + (vectors[i].Y * ((1.0f - xx) - zz))) + (vectors[i].Z * (yz - wx));\r
-                       r.Z = ((vectors[i].X * (xz - wy)) + (vectors[i].Y * (yz + wx))) + (vectors[i].Z * ((1.0f - xx) - yy));\r
-                       r.W = 1.0f;\r
-\r
-                       results[i] = r;\r
-               }\r
-\r
-               return results;\r
-       }\r
-       \r
-       Vector3 Vector3::TransformCoordinate( Vector3 coord, Matrix transform )\r
-       {\r
-               Vector4 vector;\r
-\r
-               vector.X = (((coord.X * transform.M11) + (coord.Y * transform.M21)) + (coord.Z * transform.M31)) + transform.M41;\r
-               vector.Y = (((coord.X * transform.M12) + (coord.Y * transform.M22)) + (coord.Z * transform.M32)) + transform.M42;\r
-               vector.Z = (((coord.X * transform.M13) + (coord.Y * transform.M23)) + (coord.Z * transform.M33)) + transform.M43;\r
-               vector.W = 1 / ((((coord.X * transform.M14) + (coord.Y * transform.M24)) + (coord.Z * transform.M34)) + transform.M44);\r
-\r
-               return Vector3( vector.X * vector.W, vector.Y * vector.W, vector.Z * vector.W );\r
-       }\r
-       \r
-       void Vector3::TransformCoordinate( Vector3% coord, Matrix% transform, [Out] Vector3% result )\r
-       {\r
-               Vector4 vector;\r
-\r
-               vector.X = (((coord.X * transform.M11) + (coord.Y * transform.M21)) + (coord.Z * transform.M31)) + transform.M41;\r
-               vector.Y = (((coord.X * transform.M12) + (coord.Y * transform.M22)) + (coord.Z * transform.M32)) + transform.M42;\r
-               vector.Z = (((coord.X * transform.M13) + (coord.Y * transform.M23)) + (coord.Z * transform.M33)) + transform.M43;\r
-               vector.W = 1 / ((((coord.X * transform.M14) + (coord.Y * transform.M24)) + (coord.Z * transform.M34)) + transform.M44);\r
-\r
-               result = Vector3( vector.X * vector.W, vector.Y * vector.W, vector.Z * vector.W );\r
-       }\r
-       \r
-       void Vector3::TransformCoordinate( Vector3* coordsIn, int inputStride, Matrix* transformation, Vector3* coordsOut, int outputStride, int count )\r
-       {\r
-               D3DXVec3TransformCoordArray( reinterpret_cast<D3DXVECTOR3*>( coordsOut ), outputStride,\r
-                       reinterpret_cast<const D3DXVECTOR3*>( coordsIn ), inputStride,\r
-                       reinterpret_cast<const D3DXMATRIX*>( transformation ), count );\r
-       }\r
-\r
-       void Vector3::TransformCoordinate( array<Vector3>^ coordsIn, Matrix% transformation, array<Vector3>^ coordsOut, int offset, int count )\r
-       {\r
-               if(coordsIn->Length != coordsOut->Length)\r
-                       throw gcnew ArgumentException( "Input and output arrays must be the same size.", "coordinatesOut" );\r
-               Utilities::CheckArrayBounds( coordsIn, offset, count );\r
-\r
-               pin_ptr<Vector3> pinnedIn = &coordsIn[offset];\r
-               pin_ptr<Matrix> pinnedMatrix = &transformation;\r
-               pin_ptr<Vector3> pinnedOut = &coordsOut[offset];\r
-\r
-               TransformCoordinate( pinnedIn, pinnedMatrix, pinnedOut, count );\r
-       }\r
-       \r
-       array<Vector3>^ Vector3::TransformCoordinate( array<Vector3>^ coords, Matrix% transform )\r
-       {\r
-               if( coords == nullptr )\r
-                       throw gcnew ArgumentNullException( "coordinates" );\r
-\r
-               Vector4 vector;\r
-               int count = coords->Length;\r
-               array<Vector3>^ results = gcnew array<Vector3>( count );\r
-\r
-               /*for( int i = 0; i < count; i++ )\r
-               {\r
-                       vector.X = (((coords[i].X * transform.M11) + (coords[i].Y * transform.M21)) + (coords[i].Z * transform.M31)) + transform.M41;\r
-                       vector.Y = (((coords[i].X * transform.M12) + (coords[i].Y * transform.M22)) + (coords[i].Z * transform.M32)) + transform.M42;\r
-                       vector.Z = (((coords[i].X * transform.M13) + (coords[i].Y * transform.M23)) + (coords[i].Z * transform.M33)) + transform.M43;\r
-                       vector.W = 1 / ((((coords[i].X * transform.M14) + (coords[i].Y * transform.M24)) + (coords[i].Z * transform.M34)) + transform.M44);\r
-                       results[i] = Vector3( vector.X * vector.W, vector.Y * vector.W, vector.Z * vector.W );\r
-               }*/\r
-               TransformCoordinate( coords, transform, results );\r
-               return results;\r
-       }\r
-       \r
-       Vector3 Vector3::TransformNormal( Vector3 normal, Matrix transform )\r
-       {\r
-               Vector3 vector;\r
-\r
-               vector.X = ((normal.X * transform.M11) + (normal.Y * transform.M21)) + (normal.Z * transform.M31);\r
-               vector.Y = ((normal.X * transform.M12) + (normal.Y * transform.M22)) + (normal.Z * transform.M32);\r
-               vector.Z = ((normal.X * transform.M13) + (normal.Y * transform.M23)) + (normal.Z * transform.M33);\r
-\r
-               return vector;\r
-       }\r
-       \r
-       void Vector3::TransformNormal( Vector3% normal, Matrix% transform, [Out] Vector3% result )\r
-       {\r
-               result.X = ((normal.X * transform.M11) + (normal.Y * transform.M21)) + (normal.Z * transform.M31);\r
-               result.Y = ((normal.X * transform.M12) + (normal.Y * transform.M22)) + (normal.Z * transform.M32);\r
-               result.Z = ((normal.X * transform.M13) + (normal.Y * transform.M23)) + (normal.Z * transform.M33);\r
-       }\r
-       \r
-       void Vector3::TransformNormal( Vector3* normalsIn, int inputStride, Matrix* transformation, Vector3* normalsOut, int outputStride, int count )\r
-       {\r
-               D3DXVec3TransformNormalArray( reinterpret_cast<D3DXVECTOR3*>( normalsOut ), outputStride,\r
-                       reinterpret_cast<const D3DXVECTOR3*>( normalsIn ), inputStride,\r
-                       reinterpret_cast<const D3DXMATRIX*>( transformation ), count );\r
-       }\r
-\r
-       void Vector3::TransformNormal( array<Vector3>^ normalsIn, Matrix% transformation, array<Vector3>^ normalsOut, int offset, int count )\r
-       {\r
-               if(normalsIn->Length != normalsOut->Length)\r
-                       throw gcnew ArgumentException( "Input and output arrays must be the same size.", "normalsOut" );\r
-               Utilities::CheckArrayBounds( normalsOut, offset, count );\r
-\r
-               pin_ptr<Vector3> pinnedIn = &normalsIn[offset];\r
-               pin_ptr<Matrix> pinnedMatrix = &transformation;\r
-               pin_ptr<Vector3> pinnedOut = &normalsOut[offset];\r
-\r
-               TransformNormal( pinnedIn, pinnedMatrix, pinnedOut, count );\r
-       }\r
-       \r
-       array<Vector3>^ Vector3::TransformNormal( array<Vector3>^ normals, Matrix% transform )\r
-       {\r
-               if( normals == nullptr )\r
-                       throw gcnew ArgumentNullException( "normals" );\r
-\r
-               int count = normals->Length;\r
-               array<Vector3>^ results = gcnew array<Vector3>( count );\r
-\r
-               /*for( int i = 0; i < count; i++ )\r
-               {\r
-                       Vector3 r;\r
-                       r.X = ((normals[i].X * transform.M11) + (normals[i].Y * transform.M21)) + (normals[i].Z * transform.M31);\r
-                       r.Y = ((normals[i].X * transform.M12) + (normals[i].Y * transform.M22)) + (normals[i].Z * transform.M32);\r
-                       r.Z = ((normals[i].X * transform.M13) + (normals[i].Y * transform.M23)) + (normals[i].Z * transform.M33);\r
-               \r
-                       results[i] = r;\r
-               }*/\r
-               TransformNormal( normals, transform, results );\r
-               return results;\r
-       }\r
-       \r
-       Vector3 Vector3::Project( Vector3 vector, float x, float y, float width, float height, float minZ, float maxZ, Matrix worldViewProjection )\r
-       {\r
-               Vector3::TransformCoordinate( vector, worldViewProjection, vector );\r
-               return Vector3( ( ( 1.0f + vector.X ) * 0.5f * width ) + x, ( ( 1.0f - vector.Y ) * 0.5f * height ) + y, ( vector.Z * ( maxZ - minZ ) ) + minZ );\r
-       }\r
-       \r
-       void Vector3::Project( Vector3% vector, float x, float y, float width, float height, float minZ, float maxZ, Matrix% worldViewProjection, [Out] Vector3% result )\r
-       {\r
-               Vector3 v;\r
-               Vector3::TransformCoordinate( vector, worldViewProjection, v );\r
-\r
-               result = Vector3( ( ( 1.0f + v.X ) * 0.5f * width ) + x, ( ( 1.0f - v.Y ) * 0.5f * height ) + y, ( v.Z * ( maxZ - minZ ) ) + minZ );\r
-       }\r
-       \r
-       Vector3 Vector3::Unproject( Vector3 vector, float x, float y, float width, float height, float minZ, float maxZ, Matrix worldViewProjection )\r
-       {\r
-               Vector3 v;\r
-               Matrix matrix;\r
-               Matrix::Invert( worldViewProjection, matrix );\r
-\r
-               v.X = ( ( ( vector.X - x ) / width ) * 2.0f ) - 1.0f;\r
-               v.Y = -( ( ( ( vector.Y - y ) / height ) * 2.0f ) - 1.0f );\r
-               v.Z = ( vector.Z - minZ ) / ( maxZ - minZ );\r
-\r
-               Vector3::TransformCoordinate( v, matrix, v );\r
-               return v;\r
-       }\r
-       \r
-       void Vector3::Unproject( Vector3% vector, float x, float y, float width, float height, float minZ, float maxZ, Matrix% worldViewProjection, [Out] Vector3% result )\r
-       {\r
-               Vector3 v;\r
-               Matrix matrix;\r
-               Matrix::Invert( worldViewProjection, matrix );\r
-\r
-               v.X = ( ( ( vector.X - x ) / width ) * 2.0f ) - 1.0f;\r
-               v.Y = -( ( ( ( vector.Y - y ) / height ) * 2.0f ) - 1.0f );\r
-               v.Z = ( vector.Z - minZ ) / ( maxZ - minZ );\r
-\r
-               Vector3::TransformCoordinate( v, matrix, v );\r
-               result = v;\r
-       }\r
-       \r
-       Vector3 Vector3::Minimize( Vector3 left, Vector3 right )\r
-       {\r
-               Vector3 vector;\r
-               vector.X = (left.X < right.X) ? left.X : right.X;\r
-               vector.Y = (left.Y < right.Y) ? left.Y : right.Y;\r
-               vector.Z = (left.Z < right.Z) ? left.Z : right.Z;\r
-               return vector;\r
-       }\r
-       \r
-       void Vector3::Minimize( Vector3% left, Vector3% right, [Out] Vector3% result )\r
-       {\r
-               result.X = (left.X < right.X) ? left.X : right.X;\r
-               result.Y = (left.Y < right.Y) ? left.Y : right.Y;\r
-               result.Z = (left.Z < right.Z) ? left.Z : right.Z;\r
-       }\r
-       \r
-       Vector3 Vector3::Maximize( Vector3 left, Vector3 right )\r
-       {\r
-               Vector3 vector;\r
-               vector.X = (left.X > right.X) ? left.X : right.X;\r
-               vector.Y = (left.Y > right.Y) ? left.Y : right.Y;\r
-               vector.Z = (left.Z > right.Z) ? left.Z : right.Z;\r
-               return vector;\r
-       }\r
-       \r
-       void Vector3::Maximize( Vector3% left, Vector3% right, [Out] Vector3% result )\r
-       {\r
-               result.X = (left.X > right.X) ? left.X : right.X;\r
-               result.Y = (left.Y > right.Y) ? left.Y : right.Y;\r
-               result.Z = (left.Z > right.Z) ? left.Z : right.Z;\r
-       }\r
-       \r
-       Vector3 Vector3::operator + ( Vector3 left, Vector3 right )\r
-       {\r
-               return Vector3( left.X + right.X, left.Y + right.Y, left.Z + right.Z );\r
-       }\r
-       \r
-       Vector3 Vector3::operator - ( Vector3 left, Vector3 right )\r
-       {\r
-               return Vector3( left.X - right.X, left.Y - right.Y, left.Z - right.Z );\r
-       }\r
-       \r
-       Vector3 Vector3::operator - ( Vector3 value )\r
-       {\r
-               return Vector3( -value.X, -value.Y, -value.Z );\r
-       }\r
-\r
-       Vector3 Vector3::operator * ( Vector3 value, float scale )\r
-       {\r
-               return Vector3( value.X * scale, value.Y * scale, value.Z * scale );\r
-       }\r
-\r
-       Vector3 Vector3::operator * ( float scale, Vector3 vec )\r
-       {\r
-               return vec * scale;\r
-       }\r
-       \r
-       Vector3 Vector3::operator / ( Vector3 value, float scale )\r
-       {\r
-               return Vector3( value.X / scale, value.Y / scale, value.Z / scale );\r
-       }\r
-       \r
-       bool Vector3::operator == ( Vector3 left, Vector3 right )\r
-       {\r
-               return Vector3::Equals( left, right );\r
-       }\r
-       \r
-       bool Vector3::operator != ( Vector3 left, Vector3 right )\r
-       {\r
-               return !Vector3::Equals( left, right );\r
-       }\r
-\r
-       String^ Vector3::ToString()\r
-       {\r
-               return String::Format( CultureInfo::CurrentCulture, "X:{0} Y:{1} Z:{2}", X.ToString(CultureInfo::CurrentCulture), Y.ToString(CultureInfo::CurrentCulture), Z.ToString(CultureInfo::CurrentCulture) );\r
-       }\r
-\r
-       int Vector3::GetHashCode()\r
-       {\r
-               return X.GetHashCode() + Y.GetHashCode() + Z.GetHashCode();\r
-       }\r
-\r
-       bool Vector3::Equals( Object^ value )\r
-       {\r
-               if( value == nullptr )\r
-                       return false;\r
-\r
-               if( value->GetType() != GetType() )\r
-                       return false;\r
-\r
-               return Equals( safe_cast<Vector3>( value ) );\r
-       }\r
-\r
-       bool Vector3::Equals( Vector3 value )\r
-       {\r
-               return ( X == value.X && Y == value.Y && Z == value.Z );\r
-       }\r
-\r
-       bool Vector3::Equals( Vector3% value1, Vector3% value2 )\r
-       {\r
-               return ( value1.X == value2.X && value1.Y == value2.Y && value1.Z == value2.Z );\r
-       }\r
-}
\ No newline at end of file