added c++ PingPong and flipped sheer

This commit is contained in:
NoriteSC
2023-11-16 11:50:44 +01:00
parent ea3f02f810
commit 307129b4a1
2 changed files with 13 additions and 2 deletions

View File

@@ -890,6 +890,17 @@ namespace Math
{
return Lerp<T>(a, b, alpha < 0.5f ? InterpCircularIn(0.f, 1.f, alpha * 2.f) * 0.5f : InterpCircularOut(0.f, 1.f, alpha * 2.f - 1.f) * 0.5f + 0.5f);
}
/// <summary>
/// PingPongs the value <paramref name="t"/>, so that it is never larger than <paramref name="length"/> and never smaller than 0.
/// </summary>
/// <param name="t"></param>
/// <param name="length"></param>
/// <returns></returns>
template<class T>
static FORCE_INLINE T PingPong(const T& t, T length)
{
return length - Abs(Repeat(t, length * 2.0f) - length);
}
// Rotates position about the given axis by the given angle, in radians, and returns the offset to position
Vector3 FLAXENGINE_API RotateAboutAxis(const Vector3& normalizedRotationAxis, float angle, const Vector3& positionOnAxis, const Vector3& position);

View File

@@ -530,9 +530,9 @@ namespace FlaxEngine.GUI
Matrix3x3 m1 = new Matrix3x3
(
_scale.X,
_scale.X * (_shear.X == 0 ? 0 : (1.0f / Mathf.Tan(Mathf.DegreesToRadians * (90 - Mathf.Clamp(_shear.X, -89.0f, 89.0f))))),
_scale.X * (_shear.Y == 0 ? 0 : (1.0f / Mathf.Tan(Mathf.DegreesToRadians * (90 - Mathf.Clamp(_shear.Y, -89.0f, 89.0f))))),
0,
_scale.Y * (_shear.Y == 0 ? 0 : (1.0f / Mathf.Tan(Mathf.DegreesToRadians * (90 - Mathf.Clamp(_shear.Y, -89.0f, 89.0f))))),
_scale.Y * (_shear.X == 0 ? 0 : (1.0f / Mathf.Tan(Mathf.DegreesToRadians * (90 - Mathf.Clamp(_shear.X, -89.0f, 89.0f))))),
_scale.Y,
0, 0, 0, 1
);