Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #51 from techno-dwarf-works/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
uurha committed Oct 19, 2023
1 parent c3d6794 commit 30de4d5
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 35 deletions.
23 changes: 0 additions & 23 deletions Runtime/Extension/MathfExtensions/QuaternionMathf.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Runtime/Extension/MathfExtensions/QuaternionMathf.cs.meta

This file was deleted.

40 changes: 40 additions & 0 deletions Runtime/Extension/MathfExtensions/Vector3Math.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,46 @@ namespace Better.Extensions.Runtime.MathfExtensions
{
public struct Vector3Math
{
public static Quaternion Validate(Quaternion rotation)
{
if (IsNormalized(rotation))
{
return rotation;
}

return Quaternion.identity;
}

public static bool IsNormalized(Quaternion quaternion)
{
var magnitudeSquared = quaternion.x * quaternion.x + quaternion.y * quaternion.y + quaternion.z * quaternion.z + quaternion.w * quaternion.w;
return Mathf.Approximately(magnitudeSquared, 1.0f);
}

public static bool Approximately(Vector3 current, Vector3 other)
{
return Mathf.Approximately(current.x, other.x) &&
Mathf.Approximately(current.y, other.y) &&
Mathf.Approximately(current.z, other.z);
}

public static bool Approximately(Vector2 current, Vector2 other)
{
return Mathf.Approximately(current.x, other.x) &&
Mathf.Approximately(current.y, other.y);
}

public static bool Approximately(Bounds current, Bounds other)
{
return Approximately(current.center, other.center) &&
Approximately(current.size, other.size);
}

public static bool Approximately(Quaternion current, Quaternion other)
{
return Mathf.Approximately(Quaternion.Dot(current, other), 1.0f);
}

/// <summary>
/// Take projection of point on Plane
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.uurha.betterextensions",
"displayName": "Better Extensions",
"description": "Unity extensions, serialize extension, async extension, string extension and UI extensions",
"version": "1.1.95",
"version": "1.1.96",
"unity": "2020.1",
"author": {
"name": "Better Plugins",
Expand Down

0 comments on commit 30de4d5

Please sign in to comment.