mathTypes.cpp
Engine/source/math/mathTypes.cpp
Public Variables
ConsoleGetType (TypePoint2I)
Public Functions
ConsoleFunctionGroupEnd(MatrixMath )
ConsoleGetType(TypeAngAxisF )
ConsoleGetType(TypeBox3F )
ConsoleGetType(TypeEaseF )
ConsoleGetType(TypeMatrixF )
ConsoleGetType(TypePoint2F )
ConsoleGetType(TypePoint3F )
ConsoleGetType(TypePoint3I )
ConsoleGetType(TypePoint4F )
ConsoleGetType(TypeRectF )
ConsoleGetType(TypeRectI )
ConsoleGetType(TypeRotationF )
ConsoleGetType(TypeTransformF )
ConsoleSetType(TypeAngAxisF )
ConsoleSetType(TypeBox3F )
ConsoleSetType(TypeEaseF )
ConsoleSetType(TypeMatrixF )
ConsoleSetType(TypeMatrixPosition )
ConsoleSetType(TypeMatrixRotation )
ConsoleSetType(TypePoint2F )
ConsoleSetType(TypePoint2I )
ConsoleSetType(TypePoint3F )
ConsoleSetType(TypePoint3I )
ConsoleSetType(TypePoint4F )
ConsoleSetType(TypeRectF )
ConsoleSetType(TypeRectI )
ConsoleSetType(TypeRotationF )
ConsoleSetType(TypeTransformF )
ConsoleType(AngAxisF , TypeAngAxisF , AngAxisF , "" )
ConsoleType(Box3F , TypeBox3F , Box3F , "" )
ConsoleType(EaseF , TypeEaseF , EaseF , "" )
ConsoleType(MatrixF , TypeMatrixF , MatrixF , "" )
ConsoleType(MatrixPosition , TypeMatrixPosition , MatrixF , "" )
ConsoleType(MatrixRotation , TypeMatrixRotation , MatrixF , "" )
ConsoleType(Point2F , TypePoint2F , Point2F , "" )
ConsoleType(Point2I , TypePoint2I , Point2I , "" )
ConsoleType(Point3F , TypePoint3F , Point3F , "" )
ConsoleType(Point3I , TypePoint3I , Point3I , "" )
ConsoleType(Point4F , TypePoint4F , Point4F , "" )
ConsoleType(RectF , TypeRectF , RectF , "" )
ConsoleType(RectI , TypeRectI , RectI , "" )
ConsoleType(RotationF , TypeRotationF , RotationF , "" )
ConsoleType(TransformF , TypeTransformF , TransformF , "" )
DefineConsoleFunction(getBoxCenter , Point3F , (Box3F box) , "Get the center point of an axis-aligned <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">box.\n\n</a>" "@param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> A Box3F, in string format using \"minExtentX minExtentY minExtentZ maxExtentX maxExtentY maxExtentZ\"\n" "@return Center of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">box.\n</a>" "@ingroup <a href="/coding/class/structmath/">Math</a>" )
DefineConsoleFunction(getRandom , F32 , (S32 a, S32 b) , (S32_MAX, S32_MAX) , "( int a, int <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> ) " "@brief Returns a random number based on parameters passed <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">in..\n\n</a>" "If no parameters are passed in, getRandom() will return a float between 0.0 and 1.0. If one " "parameter is passed an integer between 0 and the passed in value will be returned. Two parameters will " "return an integer between the specified <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">numbers.\n\n</a>" " @param a If this is the only parameter, a number between 0 and a is returned. Elsewise represents the lower <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">bound.\n</a>" " @param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> Upper bound on the random number. The random number will be<=@a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">b.\n</a>" " @return A pseudo-random integer between @a a and @a b, between 0 and a, or a " "float between 0.0 and 1.1 depending on <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">usage.\n\n</a>" " @note All parameters are optional." " @see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">setRandomSeed\n</a>" " @ingroup Random" )
DefineConsoleFunction(MatrixCreate , TransformF , (VectorF position, AngAxisF orientation) , "Create a transform from the given translation and <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">orientation.\n</a>" "@param position The translation vector <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">transform.\n</a>" "@param orientation The axis and rotation that orients the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">transform.\n</a>" "@return A transform based on the given position and <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">orientation.\n</a>" "@ingroup Matrices" )
DefineConsoleFunction(MatrixCreateFromEuler , TransformF , (Point3F angles) , "@Create a matrix from the given <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">rotations.\n\n</a>" "@param Vector3F X, Y , and Z rotation in *radians *.\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @return A transform based on the given <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">orientation.\n</a>" " @ingroup Matrices" )
DefineConsoleFunction(MatrixMulPoint , Point3F , (TransformF transform, Point3F point) )
DefineConsoleFunction(MatrixMultiply , TransformF , (TransformF left, TransformF right) , "@brief Multiply the two <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">matrices.\n\n</a>" "@param left First <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">transform.\n</a>" "@param right Right <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">transform.\n</a>" "@return Concatenation of the two <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">transforms.\n</a>" "@ingroup Matrices" )
DefineConsoleFunction(MatrixMulVector , VectorF , (TransformF transform, VectorF vector) )
DefineConsoleFunction(VectorAdd , VectorF , (VectorF a, VectorF b) , "Add two <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vectors.\n</a>" "@param a The first <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> The second <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@return The vector @a a + @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">b.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// VectorAdd( %a, %<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> );\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// The sum of vector a, (ax, ay, az) , and vector b, (bx, by, bz) <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is:\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//a+ b)
DefineConsoleFunction(VectorCross , VectorF , (VectorF a, VectorF b) , "Calculcate the cross product of two <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vectors.\n</a>" "@param a The first <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> The second <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@return The cross product @a x @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">b.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// VectorCross( %a, %<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> );\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// The cross product of vector a, (ax, ay, az) , and vector b, (bx, by, bz) , <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//a x b)
DefineConsoleFunction(VectorDist , F32 , (VectorF a, VectorF b) , "Compute the distance between two <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vectors.\n</a>" "@param a The first <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> The second <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@return The length( @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> - @a a ).\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// VectorDist( %a, %<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> );\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// The distance between vector a, (ax, ay, az) , and vector b, (bx, by, bz) , <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//a -> b)
DefineConsoleFunction(VectorDiv , VectorF , (VectorF a, VectorF b) , "Divide two <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vectors.\n</a>" "@param a The first <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> The second <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@return The vector @a a / @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">b.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// VectorDiv( %a, %<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> );\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// The division of vector a, (ax, ay, az) , and vector b, (bx, by, bz) <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is:\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//a * b)
DefineConsoleFunction(VectorDot , F32 , (VectorF a, VectorF b) , "Compute the dot product of two <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vectors.\n</a>" "@param a The first <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> The second <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@return The dot product @a a * @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">b.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// VectorDot( %a, %<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> );\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// The dot product between vector a, (ax, ay, az) , and vector b, (bx, by, bz) , <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is:\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//a . b)
DefineConsoleFunction(VectorLen , F32 , (VectorF v) , "Calculate the magnitude of the given <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@param v A <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@return The length of vector @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">v.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// VectorLen( %a );\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// The length or magnitude of vector a, (ax, ay, az) , <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is:\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//||a|| )
DefineConsoleFunction(VectorLerp , VectorF , (VectorF a, VectorF b, F32 t) , "Linearly interpolate between two vectors by @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">t.\n</a>" "@param a <a href="/coding/class/classvector/">Vector</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> start interpolation <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">from.\n</a>" "@param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> <a href="/coding/class/classvector/">Vector</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> interpolate <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">to.\n</a>" "@param <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a21feba301403a65090791a94f26c9d92">t</a> Interpolation factor (0-1). At zero, @a a is returned and at one, @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> is returned. In between, an interpolated vector " "between @a a and @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">returned.\n</a>" " @return An interpolated vector between @a a and @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">b.\n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//VectorLerp(%a, %<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a>);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//The point between vector a, (ax, ay, az) , and vector b, (bx, by, bz) , which <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is\n</a>" "//weighted by the interpolation factor, <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a21feba301403a65090791a94f26c9d92">t</a> , <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// r)
DefineConsoleFunction(VectorMidPoint , VectorF , (VectorF a, VectorF b) , "Gets the midpoint between the two <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vectors.\n</a>" "@param a The first <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> The second <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@return The vector (@a a + @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a>) / 2.\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// VectorMidPoint( %a, %<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> );\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// The midpoint of vector a, (ax, ay, az) , and vector b, (bx, by, bz) <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is:\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//(a+<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a>)/ 2, (az+bz)/ 2)
DefineConsoleFunction(VectorMul , VectorF , (VectorF a, VectorF b) , "Multiplies two <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vectors.\n</a>" "@param a The first <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> The second <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@return The vector @a a * @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">b.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// VectorMul( %a, %<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> );\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// The multiplication of vector a, (ax, ay, az) , and vector b, (bx, by, bz) <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is:\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//a * b)
DefineConsoleFunction(VectorNormalize , VectorF , (VectorF v) , "Brings a vector into its unit form, i.e. such that it has the magnitute 1.\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @param v The vector <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">normalize.\n</a>" " @return The vector @a v scaled <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> length 1.\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//VectorNormalize(%a);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//The normalized vector a, (ax, ay, az) , <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is:\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//a^ )
DefineConsoleFunction(VectorOrthoBasis , MatrixF , (AngAxisF aa) , "Create an orthogonal basis from the given <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@param aaf The vector <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> create the orthogonal basis <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">from.\n</a>" "@return A matrix representing the orthogonal <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">basis.\n</a>" "@ingroup Vectors" )
DefineConsoleFunction(VectorReflect , VectorF , (VectorF vec, VectorF normal) , "Compute the reflection of a vector based on a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">normal.\n</a>" "@param a The <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> The <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">normal.\n</a>" "@return The reflected <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n\n</a>" "@ingroup Vectors" )
DefineConsoleFunction(VectorRot , const char * , (Point3F v, F32 angle) , "(Vector3F, float) rotate a vector in 2d" )
DefineConsoleFunction(VectorScale , VectorF , (VectorF a, F32 scalar) , "Scales a vector by a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">scalar.\n</a>" "@param a The vector <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">scale.\n</a>" "@param scalar The scale <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">factor.\n</a>" "@return The vector @a a * @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">scalar.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// VectorScale( %a, %v );\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// Scaling vector a, (ax, ay, az) , but the scalar, v , <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is:\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//a * v)
DefineConsoleFunction(VectorSub , VectorF , (VectorF a, VectorF b) , "Subtract two <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vectors.\n</a>" "@param a The first <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> The second <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@return The vector @a a - @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">b.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// VectorSub( %a, %<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> );\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// The difference of vector a, (ax, ay, az) , and vector b, (bx, by, bz) <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is:\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//a - b)
DefineEngineFunction(getRandomSeed , S32 , () , "Get the current seed used by the random number <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">generator.\n</a>" "@return The current random number generator seed <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">value.\n</a>" "@ingroup Random" )
DefineEngineFunction(setRandomSeed , void , (S32 seed) , (-1) , "Set the current seed <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the random number <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">generator.\n</a>" "Based on this seed, a repeatable sequence of numbers will be produced by getRandom().\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @param seed The seed with which <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> initialize the randon number generator with. The same seed will always leed <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a>" "the same sequence of pseudo-random <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">numbers.\n</a>" "If - 1, the current timestamp will be used as the seed which is a good basis <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">randomization.\n</a>" " @ingroup Random" )
IMPLEMENT_SCOPE(MathTypes , Math , "" )
IMPLEMENT_STRUCT(AngAxisF , AngAxisF , MathTypes , "" )
IMPLEMENT_STRUCT(Box3F , Box3F , MathTypes , "" )
IMPLEMENT_STRUCT(EaseF , EaseF , MathTypes , "" )
IMPLEMENT_STRUCT(MatrixF , MatrixF , MathTypes , "" )
IMPLEMENT_STRUCT(Point2F , Point2F , MathTypes , "" )
IMPLEMENT_STRUCT(Point2I , Point2I , MathTypes , "" )
IMPLEMENT_STRUCT(Point3F , Point3F , MathTypes , "" )
IMPLEMENT_STRUCT(Point3I , Point3I , MathTypes , "" )
IMPLEMENT_STRUCT(Point4F , Point4F , MathTypes , "" )
IMPLEMENT_STRUCT(RectF , RectF , MathTypes , "" )
IMPLEMENT_STRUCT(RectI , RectI , MathTypes , "" )
IMPLEMENT_STRUCT(RotationF , RotationF , MathTypes , "" )
IMPLEMENT_STRUCT(TransformF , TransformF , MathTypes , "" )
Detailed Description
Public Variables
Point2I ConsoleGetType (TypePoint2I)
Public Functions
ConsoleFunctionGroupEnd(MatrixMath )
ConsoleGetType(TypeAngAxisF )
ConsoleGetType(TypeBox3F )
ConsoleGetType(TypeEaseF )
ConsoleGetType(TypeMatrixF )
ConsoleGetType(TypePoint2F )
ConsoleGetType(TypePoint3F )
ConsoleGetType(TypePoint3I )
ConsoleGetType(TypePoint4F )
ConsoleGetType(TypeRectF )
ConsoleGetType(TypeRectI )
ConsoleGetType(TypeRotationF )
ConsoleGetType(TypeTransformF )
ConsoleSetType(TypeAngAxisF )
ConsoleSetType(TypeBox3F )
ConsoleSetType(TypeEaseF )
ConsoleSetType(TypeMatrixF )
ConsoleSetType(TypeMatrixPosition )
ConsoleSetType(TypeMatrixRotation )
ConsoleSetType(TypePoint2F )
ConsoleSetType(TypePoint2I )
ConsoleSetType(TypePoint3F )
ConsoleSetType(TypePoint3I )
ConsoleSetType(TypePoint4F )
ConsoleSetType(TypeRectF )
ConsoleSetType(TypeRectI )
ConsoleSetType(TypeRotationF )
ConsoleSetType(TypeTransformF )
ConsoleType(AngAxisF , TypeAngAxisF , AngAxisF , "" )
ConsoleType(Box3F , TypeBox3F , Box3F , "" )
ConsoleType(EaseF , TypeEaseF , EaseF , "" )
ConsoleType(MatrixF , TypeMatrixF , MatrixF , "" )
ConsoleType(MatrixPosition , TypeMatrixPosition , MatrixF , "" )
ConsoleType(MatrixRotation , TypeMatrixRotation , MatrixF , "" )
ConsoleType(Point2F , TypePoint2F , Point2F , "" )
ConsoleType(Point2I , TypePoint2I , Point2I , "" )
ConsoleType(Point3F , TypePoint3F , Point3F , "" )
ConsoleType(Point3I , TypePoint3I , Point3I , "" )
ConsoleType(Point4F , TypePoint4F , Point4F , "" )
ConsoleType(RectF , TypeRectF , RectF , "" )
ConsoleType(RectI , TypeRectI , RectI , "" )
ConsoleType(RotationF , TypeRotationF , RotationF , "" )
ConsoleType(TransformF , TypeTransformF , TransformF , "" )
DefineConsoleFunction(getBoxCenter , Point3F , (Box3F box) , "Get the center point of an axis-aligned <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">box.\n\n</a>" "@param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> A Box3F, in string format using \"minExtentX minExtentY minExtentZ maxExtentX maxExtentY maxExtentZ\"\n" "@return Center of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">box.\n</a>" "@ingroup <a href="/coding/class/structmath/">Math</a>" )
DefineConsoleFunction(getRandom , F32 , (S32 a, S32 b) , (S32_MAX, S32_MAX) , "( int a, int <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> ) " "@brief Returns a random number based on parameters passed <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">in..\n\n</a>" "If no parameters are passed in, getRandom() will return a float between 0.0 and 1.0. If one " "parameter is passed an integer between 0 and the passed in value will be returned. Two parameters will " "return an integer between the specified <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">numbers.\n\n</a>" " @param a If this is the only parameter, a number between 0 and a is returned. Elsewise represents the lower <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">bound.\n</a>" " @param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> Upper bound on the random number. The random number will be<=@a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">b.\n</a>" " @return A pseudo-random integer between @a a and @a b, between 0 and a, or a " "float between 0.0 and 1.1 depending on <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">usage.\n\n</a>" " @note All parameters are optional." " @see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">setRandomSeed\n</a>" " @ingroup Random" )
DefineConsoleFunction(MatrixCreate , TransformF , (VectorF position, AngAxisF orientation) , "Create a transform from the given translation and <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">orientation.\n</a>" "@param position The translation vector <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">transform.\n</a>" "@param orientation The axis and rotation that orients the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">transform.\n</a>" "@return A transform based on the given position and <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">orientation.\n</a>" "@ingroup Matrices" )
DefineConsoleFunction(MatrixCreateFromEuler , TransformF , (Point3F angles) , "@Create a matrix from the given <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">rotations.\n\n</a>" "@param Vector3F X, Y , and Z rotation in *radians *.\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @return A transform based on the given <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">orientation.\n</a>" " @ingroup Matrices" )
DefineConsoleFunction(MatrixMulPoint , Point3F , (TransformF transform, Point3F point) )
DefineConsoleFunction(MatrixMultiply , TransformF , (TransformF left, TransformF right) , "@brief Multiply the two <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">matrices.\n\n</a>" "@param left First <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">transform.\n</a>" "@param right Right <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">transform.\n</a>" "@return Concatenation of the two <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">transforms.\n</a>" "@ingroup Matrices" )
DefineConsoleFunction(MatrixMulVector , VectorF , (TransformF transform, VectorF vector) )
DefineConsoleFunction(VectorAdd , VectorF , (VectorF a, VectorF b) , "Add two <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vectors.\n</a>" "@param a The first <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> The second <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@return The vector @a a + @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">b.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// VectorAdd( %a, %<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> );\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// The sum of vector a, (ax, ay, az) , and vector b, (bx, by, bz) <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is:\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//a+ b)
DefineConsoleFunction(VectorCross , VectorF , (VectorF a, VectorF b) , "Calculcate the cross product of two <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vectors.\n</a>" "@param a The first <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> The second <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@return The cross product @a x @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">b.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// VectorCross( %a, %<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> );\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// The cross product of vector a, (ax, ay, az) , and vector b, (bx, by, bz) , <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//a x b)
DefineConsoleFunction(VectorDist , F32 , (VectorF a, VectorF b) , "Compute the distance between two <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vectors.\n</a>" "@param a The first <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> The second <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@return The length( @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> - @a a ).\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// VectorDist( %a, %<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> );\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// The distance between vector a, (ax, ay, az) , and vector b, (bx, by, bz) , <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//a -> b)
DefineConsoleFunction(VectorDiv , VectorF , (VectorF a, VectorF b) , "Divide two <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vectors.\n</a>" "@param a The first <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> The second <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@return The vector @a a / @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">b.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// VectorDiv( %a, %<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> );\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// The division of vector a, (ax, ay, az) , and vector b, (bx, by, bz) <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is:\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//a * b)
DefineConsoleFunction(VectorDot , F32 , (VectorF a, VectorF b) , "Compute the dot product of two <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vectors.\n</a>" "@param a The first <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> The second <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@return The dot product @a a * @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">b.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// VectorDot( %a, %<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> );\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// The dot product between vector a, (ax, ay, az) , and vector b, (bx, by, bz) , <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is:\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//a . b)
DefineConsoleFunction(VectorLen , F32 , (VectorF v) , "Calculate the magnitude of the given <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@param v A <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@return The length of vector @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">v.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// VectorLen( %a );\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// The length or magnitude of vector a, (ax, ay, az) , <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is:\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//||a|| )
DefineConsoleFunction(VectorLerp , VectorF , (VectorF a, VectorF b, F32 t) , "Linearly interpolate between two vectors by @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">t.\n</a>" "@param a <a href="/coding/class/classvector/">Vector</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> start interpolation <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">from.\n</a>" "@param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> <a href="/coding/class/classvector/">Vector</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> interpolate <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">to.\n</a>" "@param <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a21feba301403a65090791a94f26c9d92">t</a> Interpolation factor (0-1). At zero, @a a is returned and at one, @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> is returned. In between, an interpolated vector " "between @a a and @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">returned.\n</a>" " @return An interpolated vector between @a a and @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">b.\n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//VectorLerp(%a, %<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a>);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//The point between vector a, (ax, ay, az) , and vector b, (bx, by, bz) , which <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is\n</a>" "//weighted by the interpolation factor, <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a21feba301403a65090791a94f26c9d92">t</a> , <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// r)
DefineConsoleFunction(VectorMidPoint , VectorF , (VectorF a, VectorF b) , "Gets the midpoint between the two <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vectors.\n</a>" "@param a The first <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> The second <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@return The vector (@a a + @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a>) / 2.\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// VectorMidPoint( %a, %<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> );\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// The midpoint of vector a, (ax, ay, az) , and vector b, (bx, by, bz) <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is:\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//(a+<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a>)/ 2, (az+bz)/ 2)
DefineConsoleFunction(VectorMul , VectorF , (VectorF a, VectorF b) , "Multiplies two <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vectors.\n</a>" "@param a The first <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> The second <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@return The vector @a a * @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">b.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// VectorMul( %a, %<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> );\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// The multiplication of vector a, (ax, ay, az) , and vector b, (bx, by, bz) <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is:\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//a * b)
DefineConsoleFunction(VectorNormalize , VectorF , (VectorF v) , "Brings a vector into its unit form, i.e. such that it has the magnitute 1.\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @param v The vector <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">normalize.\n</a>" " @return The vector @a v scaled <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> length 1.\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//VectorNormalize(%a);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//The normalized vector a, (ax, ay, az) , <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is:\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//a^ )
DefineConsoleFunction(VectorOrthoBasis , MatrixF , (AngAxisF aa) , "Create an orthogonal basis from the given <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@param aaf The vector <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> create the orthogonal basis <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">from.\n</a>" "@return A matrix representing the orthogonal <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">basis.\n</a>" "@ingroup Vectors" )
DefineConsoleFunction(VectorReflect , VectorF , (VectorF vec, VectorF normal) , "Compute the reflection of a vector based on a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">normal.\n</a>" "@param a The <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> The <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">normal.\n</a>" "@return The reflected <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n\n</a>" "@ingroup Vectors" )
DefineConsoleFunction(VectorRot , const char * , (Point3F v, F32 angle) , "(Vector3F, float) rotate a vector in 2d" )
DefineConsoleFunction(VectorScale , VectorF , (VectorF a, F32 scalar) , "Scales a vector by a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">scalar.\n</a>" "@param a The vector <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">scale.\n</a>" "@param scalar The scale <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">factor.\n</a>" "@return The vector @a a * @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">scalar.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// VectorScale( %a, %v );\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// Scaling vector a, (ax, ay, az) , but the scalar, v , <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is:\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//a * v)
DefineConsoleFunction(VectorSub , VectorF , (VectorF a, VectorF b) , "Subtract two <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vectors.\n</a>" "@param a The first <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> The second <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vector.\n</a>" "@return The vector @a a - @a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">b.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//-----------------------------------------------------------------------------\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// VectorSub( %a, %<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> );\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// The difference of vector a, (ax, ay, az) , and vector b, (bx, by, bz) <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">is:\n</a>" "//\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//a - b)
DefineEngineFunction(getRandomSeed , S32 , () , "Get the current seed used by the random number <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">generator.\n</a>" "@return The current random number generator seed <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">value.\n</a>" "@ingroup Random" )
DefineEngineFunction(setRandomSeed , void , (S32 seed) , (-1) , "Set the current seed <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the random number <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">generator.\n</a>" "Based on this seed, a repeatable sequence of numbers will be produced by getRandom().\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @param seed The seed with which <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> initialize the randon number generator with. The same seed will always leed <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a>" "the same sequence of pseudo-random <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">numbers.\n</a>" "If - 1, the current timestamp will be used as the seed which is a good basis <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">randomization.\n</a>" " @ingroup Random" )
IMPLEMENT_SCOPE(MathTypes , Math , "" )
IMPLEMENT_STRUCT(AngAxisF , AngAxisF , MathTypes , "" )
IMPLEMENT_STRUCT(Box3F , Box3F , MathTypes , "" )
IMPLEMENT_STRUCT(EaseF , EaseF , MathTypes , "" )
IMPLEMENT_STRUCT(MatrixF , MatrixF , MathTypes , "" )
IMPLEMENT_STRUCT(Point2F , Point2F , MathTypes , "" )
IMPLEMENT_STRUCT(Point2I , Point2I , MathTypes , "" )
IMPLEMENT_STRUCT(Point3F , Point3F , MathTypes , "" )
IMPLEMENT_STRUCT(Point3I , Point3I , MathTypes , "" )
IMPLEMENT_STRUCT(Point4F , Point4F , MathTypes , "" )
IMPLEMENT_STRUCT(RectF , RectF , MathTypes , "" )
IMPLEMENT_STRUCT(RectI , RectI , MathTypes , "" )
IMPLEMENT_STRUCT(RotationF , RotationF , MathTypes , "" )
IMPLEMENT_STRUCT(TransformF , TransformF , MathTypes , "" )
mRandF()
mRandF(F32 f1, F32 f2)
mRandI(S32 i1, S32 i2)
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 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 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#include "core/strings/stringFunctions.h" 25#include "console/consoleTypes.h" 26#include "console/console.h" 27#include "console/engineAPI.h" 28#include "math/mPoint2.h" 29#include "math/mPoint3.h" 30#include "math/mMatrix.h" 31#include "math/mQuat.h" 32#include "math/mRect.h" 33#include "math/mBox.h" 34#include "math/mAngAxis.h" 35#include "math/mTransform.h" 36#include "math/mathTypes.h" 37#include "math/mRandom.h" 38#include "math/mEase.h" 39#include "math/mathUtils.h" 40#include "math/mRotation.h" 41#include "core/strings/stringUnit.h" 42 43IMPLEMENT_SCOPE( MathTypes, Math,, "" ); 44 45IMPLEMENT_STRUCT( Point2I, 46 Point2I, MathTypes, 47 "" ) 48 49 FIELD( x, x, 1, "<a href="/coding/namespace/namespacerazerhydrautil/#namespacerazerhydrautil_1a11c85cfe8843637b62a763d17949965dae8dfc01bae2100bf825946e9ab4aa0e3">X</a> coordinate." ) 50 FIELD( y, y, 1, "<a href="/coding/namespace/namespacerazerhydrautil/#namespacerazerhydrautil_1a11c85cfe8843637b62a763d17949965da4b172ac256416a167161f9511017baae">Y</a> coordinate." ) 51 52END_IMPLEMENT_STRUCT; 53IMPLEMENT_STRUCT( Point2F, 54 Point2F, MathTypes, 55 "" ) 56 57 FIELD( x, x, 1, "<a href="/coding/namespace/namespacerazerhydrautil/#namespacerazerhydrautil_1a11c85cfe8843637b62a763d17949965dae8dfc01bae2100bf825946e9ab4aa0e3">X</a> coordinate." ) 58 FIELD( y, y, 1, "<a href="/coding/namespace/namespacerazerhydrautil/#namespacerazerhydrautil_1a11c85cfe8843637b62a763d17949965da4b172ac256416a167161f9511017baae">Y</a> coordinate." ) 59 60END_IMPLEMENT_STRUCT; 61IMPLEMENT_STRUCT( Point3I, 62 Point3I, MathTypes, 63 "" ) 64 65 FIELD( x, x, 1, "<a href="/coding/namespace/namespacerazerhydrautil/#namespacerazerhydrautil_1a11c85cfe8843637b62a763d17949965dae8dfc01bae2100bf825946e9ab4aa0e3">X</a> coordinate." ) 66 FIELD( y, y, 1, "<a href="/coding/namespace/namespacerazerhydrautil/#namespacerazerhydrautil_1a11c85cfe8843637b62a763d17949965da4b172ac256416a167161f9511017baae">Y</a> coordinate." ) 67 FIELD( z, z, 1, "<a href="/coding/namespace/namespacerazerhydrautil/#namespacerazerhydrautil_1a11c85cfe8843637b62a763d17949965da6cb352937ac2ab0e3036d53e2639fd3d">Z</a> coordinate." ) 68 69END_IMPLEMENT_STRUCT; 70IMPLEMENT_STRUCT( Point3F, 71 Point3F, MathTypes, 72 "" ) 73 74 FIELD( x, x, 1, "<a href="/coding/namespace/namespacerazerhydrautil/#namespacerazerhydrautil_1a11c85cfe8843637b62a763d17949965dae8dfc01bae2100bf825946e9ab4aa0e3">X</a> coordinate." ) 75 FIELD( y, y, 1, "<a href="/coding/namespace/namespacerazerhydrautil/#namespacerazerhydrautil_1a11c85cfe8843637b62a763d17949965da4b172ac256416a167161f9511017baae">Y</a> coordinate." ) 76 FIELD( z, z, 1, "<a href="/coding/namespace/namespacerazerhydrautil/#namespacerazerhydrautil_1a11c85cfe8843637b62a763d17949965da6cb352937ac2ab0e3036d53e2639fd3d">Z</a> coordinate." ) 77 78END_IMPLEMENT_STRUCT; 79IMPLEMENT_STRUCT( Point4F, 80 Point4F, MathTypes, 81 "" ) 82 83 FIELD( x, x, 1, "<a href="/coding/namespace/namespacerazerhydrautil/#namespacerazerhydrautil_1a11c85cfe8843637b62a763d17949965dae8dfc01bae2100bf825946e9ab4aa0e3">X</a> coordinate." ) 84 FIELD( y, y, 1, "<a href="/coding/namespace/namespacerazerhydrautil/#namespacerazerhydrautil_1a11c85cfe8843637b62a763d17949965da4b172ac256416a167161f9511017baae">Y</a> coordinate." ) 85 FIELD( z, z, 1, "<a href="/coding/namespace/namespacerazerhydrautil/#namespacerazerhydrautil_1a11c85cfe8843637b62a763d17949965da6cb352937ac2ab0e3036d53e2639fd3d">Z</a> coordinate." ) 86 FIELD( w, w, 1, "W coordinate." ) 87 88END_IMPLEMENT_STRUCT; 89IMPLEMENT_STRUCT( RectI, 90 RectI, MathTypes, 91 "" ) 92END_IMPLEMENT_STRUCT; 93IMPLEMENT_STRUCT( RectF, 94 RectF, MathTypes, 95 "" ) 96END_IMPLEMENT_STRUCT; 97IMPLEMENT_STRUCT( MatrixF, 98 MatrixF, MathTypes, 99 "" ) 100END_IMPLEMENT_STRUCT; 101IMPLEMENT_STRUCT( AngAxisF, 102 AngAxisF, MathTypes, 103 "" ) 104END_IMPLEMENT_STRUCT; 105IMPLEMENT_STRUCT( TransformF, 106 TransformF, MathTypes, 107 "" ) 108END_IMPLEMENT_STRUCT; 109IMPLEMENT_STRUCT( Box3F, 110 Box3F, MathTypes, 111 "" ) 112END_IMPLEMENT_STRUCT; 113IMPLEMENT_STRUCT( EaseF, 114 EaseF, MathTypes, 115 "" ) 116END_IMPLEMENT_STRUCT; 117IMPLEMENT_STRUCT(RotationF, 118 RotationF, MathTypes, 119 "") 120 FIELD(x, x, 1, "<a href="/coding/namespace/namespacerazerhydrautil/#namespacerazerhydrautil_1a11c85cfe8843637b62a763d17949965dae8dfc01bae2100bf825946e9ab4aa0e3">X</a> coordinate.") 121 FIELD(y, y, 1, "<a href="/coding/namespace/namespacerazerhydrautil/#namespacerazerhydrautil_1a11c85cfe8843637b62a763d17949965da4b172ac256416a167161f9511017baae">Y</a> coordinate.") 122 FIELD(z, z, 1, "<a href="/coding/namespace/namespacerazerhydrautil/#namespacerazerhydrautil_1a11c85cfe8843637b62a763d17949965da6cb352937ac2ab0e3036d53e2639fd3d">Z</a> coordinate.") 123 FIELD(w, w, 1, "W coordinate.") 124END_IMPLEMENT_STRUCT; 125 126//----------------------------------------------------------------------------- 127// TypePoint2I 128//----------------------------------------------------------------------------- 129ConsoleType(Point2I, TypePoint2I, Point2I, "") 130ImplementConsoleTypeCasters( TypePoint2I, Point2I ) 131 132ConsoleGetType( TypePoint2I ) 133{ 134 Point2I *pt = (Point2I *) dptr; 135 static const U32 bufSize = 256; 136 char* returnBuffer = Con::getReturnBuffer(bufSize); 137 dSprintf(returnBuffer, bufSize, "%d %d", pt->x, pt->y); 138 return returnBuffer; 139} 140 141ConsoleSetType( TypePoint2I ) 142{ 143 if(argc == 1) 144 dSscanf(argv[0], "%d %d", &((Point2I *) dptr)->x, &((Point2I *) dptr)->y); 145 else if(argc == 2) 146 *((Point2I *) dptr) = Point2I(dAtoi(argv[0]), dAtoi(argv[1])); 147 else 148 Con::printf("Point2I must be set as { x, y } or \"x y\""); 149} 150 151//----------------------------------------------------------------------------- 152// TypePoint2F 153//----------------------------------------------------------------------------- 154ConsoleType(Point2F, TypePoint2F, Point2F, "") 155ImplementConsoleTypeCasters( TypePoint2F, Point2F ) 156 157ConsoleGetType( TypePoint2F ) 158{ 159 Point2F *pt = (Point2F *) dptr; 160 static const U32 bufSize = 256; 161 char* returnBuffer = Con::getReturnBuffer(bufSize); 162 dSprintf(returnBuffer, bufSize, "%g %g", pt->x, pt->y); 163 return returnBuffer; 164} 165 166ConsoleSetType( TypePoint2F ) 167{ 168 if(argc == 1) 169 dSscanf(argv[0], "%g %g", &((Point2F *) dptr)->x, &((Point2F *) dptr)->y); 170 else if(argc == 2) 171 *((Point2F *) dptr) = Point2F(dAtof(argv[0]), dAtof(argv[1])); 172 else 173 Con::printf("Point2F must be set as { x, y } or \"x y\""); 174} 175 176//----------------------------------------------------------------------------- 177// TypePoint3I 178//----------------------------------------------------------------------------- 179ConsoleType(Point3I, TypePoint3I, Point3I, "") 180ImplementConsoleTypeCasters(TypePoint3I, Point3I) 181 182ConsoleGetType( TypePoint3I ) 183{ 184 Point3I *pt = (Point3I *) dptr; 185 static const U32 bufSize = 256; 186 char* returnBuffer = Con::getReturnBuffer(bufSize); 187 dSprintf(returnBuffer, bufSize, "%d %d %d", pt->x, pt->y, pt->z); 188 return returnBuffer; 189} 190 191ConsoleSetType( TypePoint3I ) 192{ 193 if(argc == 1) 194 dSscanf(argv[0], "%d %d %d", &((Point3I *) dptr)->x, &((Point3I *) dptr)->y, &((Point3I *) dptr)->z); 195 else if(argc == 3) 196 *((Point3I *) dptr) = Point3I(dAtoi(argv[0]), dAtoi(argv[1]), dAtoi(argv[2])); 197 else 198 Con::printf("Point3I must be set as { x, y, z } or \"x y z\""); 199} 200 201//----------------------------------------------------------------------------- 202// TypePoint3F 203//----------------------------------------------------------------------------- 204ConsoleType(Point3F, TypePoint3F, Point3F, "") 205ImplementConsoleTypeCasters(TypePoint3F, Point3F) 206 207ConsoleGetType( TypePoint3F ) 208{ 209 Point3F *pt = (Point3F *) dptr; 210 static const U32 bufSize = 256; 211 char* returnBuffer = Con::getReturnBuffer(bufSize); 212 dSprintf(returnBuffer, bufSize, "%g %g %g", pt->x, pt->y, pt->z); 213 return returnBuffer; 214} 215 216ConsoleSetType( TypePoint3F ) 217{ 218 if(argc == 1) 219 dSscanf(argv[0], "%g %g %g", &((Point3F *) dptr)->x, &((Point3F *) dptr)->y, &((Point3F *) dptr)->z); 220 else if(argc == 3) 221 *((Point3F *) dptr) = Point3F(dAtof(argv[0]), dAtof(argv[1]), dAtof(argv[2])); 222 else 223 Con::printf("Point3F must be set as { x, y, z } or \"x y z\""); 224} 225 226//----------------------------------------------------------------------------- 227// TypePoint4F 228//----------------------------------------------------------------------------- 229ConsoleType(Point4F, TypePoint4F, Point4F, "") 230ImplementConsoleTypeCasters( TypePoint4F, Point4F ) 231 232ConsoleGetType( TypePoint4F ) 233{ 234 Point4F *pt = (Point4F *) dptr; 235 static const U32 bufSize = 256; 236 char* returnBuffer = Con::getReturnBuffer(bufSize); 237 dSprintf(returnBuffer, bufSize, "%g %g %g %g", pt->x, pt->y, pt->z, pt->w); 238 return returnBuffer; 239} 240 241ConsoleSetType( TypePoint4F ) 242{ 243 if(argc == 1) 244 dSscanf(argv[0], "%g %g %g %g", &((Point4F *) dptr)->x, &((Point4F *) dptr)->y, &((Point4F *) dptr)->z, &((Point4F *) dptr)->w); 245 else if(argc == 4) 246 *((Point4F *) dptr) = Point4F(dAtof(argv[0]), dAtof(argv[1]), dAtof(argv[2]), dAtof(argv[3])); 247 else 248 Con::printf("Point4F must be set as { x, y, z, w } or \"x y z w\""); 249} 250 251//----------------------------------------------------------------------------- 252// TypeRectI 253//----------------------------------------------------------------------------- 254ConsoleType(RectI, TypeRectI, RectI, "") 255ImplementConsoleTypeCasters( TypeRectI, RectI ) 256 257ConsoleGetType( TypeRectI ) 258{ 259 RectI *rect = (RectI *) dptr; 260 static const U32 bufSize = 256; 261 char* returnBuffer = Con::getReturnBuffer(bufSize); 262 dSprintf(returnBuffer, bufSize, "%d %d %d %d", rect->point.x, rect->point.y, 263 rect->extent.x, rect->extent.y); 264 return returnBuffer; 265} 266 267ConsoleSetType( TypeRectI ) 268{ 269 if(argc == 1) 270 dSscanf(argv[0], "%d %d %d %d", &((RectI *) dptr)->point.x, &((RectI *) dptr)->point.y, 271 &((RectI *) dptr)->extent.x, &((RectI *) dptr)->extent.y); 272 else if(argc == 4) 273 *((RectI *) dptr) = RectI(dAtoi(argv[0]), dAtoi(argv[1]), dAtoi(argv[2]), dAtoi(argv[3])); 274 else 275 Con::printf("RectI must be set as { x, y, w, h } or \"x y w h\""); 276} 277 278//----------------------------------------------------------------------------- 279// TypeRectF 280//----------------------------------------------------------------------------- 281ConsoleType(RectF, TypeRectF, RectF, "") 282ImplementConsoleTypeCasters( TypeRectF, RectF ) 283 284ConsoleGetType( TypeRectF ) 285{ 286 RectF *rect = (RectF *) dptr; 287 static const U32 bufSize = 256; 288 char* returnBuffer = Con::getReturnBuffer(bufSize); 289 dSprintf(returnBuffer, bufSize, "%g %g %g %g", rect->point.x, rect->point.y, 290 rect->extent.x, rect->extent.y); 291 return returnBuffer; 292} 293 294ConsoleSetType( TypeRectF ) 295{ 296 if(argc == 1) 297 dSscanf(argv[0], "%g %g %g %g", &((RectF *) dptr)->point.x, &((RectF *) dptr)->point.y, 298 &((RectF *) dptr)->extent.x, &((RectF *) dptr)->extent.y); 299 else if(argc == 4) 300 *((RectF *) dptr) = RectF(dAtof(argv[0]), dAtof(argv[1]), dAtof(argv[2]), dAtof(argv[3])); 301 else 302 Con::printf("RectF must be set as { x, y, w, h } or \"x y w h\""); 303} 304 305//----------------------------------------------------------------------------- 306// TypeMatrix 307//----------------------------------------------------------------------------- 308ConsoleType(MatrixF, TypeMatrixF, MatrixF, "") 309ImplementConsoleTypeCasters( TypeMatrixF, MatrixF ) 310 311// Oh merry confusion. Torque stores matrices in row-major order yet to TorqueScript 312// matrices were passed in column-major order, so we need to stick to this here. 313 314ConsoleGetType( TypeMatrixF ) 315{ 316 MatrixF* mat = ( MatrixF* ) dptr; 317 318 Point3F col0, col1, col2; 319 mat->getColumn(0, &col0); 320 mat->getColumn(1, &col1); 321 mat->getColumn(2, &col2); 322 static const U32 bufSize = 256; 323 char* returnBuffer = Con::getReturnBuffer(bufSize); 324 dSprintf(returnBuffer,bufSize,"%g %g %g %g %g %g %g %g %g", 325 col0.x, col0.y, col0.z, col1.x, col1.y, col1.z, col2.x, col2.y, col2.z); 326 return returnBuffer; 327} 328 329ConsoleSetType( TypeMatrixF ) 330{ 331 if( argc != 1 ) 332 { 333 Con::errorf( "MatrixF must be set as \"c0x c0y c0z c1x c1y c1z c2x c2y c2z\"" ); 334 return; 335 } 336 337 Point3F col0, col1, col2; 338 dSscanf( argv[ 0 ], "%g %g %g %g %g %g %g %g %g", 339 &col0.x, &col0.y, &col0.z, &col1.x, &col1.y, &col1.z, &col2.x, &col2.y, &col2.z ); 340 341 MatrixF* mat = ( MatrixF* ) dptr; 342 343 mat->setColumn( 0, col0 ); 344 mat->setColumn( 1, col1 ); 345 mat->setColumn( 2, col2 ); 346} 347 348//----------------------------------------------------------------------------- 349// TypeMatrixPosition 350//----------------------------------------------------------------------------- 351ConsoleType(MatrixPosition, TypeMatrixPosition, MatrixF, "") 352 353ConsoleGetType( TypeMatrixPosition ) 354{ 355 F32 *col = (F32 *) dptr + 3; 356 static const U32 bufSize = 256; 357 char* returnBuffer = Con::getReturnBuffer(bufSize); 358 if(col[12] == 1.f) 359 dSprintf(returnBuffer, bufSize, "%g %g %g", col[0], col[4], col[8]); 360 else 361 dSprintf(returnBuffer, bufSize, "%g %g %g %g", col[0], col[4], col[8], col[12]); 362 return returnBuffer; 363} 364 365ConsoleSetType( TypeMatrixPosition ) 366{ 367 F32 *col = ((F32 *) dptr) + 3; 368 if (argc == 1) 369 { 370 col[0] = col[4] = col[8] = 0.f; 371 col[12] = 1.f; 372 dSscanf(argv[0], "%g %g %g %g", &col[0], &col[4], &col[8], &col[12]); 373 } 374 else if (argc <= 4) 375 { 376 for (S32 i = 0; i < argc; i++) 377 col[i << 2] = dAtof(argv[i]); 378 } 379 else 380 Con::printf("Matrix position must be set as { x, y, z, w } or \"x y z w\""); 381} 382 383//----------------------------------------------------------------------------- 384// TypeMatrixRotation 385//----------------------------------------------------------------------------- 386ConsoleType(MatrixRotation, TypeMatrixRotation, MatrixF, "") 387 388ConsoleGetType( TypeMatrixRotation ) 389{ 390 AngAxisF aa(*(MatrixF *) dptr); 391 aa.axis.normalize(); 392 static const U32 bufSize = 256; 393 char* returnBuffer = Con::getReturnBuffer(bufSize); 394 dSprintf(returnBuffer,bufSize,"%g %g %g %g",aa.axis.x,aa.axis.y,aa.axis.z,mRadToDeg(aa.angle)); 395 return returnBuffer; 396} 397 398ConsoleSetType( TypeMatrixRotation ) 399{ 400 // DMM: Note that this will ONLY SET the ULeft 3x3 submatrix. 401 // 402 AngAxisF aa(Point3F(0,0,0),0); 403 if (argc == 1) 404 { 405 dSscanf(argv[0], "%g %g %g %g", &aa.axis.x, &aa.axis.y, &aa.axis.z, &aa.angle); 406 aa.angle = mDegToRad(aa.angle); 407 } 408 else if (argc == 4) 409 { 410 for (S32 i = 0; i < argc; i++) 411 ((F32*)&aa)[i] = dAtof(argv[i]); 412 aa.angle = mDegToRad(aa.angle); 413 } 414 else 415 Con::printf("Matrix rotation must be set as { x, y, z, angle } or \"x y z angle\""); 416 417 // 418 MatrixF temp; 419 aa.setMatrix(&temp); 420 421 F32* pDst = *(MatrixF *)dptr; 422 const F32* pSrc = temp; 423 for (U32 i = 0; i < 3; i++) 424 for (U32 j = 0; j < 3; j++) 425 pDst[i*4 + j] = pSrc[i*4 + j]; 426} 427 428//----------------------------------------------------------------------------- 429// TypeAngAxisF 430//----------------------------------------------------------------------------- 431ConsoleType(AngAxisF, TypeAngAxisF, AngAxisF, "") 432ImplementConsoleTypeCasters( TypeAngAxisF, AngAxisF ) 433 434ConsoleGetType( TypeAngAxisF ) 435{ 436 AngAxisF* aa = ( AngAxisF* ) dptr; 437 static const U32 bufSize = 256; 438 char* returnBuffer = Con::getReturnBuffer(bufSize); 439 dSprintf(returnBuffer,bufSize,"%g %g %g %g",aa->axis.x,aa->axis.y,aa->axis.z,mRadToDeg(aa->angle)); 440 return returnBuffer; 441} 442 443ConsoleSetType( TypeAngAxisF ) 444{ 445 // DMM: Note that this will ONLY SET the ULeft 3x3 submatrix. 446 // 447 AngAxisF* aa = ( AngAxisF* ) dptr; 448 if (argc == 1) 449 { 450 dSscanf(argv[0], "%g %g %g %g", &aa->axis.x, &aa->axis.y, &aa->axis.z, &aa->angle); 451 aa->angle = mDegToRad(aa->angle); 452 } 453 else if (argc == 4) 454 { 455 for (S32 i = 0; i < argc; i++) 456 ((F32*)&aa)[i] = dAtof(argv[i]); 457 aa->angle = mDegToRad(aa->angle); 458 } 459 else 460 Con::printf("AngAxisF must be set as { x, y, z, angle } or \"x y z angle\""); 461} 462 463 464//----------------------------------------------------------------------------- 465// TypeTransformF 466//----------------------------------------------------------------------------- 467 468const TransformF TransformF::Identity( Point3F::Zero, AngAxisF( Point3F( 0, 0, 1 ), 0) ); 469 470ConsoleType(TransformF, TypeTransformF, TransformF, "") 471ImplementConsoleTypeCasters( TypeTransformF, TransformF ) 472 473ConsoleGetType( TypeTransformF ) 474{ 475 TransformF* aa = ( TransformF* ) dptr; 476 static const U32 bufSize = 256; 477 char* returnBuffer = Con::getReturnBuffer(bufSize); 478 dSprintf( returnBuffer, bufSize, "%g %g %g %g %g %g %g", 479 aa->mPosition.x, aa->mPosition.y, aa->mPosition.z, 480 aa->mOrientation.axis.x, aa->mOrientation.axis.y, aa->mOrientation.axis.z, aa->mOrientation.angle ); 481 return returnBuffer; 482} 483 484ConsoleSetType( TypeTransformF ) 485{ 486 TransformF* aa = ( TransformF* ) dptr; 487 if( argc == 1 ) 488 { 489 U32 count = dSscanf( argv[ 0 ], "%g %g %g %g %g %g %g", 490 &aa->mPosition.x, &aa->mPosition.y, &aa->mPosition.z, 491 &aa->mOrientation.axis.x, &aa->mOrientation.axis.y, &aa->mOrientation.axis.z, &aa->mOrientation.angle ); 492 493 aa->mHasRotation = ( count == 7 ); 494 } 495 else if( argc == 7 ) 496 { 497 aa->mPosition.x = dAtof( argv[ 0 ] ); 498 aa->mPosition.y = dAtof( argv[ 1 ] ); 499 aa->mPosition.z = dAtof( argv[ 2 ] ); 500 aa->mOrientation.axis.x = dAtof( argv[ 3 ] ); 501 aa->mOrientation.axis.y = dAtof( argv[ 4 ] ); 502 aa->mOrientation.axis.z = dAtof( argv[ 5 ] ); 503 aa->mOrientation.angle = dAtof( argv[ 6 ] ); 504 } 505 else 506 Con::errorf( "TransformF must be set as { px, py, pz, x, y, z, angle } or \"px py pz x y z angle\""); 507} 508 509 510 511//----------------------------------------------------------------------------- 512// TypeBox3F 513//----------------------------------------------------------------------------- 514ConsoleType(Box3F, TypeBox3F, Box3F, "") 515ImplementConsoleTypeCasters( TypeBox3F, Box3F ) 516 517ConsoleGetType( TypeBox3F ) 518{ 519 const Box3F* pBox = (const Box3F*)dptr; 520 521 static const U32 bufSize = 256; 522 char* returnBuffer = Con::getReturnBuffer(bufSize); 523 dSprintf(returnBuffer, bufSize, "%g %g %g %g %g %g", 524 pBox->minExtents.x, pBox->minExtents.y, pBox->minExtents.z, 525 pBox->maxExtents.x, pBox->maxExtents.y, pBox->maxExtents.z); 526 527 return returnBuffer; 528} 529 530ConsoleSetType( TypeBox3F ) 531{ 532 Box3F* pDst = (Box3F*)dptr; 533 534 if (argc == 1) 535 { 536 U32 args = dSscanf(argv[0], "%g %g %g %g %g %g", 537 &pDst->minExtents.x, &pDst->minExtents.y, &pDst->minExtents.z, 538 &pDst->maxExtents.x, &pDst->maxExtents.y, &pDst->maxExtents.z); 539 AssertWarn(args == 6, "Warning, box probably not read properly"); 540 } 541 else 542 { 543 Con::printf("Box3F must be set as \"xMin yMin zMin xMax yMax zMax\""); 544 } 545} 546 547 548//----------------------------------------------------------------------------- 549// TypeEaseF 550//----------------------------------------------------------------------------- 551ConsoleType(EaseF, TypeEaseF, EaseF, "") 552ImplementConsoleTypeCasters( TypeEaseF, EaseF ) 553 554ConsoleGetType( TypeEaseF ) 555{ 556 const EaseF* pEase = (const EaseF*)dptr; 557 558 static const U32 bufSize = 256; 559 char* returnBuffer = Con::getReturnBuffer(bufSize); 560 dSprintf(returnBuffer, bufSize, "%d %d %g %g", 561 pEase->dir, pEase->type, pEase->param[0], pEase->param[1]); 562 563 return returnBuffer; 564} 565 566ConsoleSetType( TypeEaseF ) 567{ 568 EaseF* pDst = (EaseF*)dptr; 569 570 // defaults... 571 pDst->param[0] = -1.0f; 572 pDst->param[1] = -1.0f; 573 if (argc == 1) { 574 U32 args = dSscanf(argv[0], "%d %d %f %f", // the two params are optional and assumed -1 if not present... 575 &pDst->dir, &pDst->type, &pDst->param[0],&pDst->param[1]); 576 if( args < 2 ) 577 Con::warnf( "Warning, EaseF probably not read properly" ); 578 } else { 579 Con::printf("EaseF must be set as \"dir type [param0 param1]\""); 580 } 581} 582 583//----------------------------------------------------------------------------- 584// TypeRotationF 585//----------------------------------------------------------------------------- 586ConsoleType(RotationF, TypeRotationF, RotationF, "") 587ImplementConsoleTypeCasters( TypeRotationF, RotationF ) 588 589ConsoleGetType(TypeRotationF) 590{ 591 RotationF *pt = (RotationF *)dptr; 592 static const U32 bufSize = 256; 593 char* returnBuffer = Con::getReturnBuffer(bufSize); 594 595 EulerF out = pt->asEulerF(RotationF::Degrees); 596 dSprintf(returnBuffer, bufSize, "%g %g %g", out.x, out.y, out.z); 597 598 return returnBuffer; 599} 600 601ConsoleSetType(TypeRotationF) 602{ 603 if (argc == 1) 604 { 605 U32 elements = StringUnit::getUnitCount(argv[0], " \t\n"); 606 if (elements == 3) 607 { 608 EulerF in; 609 dSscanf(argv[0], "%g %g %g", &in.x, &in.y, &in.z); 610 ((RotationF *)dptr)->set(in, RotationF::Degrees); 611 } 612 else 613 { 614 AngAxisF in; 615 dSscanf(argv[0], "%g %g %g %g", &in.axis.x, &in.axis.y, &in.axis.z, &in.angle); 616 ((RotationF *)dptr)->set(in, RotationF::Degrees); 617 } 618 } 619 else if (argc == 3) 620 { 621 EulerF in(dAtof(argv[0]), dAtof(argv[1]), dAtof(argv[2])); 622 ((RotationF *)dptr)->set(in, RotationF::Degrees); 623 } 624 else if (argc == 4) 625 { 626 AngAxisF in(Point3F(dAtof(argv[0]), dAtof(argv[1]), dAtof(argv[2])), dAtof(argv[3])); 627 ((RotationF *)dptr)->set(in, RotationF::Degrees); 628 } 629 else 630 Con::printf("RotationF must be set as { x, y, z, w } or \"x y z w\""); 631} 632 633//----------------------------------------------------------------------------- 634 635DefineConsoleFunction( VectorAdd, VectorF, ( VectorF a, VectorF b ),, 636 "Add two vectors.\n" 637 "@param a The first vector.\n" 638 "@param b The second vector.\n" 639 "@return The vector @a a + @a b.\n\n" 640 "@tsexample\n" 641 "//-----------------------------------------------------------------------------\n" 642 "//\n" 643 "// VectorAdd( %a, %b );\n" 644 "//\n" 645 "// The sum of vector a, (ax, ay, az), and vector b, (bx, by, bz) is:\n" 646 "//\n" 647 "// a + b = ( ax + bx, ay + by, az + bz )\n" 648 "//\n" 649 "//-----------------------------------------------------------------------------\n" 650 "%a = \"1 0 0\";\n" 651 "%b = \"0 1 0\";\n\n" 652 "// %r = \"( 1 + 0, 0 + 1, 0 + 0 )\";\n" 653 "// %r = \"1 1 0\";\n" 654 "%r = VectorAdd( %a, %b );\n" 655 "@endtsexample\n\n" 656 "@ingroup Vectors") 657{ 658 return a + b; 659} 660 661//----------------------------------------------------------------------------- 662 663DefineConsoleFunction( VectorSub, VectorF, ( VectorF a, VectorF b ),, 664 "Subtract two vectors.\n" 665 "@param a The first vector.\n" 666 "@param b The second vector.\n" 667 "@return The vector @a a - @a b.\n\n" 668 "@tsexample\n" 669 "//-----------------------------------------------------------------------------\n" 670 "//\n" 671 "// VectorSub( %a, %b );\n" 672 "//\n" 673 "// The difference of vector a, (ax, ay, az), and vector b, (bx, by, bz) is:\n" 674 "//\n" 675 "// a - b = ( ax - bx, ay - by, az - bz )\n" 676 "//\n" 677 "//-----------------------------------------------------------------------------\n\n" 678 679 "%a = \"1 0 0\";\n" 680 "%b = \"0 1 0\";\n\n" 681 682 "// %r = \"( 1 - 0, 0 - 1, 0 - 0 )\";\n" 683 "// %r = \"1 -1 0\";\n" 684 "%r = VectorSub( %a, %b );\n" 685 "@endtsexample\n\n" 686 "@ingroup Vectors" ) 687{ 688 return a - b; 689} 690 691//----------------------------------------------------------------------------- 692 693DefineConsoleFunction( VectorScale, VectorF, ( VectorF a, F32 scalar ),, 694 "Scales a vector by a scalar.\n" 695 "@param a The vector to scale.\n" 696 "@param scalar The scale factor.\n" 697 "@return The vector @a a * @a scalar.\n\n" 698 "@tsexample\n" 699 "//-----------------------------------------------------------------------------\n" 700 "//\n" 701 "// VectorScale( %a, %v );\n" 702 "//\n" 703 "// Scaling vector a, (ax, ay, az), but the scalar, v, is:\n" 704 "//\n" 705 "// a * v = ( ax * v, ay * v, az * v )\n" 706 "//\n" 707 "//-----------------------------------------------------------------------------\n\n" 708 709 "%a = \"1 1 0\";\n" 710 "%v = \"2\";\n\n" 711 712 "// %r = \"( 1 * 2, 1 * 2, 0 * 2 )\";\n" 713 "// %r = \"2 2 0\";\n" 714 "%r = VectorScale( %a, %v );\n" 715 "@endtsexample\n\n" 716 "@ingroup Vectors" ) 717{ 718 return a * scalar; 719} 720DefineConsoleFunction( VectorMul, VectorF, ( VectorF a, VectorF b ),, 721 "Multiplies two vectors.\n" 722 "@param a The first vector.\n" 723 "@param b The second vector.\n" 724 "@return The vector @a a * @a b.\n\n" 725 "@tsexample\n" 726 "//-----------------------------------------------------------------------------\n" 727 "//\n" 728 "// VectorMul( %a, %b );\n" 729 "//\n" 730 "// The multiplication of vector a, (ax, ay, az), and vector b, (bx, by, bz) is:\n" 731 "//\n" 732 "// a * b = ( ax * bx, ay * by, az * bz )\n" 733 "//\n" 734 "//-----------------------------------------------------------------------------\n\n" 735 736 "%a = \"1 0 0\";\n" 737 "%b = \"0 1 0\";\n\n" 738 739 "// %r = \"( 1 * 0, 0 * 1, 0 * 0 )\";\n" 740 "// %r = \"0 0 0\";\n" 741 "%r = VectorMul( %a, %b );\n" 742 "@endtsexample\n\n" 743 "@ingroup Vectors" ) 744{ 745 return a * b; 746} 747 748DefineConsoleFunction( VectorDiv, VectorF, ( VectorF a, VectorF b ),, 749 "Divide two vectors.\n" 750 "@param a The first vector.\n" 751 "@param b The second vector.\n" 752 "@return The vector @a a / @a b.\n\n" 753 "@tsexample\n" 754 "//-----------------------------------------------------------------------------\n" 755 "//\n" 756 "// VectorDiv( %a, %b );\n" 757 "//\n" 758 "// The division of vector a, (ax, ay, az), and vector b, (bx, by, bz) is:\n" 759 "//\n" 760 "// a * b = ( ax / bx, ay / by, az / bz )\n" 761 "//\n" 762 "//-----------------------------------------------------------------------------\n\n" 763 764 "%a = \"1 1 1\";\n" 765 "%b = \"2 2 2\";\n\n" 766 767 "// %r = \"( 1 / 2, 1 / 2, 1 / 2 )\";\n" 768 "// %r = \"0.5 0.5 0.5\";\n" 769 "%r = VectorDiv( %a, %b );\n" 770 "@endtsexample\n\n" 771 "@ingroup Vectors" ) 772{ 773 //this is kind of bad, but so is dividing by 0 774 if(b.x == 0) b.x = 0.000001f; 775 if(b.y == 0) b.y = 0.000001f; 776 if(b.z == 0) b.z = 0.000001f; 777 778 return a / b; 779} 780 781//----------------------------------------------------------------------------- 782 783DefineConsoleFunction( VectorNormalize, VectorF, ( VectorF v ),, 784 "Brings a vector into its unit form, i.e. such that it has the magnitute 1.\n" 785 "@param v The vector to normalize.\n" 786 "@return The vector @a v scaled to length 1.\n\n" 787 "@tsexample\n" 788 "//-----------------------------------------------------------------------------\n" 789 "//\n" 790 "// VectorNormalize( %a );\n" 791 "//\n" 792 "// The normalized vector a, (ax, ay, az), is:\n" 793 "//\n" 794 "// a^ = a / ||a||\n" 795 "// = ( ax / ||a||, ay / ||a||, az / ||a|| )\n" 796 "//\n" 797 "//-----------------------------------------------------------------------------\n\n" 798 799 "%a = \"1 1 0\";\n" 800 "%l = 1.414;\n\n" 801 802 "// %r = \"( 1 / 1.141, 1 / 1.141, 0 / 1.141 )\";\n" 803 "// %r = \"0.707 0.707 0\";\n" 804 "%r = VectorNormalize( %a );\n" 805 "@endtsexample\n\n" 806 "@ingroup Vectors" ) 807{ 808 VectorF n( v ); 809 n.normalizeSafe(); 810 return n; 811} 812 813//----------------------------------------------------------------------------- 814 815DefineConsoleFunction( VectorDot, F32, ( VectorF a, VectorF b ),, 816 "Compute the dot product of two vectors.\n" 817 "@param a The first vector.\n" 818 "@param b The second vector.\n" 819 "@return The dot product @a a * @a b.\n\n" 820 "@tsexample\n" 821 "//-----------------------------------------------------------------------------\n" 822 "//\n" 823 "// VectorDot( %a, %b );\n" 824 "//\n" 825 "// The dot product between vector a, (ax, ay, az), and vector b, (bx, by, bz), is:\n" 826 "//\n" 827 "// a . b = ( ax * bx + ay * by + az * bz )\n" 828 "//\n" 829 "//-----------------------------------------------------------------------------\n\n" 830 831 "%a = \"1 1 0\";\n" 832 "%b = \"2 0 1\";\n\n" 833 834 "// %r = \"( 1 * 2 + 1 * 0 + 0 * 1 )\";\n" 835 "// %r = 2;\n" 836 "%r = VectorDot( %a, %b );\n" 837 "@endtsexample\n\n" 838 "@ingroup Vectors" ) 839{ 840 return mDot( a, b ); 841} 842 843//----------------------------------------------------------------------------- 844 845DefineConsoleFunction( VectorCross, VectorF, ( VectorF a, VectorF b ),, 846 "Calculcate the cross product of two vectors.\n" 847 "@param a The first vector.\n" 848 "@param b The second vector.\n" 849 "@return The cross product @a x @a b.\n\n" 850 "@tsexample\n" 851 "//-----------------------------------------------------------------------------\n" 852 "//\n" 853 "// VectorCross( %a, %b );\n" 854 "//\n" 855 "// The cross product of vector a, (ax, ay, az), and vector b, (bx, by, bz), is\n" 856 "//\n" 857 "// a x b = ( ( ay * bz ) - ( az * by ), ( az * bx ) - ( ax * bz ), ( ax * by ) - ( ay * bx ) )\n" 858 "//\n" 859 "//-----------------------------------------------------------------------------\n\n" 860 861 "%a = \"1 1 0\";\n" 862 "%b = \"2 0 1\";\n\n" 863 864 "// %r = \"( ( 1 * 1 ) - ( 0 * 0 ), ( 0 * 2 ) - ( 1 * 1 ), ( 1 * 0 ) - ( 1 * 2 ) )\";\n" 865 "// %r = \"1 -1 -2\";\n" 866 "%r = VectorCross( %a, %b );\n" 867 "@endtsexample\n\n" 868 "@ingroup Vectors" ) 869{ 870 VectorF v; 871 mCross( a, b, &v ); 872 return v; 873} 874 875//----------------------------------------------------------------------------- 876 877DefineConsoleFunction( VectorDist, F32, ( VectorF a, VectorF b ),, 878 "Compute the distance between two vectors.\n" 879 "@param a The first vector.\n" 880 "@param b The second vector.\n" 881 "@return The length( @a b - @a a ).\n\n" 882 "@tsexample\n" 883 "//-----------------------------------------------------------------------------\n" 884 "//\n" 885 "// VectorDist( %a, %b );\n" 886 "//\n" 887 "// The distance between vector a, (ax, ay, az), and vector b, (bx, by, bz), is\n" 888 "//\n" 889 "// a -> b = ||( b - a )||\n" 890 "// = ||( bx - ax, by - ay, bz - az )||\n" 891 "// = mSqrt( ( bx - ax ) * ( bx - ax ) + ( by - ay ) * ( by - ay ) + ( bz - az ) * ( bz - az ) )\n" 892 "//\n" 893 "//-----------------------------------------------------------------------------\n\n" 894 895 "%a = \"1 1 0\";\n" 896 "%b = \"2 0 1\";\n\n" 897 898 "// %r = mSqrt( ( 2 - 1 ) * ( 2 - 1) + ( 0 - 1 ) * ( 0 - 1 ) + ( 1 - 0 ) * ( 1 - 0 ) );\n" 899 "// %r = mSqrt( 3 );\n" 900 "%r = VectorDist( %a, %b );\n" 901 "@endtsexample\n\n" 902 "@ingroup Vectors" ) 903{ 904 VectorF v = b - a; 905 return v.len(); 906} 907 908//----------------------------------------------------------------------------- 909 910DefineConsoleFunction( VectorMidPoint, VectorF, ( VectorF a, VectorF b ),, 911 "Gets the midpoint between the two vectors.\n" 912 "@param a The first vector.\n" 913 "@param b The second vector.\n" 914 "@return The vector (@a a + @a b) / 2.\n\n" 915 "@tsexample\n" 916 "//-----------------------------------------------------------------------------\n" 917 "//\n" 918 "// VectorMidPoint( %a, %b );\n" 919 "//\n" 920 "// The midpoint of vector a, (ax, ay, az), and vector b, (bx, by, bz) is:\n" 921 "//\n" 922 "// (a + b)/2 = ( (ax + bx) /2, ay + by) /2, (az + bz) /2 )\n" 923 "//\n" 924 "//-----------------------------------------------------------------------------\n" 925// "%a = \"1 0 0\";\n" 926// "%b = \"0 1 0\";\n\n" 927// "// %r = \"( 1 + 0, 0 + 1, 0 + 0 )\";\n" 928// "// %r = \"1 1 0\";\n" 929// "%r = VectorAdd( %a, %b );\n" 930 "@endtsexample\n\n" 931 "@ingroup Vectors") 932{ 933 return (a + b)/2.0f; 934} 935 936//----------------------------------------------------------------------------- 937 938DefineConsoleFunction( VectorLen, F32, ( VectorF v ),, 939 "Calculate the magnitude of the given vector.\n" 940 "@param v A vector.\n" 941 "@return The length of vector @a v.\n\n" 942 "@tsexample\n" 943 "//-----------------------------------------------------------------------------\n" 944 "//\n" 945 "// VectorLen( %a );\n" 946 "//\n" 947 "// The length or magnitude of vector a, (ax, ay, az), is:\n" 948 "//\n" 949 "// ||a|| = Sqrt( ax * ax + ay * ay + az * az )\n" 950 "//\n" 951 "//-----------------------------------------------------------------------------\n\n" 952 953 "%a = \"1 1 0\";\n\n" 954 955 "// %r = mSqrt( 1 * 1 + 1 * 1 + 0 * 0 );\n" 956 "// %r = mSqrt( 2 );\n" 957 "// %r = 1.414;\n" 958 "%r = VectorLen( %a );\n" 959 "@endtsexample\n\n" 960 "@ingroup Vectors" ) 961{ 962 return v.len(); 963} 964 965//----------------------------------------------------------------------------- 966 967DefineConsoleFunction( VectorOrthoBasis, MatrixF, ( AngAxisF aa ),, 968 "Create an orthogonal basis from the given vector.\n" 969 "@param aaf The vector to create the orthogonal basis from.\n" 970 "@return A matrix representing the orthogonal basis.\n" 971 "@ingroup Vectors" ) 972{ 973 MatrixF mat; 974 aa.setMatrix(&mat); 975 return mat; 976} 977 978//----------------------------------------------------------------------------- 979 980//ConsoleFunction(VectorRot, const char*, 3, 3, "(Vector3F, float) rotate a vector in 2d") 981DefineConsoleFunction( VectorRot, const char*, (Point3F v, F32 angle), , "(Vector3F, float) rotate a vector in 2d") 982{ 983 //VectorF v(0,0,0); 984 //dSscanf(argv[1],"%g %g %g",&v.x,&v.y,&v.z); 985 //dSscanf(axeStr,"%g %g %g",&v.x,&v.y,&v.z); 986 987 //float angle = dAtof(argv[2]); 988 //float angle = dAtof(angleStr); 989 990 float x = 0, y = 0; 991 992 x = v.x * cos(angle) - v.y * sin(angle); 993 y = v.x * sin(angle) + v.y * cos(angle); 994 995 char* returnBuffer = Con::getReturnBuffer(256); 996 dSprintf(returnBuffer,256,"%g %g %g", x, y, v.z); 997 return returnBuffer; 998} 999 1000DefineConsoleFunction( VectorLerp, VectorF, ( VectorF a, VectorF b, F32 t ),, 1001 "Linearly interpolate between two vectors by @a t.\n" 1002 "@param a Vector to start interpolation from.\n" 1003 "@param b Vector to interpolate to.\n" 1004 "@param t Interpolation factor (0-1). At zero, @a a is returned and at one, @a b is returned. In between, an interpolated vector " 1005 "between @a a and @a b is returned.\n" 1006 "@return An interpolated vector between @a a and @a b.\n\n" 1007 "@tsexample\n" 1008 "//-----------------------------------------------------------------------------\n" 1009 "//\n" 1010 "// VectorLerp( %a, %b );\n" 1011 "//\n" 1012 "// The point between vector a, (ax, ay, az), and vector b, (bx, by, bz), which is\n" 1013 "// weighted by the interpolation factor, t, is\n" 1014 "//\n" 1015 "// r = a + t * ( b - a )\n" 1016 "// = ( ax + t * ( bx - ax ), ay + t * ( by - ay ), az + t * ( bz - az ) )\n" 1017 "//\n" 1018 "//-----------------------------------------------------------------------------\n\n" 1019 1020 "%a = \"1 1 0\";\n" 1021 "%b = \"2 0 1\";\n" 1022 "%v = \"0.25\";\n\n" 1023 1024 "// %r = \"( 1 + 0.25 * ( 2 - 1 ), 1 + 0.25 * ( 0 - 1 ), 0 + 0.25 * ( 1 - 0 ) )\";\n" 1025 "// %r = \"1.25 0.75 0.25\";\n" 1026 "%r = VectorLerp( %a, %b );\n" 1027 "@endtsexample\n\n" 1028 "@ingroup Vectors" ) 1029{ 1030 VectorF c; 1031 c.interpolate( a, b, t ); 1032 1033 return c; 1034} 1035 1036DefineConsoleFunction(VectorReflect, VectorF, (VectorF vec, VectorF normal), , 1037 "Compute the reflection of a vector based on a normal.\n" 1038 "@param a The vector.\n" 1039 "@param b The normal.\n" 1040 "@return The reflected vector.\n\n" 1041 "@ingroup Vectors") 1042{ 1043 normal.normalize(); 1044 1045 return MathUtils::reflect(vec, normal); 1046} 1047 1048//----------------------------------------------------------------------------- 1049 1050DefineConsoleFunction( MatrixCreate, TransformF, ( VectorF position, AngAxisF orientation ),, 1051 "Create a transform from the given translation and orientation.\n" 1052 "@param position The translation vector for the transform.\n" 1053 "@param orientation The axis and rotation that orients the transform.\n" 1054 "@return A transform based on the given position and orientation.\n" 1055 "@ingroup Matrices" ) 1056{ 1057 TransformF transform( position, orientation ); 1058 return transform; 1059} 1060 1061//----------------------------------------------------------------------------- 1062 1063DefineConsoleFunction( MatrixCreateFromEuler, TransformF, ( Point3F angles ),, 1064 "@Create a matrix from the given rotations.\n\n" 1065 "@param Vector3F X, Y, and Z rotation in *radians*.\n" 1066 "@return A transform based on the given orientation.\n" 1067 "@ingroup Matrices" ) 1068{ 1069 QuatF rotQ( angles ); 1070 AngAxisF aa; 1071 aa.set(rotQ); 1072 1073 return TransformF( Point3F::Zero, aa ); 1074} 1075 1076//----------------------------------------------------------------------------- 1077 1078DefineConsoleFunction( MatrixMultiply, TransformF, ( TransformF left, TransformF right ),, 1079 "@brief Multiply the two matrices.\n\n" 1080 "@param left First transform.\n" 1081 "@param right Right transform.\n" 1082 "@return Concatenation of the two transforms.\n" 1083 "@ingroup Matrices" ) 1084{ 1085 MatrixF m1 = left.getMatrix(); 1086 MatrixF m2 = right.getMatrix(); 1087 1088 m1.mul( m2 ); 1089 1090 return TransformF( m1 ); 1091} 1092 1093//----------------------------------------------------------------------------- 1094 1095DefineConsoleFunction( MatrixMulVector, VectorF, ( TransformF transform, VectorF vector ),, 1096 "@brief Multiply the vector by the transform assuming that w=0.\n\n" 1097 "This function will multiply the given vector by the given transform such that translation will " 1098 "not affect the vector.\n\n" 1099 "@param transform A transform.\n" 1100 "@param vector A vector.\n" 1101 "@return The transformed vector.\n" 1102 "@ingroup Matrices") 1103{ 1104 MatrixF m = transform.getMatrix(); 1105 m.mulV( vector ); 1106 return vector; 1107} 1108 1109//----------------------------------------------------------------------------- 1110 1111DefineConsoleFunction( MatrixMulPoint, Point3F, ( TransformF transform, Point3F point ),, 1112 "@brief Multiply the given point by the given transform assuming that w=1.\n\n" 1113 "This function will multiply the given vector such that translation with take effect.\n" 1114 "@param transform A transform.\n" 1115 "@param point A vector.\n" 1116 "@return The transformed vector.\n" 1117 "@ingroup Matrices") 1118{ 1119 MatrixF m = transform.getMatrix(); 1120 m.mulP( point ); 1121 return point; 1122} 1123 1124ConsoleFunctionGroupEnd(MatrixMath); 1125 1126//------------------------------------------------------------------------------ 1127 1128DefineConsoleFunction( getBoxCenter, Point3F, ( Box3F box ),, 1129 "Get the center point of an axis-aligned box.\n\n" 1130 "@param b A Box3F, in string format using \"minExtentX minExtentY minExtentZ maxExtentX maxExtentY maxExtentZ\"\n" 1131 "@return Center of the box.\n" 1132 "@ingroup Math") 1133{ 1134 return box.getCenter(); 1135} 1136 1137//------------------------------------------------------------------------------ 1138 1139DefineEngineFunction( setRandomSeed, void, ( S32 seed ), ( -1 ), 1140 "Set the current seed for the random number generator.\n" 1141 "Based on this seed, a repeatable sequence of numbers will be produced by getRandom().\n" 1142 "@param seed The seed with which to initialize the randon number generator with. The same seed will always leed to" 1143 "the same sequence of pseudo-random numbers.\n" 1144 "If -1, the current timestamp will be used as the seed which is a good basis for randomization.\n" 1145 "@ingroup Random" ) 1146{ 1147 if( seed == -1 ) 1148 seed = Platform::getRealMilliseconds(); 1149 1150 MRandomLCG::setGlobalRandSeed( seed ); 1151} 1152 1153//------------------------------------------------------------------------------ 1154 1155DefineEngineFunction( getRandomSeed, S32, (),, 1156 "Get the current seed used by the random number generator.\n" 1157 "@return The current random number generator seed value.\n" 1158 "@ingroup Random" ) 1159{ 1160 return gRandGen.getSeed(); 1161} 1162 1163//------------------------------------------------------------------------------ 1164 1165S32 mRandI(S32 i1, S32 i2) 1166{ 1167 return gRandGen.randI(i1, i2); 1168} 1169 1170F32 mRandF(F32 f1, F32 f2) 1171{ 1172 return gRandGen.randF(f1, f2); 1173} 1174 1175F32 mRandF() 1176{ 1177 return gRandGen.randF(); 1178} 1179 1180DefineConsoleFunction(getRandom, F32, (S32 a, S32 b), (S32_MAX, S32_MAX), 1181 "( int a, int b ) " 1182 "@brief Returns a random number based on parameters passed in..\n\n" 1183 "If no parameters are passed in, getRandom() will return a float between 0.0 and 1.0. If one " 1184 "parameter is passed an integer between 0 and the passed in value will be returned. Two parameters will " 1185 "return an integer between the specified numbers.\n\n" 1186 "@param a If this is the only parameter, a number between 0 and a is returned. Elsewise represents the lower bound.\n" 1187 "@param b Upper bound on the random number. The random number will be <= @a b.\n" 1188 "@return A pseudo-random integer between @a a and @a b, between 0 and a, or a " 1189 "float between 0.0 and 1.1 depending on usage.\n\n" 1190 "@note All parameters are optional." 1191 "@see setRandomSeed\n" 1192 "@ingroup Random" ) 1193{ 1194 if (a != S32_MAX) 1195 { 1196 if (b == S32_MAX) 1197 return F32(gRandGen.randI(0, getMax(a, 0))); 1198 else 1199 { 1200 S32 min = a; 1201 S32 max = b; 1202 if (min > max) 1203 { 1204 S32 t = min; 1205 min = max; 1206 max = t; 1207 } 1208 return F32(gRandGen.randI(min, max)); 1209 } 1210 } 1211 return gRandGen.randF(); 1212} 1213 1214//------------------------------------------------------------------------------ 1215
