2013-11-09 14:59:10 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
// Created by Dan Andersson 2013
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "OysterMath.h"
|
|
|
|
|
|
|
|
namespace Oyster { namespace Math
|
|
|
|
{
|
|
|
|
bool IsSupported()
|
|
|
|
{ return true; }
|
|
|
|
|
|
|
|
bool SuperpositionMatrix( const Float2x2 &in, const Float2x2 &out, Float2x2 &targetMem )
|
|
|
|
{ return ::LinearAlgebra::SuperpositionMatrix( in, out, targetMem ); }
|
|
|
|
|
|
|
|
bool SuperpositionMatrix( const Float3x3 &in, const Float3x3 &out, Float3x3 &targetMem )
|
|
|
|
{ return ::LinearAlgebra::SuperpositionMatrix( in, out, targetMem ); }
|
|
|
|
|
|
|
|
bool SuperpositionMatrix( const Float4x4 &in, const Float4x4 &out, Float4x4 &targetMem )
|
|
|
|
{ return ::LinearAlgebra::SuperpositionMatrix( in, out, targetMem ); }
|
|
|
|
} }
|
|
|
|
|
|
|
|
namespace Oyster { namespace Math2D
|
|
|
|
{
|
|
|
|
Float2 X_AxisTo( const Float2 &yAxis )
|
|
|
|
{ return ::LinearAlgebra2D::X_AxisTo(yAxis); }
|
|
|
|
|
|
|
|
Float2 Y_AxisTo( const Float2 &xAxis )
|
|
|
|
{ return ::LinearAlgebra2D::Y_AxisTo(xAxis); }
|
|
|
|
|
|
|
|
Float3x3 & TranslationMatrix( const Float2 &position, Float3x3 &targetMem )
|
|
|
|
{ return ::LinearAlgebra2D::TranslationMatrix( position, targetMem ); }
|
|
|
|
|
|
|
|
Float3x3 & RotationMatrix( const Float &radian, Float3x3 &targetMem )
|
|
|
|
{ return ::LinearAlgebra2D::RotationMatrix( radian, targetMem ); }
|
2013-11-20 16:58:56 +01:00
|
|
|
|
|
|
|
Float2x2 & InverseRotationMatrix( const Float2x2 &rotation, Float2x2 &targetMem )
|
|
|
|
{
|
|
|
|
return targetMem = ::LinearAlgebra2D::InverseRotationMatrix( rotation );
|
|
|
|
}
|
|
|
|
|
|
|
|
Float3x3 & InverseRotationMatrix( const Float3x3 &rotation, Float3x3 &targetMem )
|
|
|
|
{
|
|
|
|
return targetMem = ::LinearAlgebra2D::InverseRotationMatrix( rotation );
|
|
|
|
}
|
|
|
|
|
|
|
|
Float3x3 & OrientationMatrix( const Float2x2 &rotation, const Float2 &translation, Float3x3 &targetMem )
|
|
|
|
{
|
|
|
|
return targetMem = ::LinearAlgebra2D::OrientationMatrix( rotation, translation );
|
|
|
|
}
|
|
|
|
|
|
|
|
Float3x3 & OrientationMatrix( const Float3x3 &rotation, const Float2 &translation, Float3x3 &targetMem )
|
|
|
|
{
|
|
|
|
return targetMem = ::LinearAlgebra2D::OrientationMatrix( rotation, translation );
|
|
|
|
}
|
2013-11-09 14:59:10 +01:00
|
|
|
|
|
|
|
Float3x3 & OrientationMatrix( const Float2 &position, const Float &radian, Float3x3 &targetMem )
|
2013-11-20 16:58:56 +01:00
|
|
|
{
|
|
|
|
return ::LinearAlgebra2D::OrientationMatrix( radian, position, targetMem );
|
|
|
|
}
|
2013-11-09 14:59:10 +01:00
|
|
|
|
|
|
|
Float3x3 & OrientationMatrix( const Float2 &position, const Float2 &lookAt, Float3x3 &targetMem )
|
2013-11-20 16:58:56 +01:00
|
|
|
{
|
|
|
|
return ::LinearAlgebra2D::OrientationMatrix( lookAt, position, targetMem );
|
|
|
|
}
|
2013-11-09 14:59:10 +01:00
|
|
|
|
|
|
|
Float3x3 & OrientationMatrix( const Float2 &position, Float radian, const Float2 &localCenterOfRotation, Float3x3 &targetMem )
|
2013-11-20 16:58:56 +01:00
|
|
|
{
|
|
|
|
return ::LinearAlgebra2D::OrientationMatrix( radian, position, localCenterOfRotation, targetMem );
|
|
|
|
}
|
2013-11-09 14:59:10 +01:00
|
|
|
|
|
|
|
Float3x3 & InverseOrientationMatrix( const Float3x3 &orientationMatrix, Float3x3 &targetMem )
|
2013-11-20 16:58:56 +01:00
|
|
|
{
|
|
|
|
return ::LinearAlgebra2D::InverseOrientationMatrix( orientationMatrix, targetMem );
|
|
|
|
}
|
|
|
|
|
|
|
|
Float3x3 & ExtractRotationMatrix( const Float3x3 &orientation, Float3x3 &targetMem )
|
|
|
|
{
|
|
|
|
return targetMem = ::LinearAlgebra2D::ExtractRotationMatrix( orientation );
|
|
|
|
}
|
2013-11-09 14:59:10 +01:00
|
|
|
} }
|
|
|
|
|
|
|
|
namespace Oyster { namespace Math3D
|
|
|
|
{
|
2013-12-06 09:46:30 +01:00
|
|
|
Float4 AngularAxis( const Float3x3 &rotationMatrix )
|
|
|
|
{
|
|
|
|
return ::LinearAlgebra3D::AngularAxis( rotationMatrix );
|
|
|
|
}
|
|
|
|
|
|
|
|
Float4 AngularAxis( const Float4x4 &rotationMatrix )
|
|
|
|
{
|
|
|
|
return ::LinearAlgebra3D::AngularAxis( rotationMatrix );
|
|
|
|
}
|
|
|
|
|
2013-12-18 14:16:13 +01:00
|
|
|
Float4 ExtractAngularAxis( const Float4x4 &orientationMatrix )
|
|
|
|
{
|
|
|
|
return ::LinearAlgebra3D::ExtractAngularAxis( orientationMatrix );
|
|
|
|
}
|
|
|
|
|
2013-11-09 14:59:10 +01:00
|
|
|
Float4x4 & TranslationMatrix( const Float3 &position, Float4x4 &targetMem )
|
2013-12-06 09:46:30 +01:00
|
|
|
{
|
|
|
|
return ::LinearAlgebra3D::TranslationMatrix( position, targetMem );
|
|
|
|
}
|
2013-11-09 14:59:10 +01:00
|
|
|
|
|
|
|
Float4x4 & RotationMatrix_AxisX( const Float &radian, Float4x4 &targetMem )
|
2013-12-06 09:46:30 +01:00
|
|
|
{
|
|
|
|
return ::LinearAlgebra3D::RotationMatrix_AxisX( radian, targetMem );
|
|
|
|
}
|
2013-11-09 14:59:10 +01:00
|
|
|
|
|
|
|
Float4x4 & RotationMatrix_AxisY( const Float &radian, Float4x4 &targetMem )
|
2013-12-06 09:46:30 +01:00
|
|
|
{
|
|
|
|
return ::LinearAlgebra3D::RotationMatrix_AxisY( radian, targetMem );
|
|
|
|
}
|
2013-11-09 14:59:10 +01:00
|
|
|
|
|
|
|
Float4x4 & RotationMatrix_AxisZ( const Float &radian, Float4x4 &targetMem )
|
2013-12-06 09:46:30 +01:00
|
|
|
{
|
|
|
|
return ::LinearAlgebra3D::RotationMatrix_AxisZ( radian, targetMem );
|
|
|
|
}
|
|
|
|
|
|
|
|
Float4x4 & RotationMatrix( const Float3 &angularAxis, Float4x4 &targetMem )
|
|
|
|
{
|
|
|
|
return targetMem = ::LinearAlgebra3D::RotationMatrix( angularAxis );
|
|
|
|
}
|
2013-11-09 14:59:10 +01:00
|
|
|
|
|
|
|
Float4x4 & RotationMatrix( const Float &radian, const Float3 &normalizedAxis, Float4x4 &targetMem )
|
2013-12-06 09:46:30 +01:00
|
|
|
{
|
|
|
|
return ::LinearAlgebra3D::RotationMatrix( normalizedAxis, radian, targetMem );
|
|
|
|
}
|
2013-11-20 16:58:56 +01:00
|
|
|
|
|
|
|
Float3x3 & InverseRotationMatrix( const Float3x3 &rotation, Float3x3 &targetMem )
|
|
|
|
{
|
|
|
|
return targetMem = ::LinearAlgebra3D::InverseRotationMatrix( rotation );
|
|
|
|
}
|
|
|
|
|
|
|
|
Float4x4 & InverseRotationMatrix( const Float4x4 &rotation, Float4x4 &targetMem )
|
|
|
|
{
|
2013-12-04 14:22:25 +01:00
|
|
|
// return targetMem = ::LinearAlgebra3D::InverseRotationMatrix( rotation );
|
|
|
|
return targetMem = rotation.GetTranspose();
|
2013-11-20 16:58:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Float4x4 & OrientationMatrix( const Float3x3 &rotation, const Float3 &translation, Float4x4 &targetMem )
|
|
|
|
{
|
|
|
|
return targetMem = ::LinearAlgebra3D::OrientationMatrix( rotation, translation );
|
|
|
|
}
|
|
|
|
|
|
|
|
Float4x4 & OrientationMatrix( const Float4x4 &rotation, const Float3 &translation, Float4x4 &targetMem )
|
|
|
|
{
|
|
|
|
return targetMem = ::LinearAlgebra3D::OrientationMatrix( rotation, translation );
|
|
|
|
}
|
2013-11-09 14:59:10 +01:00
|
|
|
|
2013-11-12 00:10:48 +01:00
|
|
|
Float4x4 & OrientationMatrix( const Float3 &normalizedAxis, const Float & deltaRadian, const Float3 &sumTranslation, Float4x4 &targetMem )
|
2013-11-20 16:58:56 +01:00
|
|
|
{
|
|
|
|
return ::LinearAlgebra3D::OrientationMatrix( normalizedAxis, deltaRadian, sumTranslation, targetMem );
|
|
|
|
}
|
2013-11-12 00:10:48 +01:00
|
|
|
|
2013-12-18 14:16:13 +01:00
|
|
|
Float4x4 & OrientationMatrix( const Float3 &angularAxis, const Float3 &translation, Float4x4 &targetMem )
|
|
|
|
{
|
|
|
|
return ::LinearAlgebra3D::OrientationMatrix( angularAxis, translation, targetMem );
|
|
|
|
}
|
|
|
|
|
|
|
|
Float4x4 & ViewMatrix( const Float3 &angularAxis, const Float3 &translation, Float4x4 &targetMem )
|
2013-11-20 16:58:56 +01:00
|
|
|
{
|
2013-12-18 14:16:13 +01:00
|
|
|
return ::LinearAlgebra3D::ViewMatrix( angularAxis, translation, targetMem );
|
2013-11-20 16:58:56 +01:00
|
|
|
}
|
2013-11-09 14:59:10 +01:00
|
|
|
|
|
|
|
Float4x4 & OrientationMatrix( const Float3 &sumDeltaAngularAxis, const Float3 &sumTranslation, const Float3 ¢erOfMass, Float4x4 &targetMem )
|
2013-11-20 16:58:56 +01:00
|
|
|
{
|
|
|
|
return ::LinearAlgebra3D::OrientationMatrix( sumDeltaAngularAxis, sumTranslation, centerOfMass, targetMem );
|
|
|
|
}
|
2013-11-09 14:59:10 +01:00
|
|
|
|
2013-11-21 15:19:32 +01:00
|
|
|
Float4x4 & OrientationMatrix_LookAtDirection( const Float3 &normalizedDirection, const Float3 &normalizedUpVector, const Float3 &worldPos, Float4x4 &targetMem )
|
|
|
|
{
|
|
|
|
return targetMem = ::LinearAlgebra3D::OrientationMatrix_LookAtDirection( normalizedDirection, normalizedUpVector, worldPos );
|
|
|
|
}
|
|
|
|
|
|
|
|
Float4x4 & OrientationMatrix_LookAtPos( const Float3 &worldLookAt, const Float3 &normalizedUpVector, const Float3 &worldPos, Float4x4 &targetMem )
|
|
|
|
{
|
|
|
|
return targetMem = ::LinearAlgebra3D::OrientationMatrix_LookAtPos( worldLookAt, normalizedUpVector, worldPos );
|
|
|
|
}
|
|
|
|
|
2013-11-22 10:49:07 +01:00
|
|
|
Float4x4 & ViewMatrix_LookAtDirection( const Float3 &normalizedDirection, const Float3 &normalizedUpVector, const Float3 &worldPos, Float4x4 &targetMem )
|
|
|
|
{
|
|
|
|
return ::LinearAlgebra3D::InverseOrientationMatrix( ::LinearAlgebra3D::OrientationMatrix_LookAtDirection( normalizedDirection, normalizedUpVector, worldPos ), targetMem );
|
|
|
|
}
|
|
|
|
|
|
|
|
Float4x4 & ViewMatrix_LookAtPos( const Float3 &worldLookAt, const Float3 &normalizedUpVector, const Float3 &worldPos, Float4x4 &targetMem )
|
|
|
|
{
|
|
|
|
return ::LinearAlgebra3D::InverseOrientationMatrix( ::LinearAlgebra3D::OrientationMatrix_LookAtPos( worldLookAt, normalizedUpVector, worldPos ), targetMem );
|
|
|
|
}
|
|
|
|
|
2013-11-09 14:59:10 +01:00
|
|
|
Float4x4 & InverseOrientationMatrix( const Float4x4 &orientationMatrix, Float4x4 &targetMem )
|
2013-11-20 16:58:56 +01:00
|
|
|
{
|
|
|
|
return ::LinearAlgebra3D::InverseOrientationMatrix( orientationMatrix, targetMem );
|
|
|
|
}
|
2013-11-09 14:59:10 +01:00
|
|
|
|
2013-11-18 14:01:23 +01:00
|
|
|
Float4x4 & UpdateOrientationMatrix( const Float3 &deltaPosition, const Float4x4 &deltaRotationMatrix, Float4x4 &orientationMatrix )
|
2013-11-20 16:58:56 +01:00
|
|
|
{
|
|
|
|
return ::LinearAlgebra3D::UpdateOrientationMatrix( deltaPosition, deltaRotationMatrix, orientationMatrix );
|
|
|
|
}
|
|
|
|
|
|
|
|
Float4x4 & ExtractRotationMatrix( const Float4x4 &orientation, Float4x4 &targetMem )
|
|
|
|
{
|
|
|
|
return targetMem = ::LinearAlgebra3D::ExtractRotationMatrix( orientation );
|
|
|
|
}
|
2013-11-18 14:01:23 +01:00
|
|
|
|
2013-11-09 14:59:10 +01:00
|
|
|
Float4x4 & ProjectionMatrix_Orthographic( const Float &width, const Float &height, const Float &nearClip, const Float &farClip, Float4x4 &targetMem )
|
2013-11-20 16:58:56 +01:00
|
|
|
{
|
|
|
|
return ::LinearAlgebra3D::ProjectionMatrix_Orthographic( width, height, nearClip, farClip, targetMem );
|
|
|
|
}
|
2013-11-09 14:59:10 +01:00
|
|
|
|
|
|
|
Float4x4 & ProjectionMatrix_Perspective( const Float &verticalFoV, const Float &aspectRatio, const Float &nearClip, const Float &farClip, Float4x4 &targetMem )
|
2013-11-20 16:58:56 +01:00
|
|
|
{
|
|
|
|
return ::LinearAlgebra3D::ProjectionMatrix_Perspective( verticalFoV, aspectRatio, nearClip, farClip, targetMem );
|
|
|
|
}
|
2013-11-09 14:59:10 +01:00
|
|
|
|
|
|
|
Float3 VectorProjection( const Float3 &vector, const Float3 &axis )
|
2013-11-12 12:33:52 +01:00
|
|
|
{
|
|
|
|
return ::LinearAlgebra3D::VectorProjection( vector, axis );
|
|
|
|
}
|
2013-11-21 11:39:11 +01:00
|
|
|
|
|
|
|
Float3 NormalProjection( const Float3 &vector, const Float3 &normalizedAxis )
|
|
|
|
{
|
|
|
|
return ::LinearAlgebra3D::NormalProjection( vector, normalizedAxis );
|
|
|
|
}
|
2013-11-09 14:59:10 +01:00
|
|
|
} }
|