Extended math lib

added
GetRotacionFromNormal
AlignRotacionToNormalAndSnapToGrid
SnapToRotatedGrid
SnapToRotatedGridWithOffset
This commit is contained in:
Norite SC
2024-04-03 04:53:11 +02:00
parent ce07edd1ec
commit f6313b4427
6 changed files with 429 additions and 0 deletions

View File

@@ -660,6 +660,27 @@ public:
// @param roll The roll of rotation (in radians)
// @param result When the method completes, contains the newly created quaternion
static void RotationYawPitchRoll(float yaw, float pitch, float roll, Quaternion& result);
/// <summary>
/// Gets rotacion for normal in relation to transform<br/>
/// Funcion especially created for aligned with axis aligned faces
/// use full with <seealso cref="Physics::RayCast"/>
/// </summary>
/// <param name="InNormal">the normal vector</param>
/// <param name="InRefrenceTransform">relative to</param>
/// <returns>normal as rotacion</returns>
static Quaternion GetRotacionFromNormal(const Vector3& InNormal, const Transform& InRefrenceTransform)
{
Float3 up = InRefrenceTransform.GetUp();
auto dot = Vector3::Dot(InNormal, up);
if (Math::NearEqual(Math::Abs(dot), 1))
{
up = InRefrenceTransform.GetRight();
}
return Quaternion::LookRotation(InNormal, up);
}
};
/// <summary>