diff --git a/Runtime/Extension/MathfExtensions/QuaternionMathf.cs b/Runtime/Extension/MathfExtensions/QuaternionMathf.cs deleted file mode 100644 index e69b0b0..0000000 --- a/Runtime/Extension/MathfExtensions/QuaternionMathf.cs +++ /dev/null @@ -1,23 +0,0 @@ -using UnityEngine; - -namespace Better.Extensions.Runtime.MathfExtensions -{ - public static class QuaternionMath - { - public static Quaternion Validate(this Quaternion rotation) - { - if (IsNormalized(rotation)) - { - return rotation; - } - - return Quaternion.identity; - } - - public static bool IsNormalized(this Quaternion quaternion) - { - float magnitudeSquared = quaternion.x * quaternion.x + quaternion.y * quaternion.y + quaternion.z * quaternion.z + quaternion.w * quaternion.w; - return Mathf.Approximately(magnitudeSquared, 1.0f); - } - } -} \ No newline at end of file diff --git a/Runtime/Extension/MathfExtensions/QuaternionMathf.cs.meta b/Runtime/Extension/MathfExtensions/QuaternionMathf.cs.meta deleted file mode 100644 index 8872b6e..0000000 --- a/Runtime/Extension/MathfExtensions/QuaternionMathf.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 32d26f5660faf0343b4bf5df361fdb55 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Extension/MathfExtensions/Vector3Math.cs b/Runtime/Extension/MathfExtensions/Vector3Math.cs index 4f0928b..5ead336 100644 --- a/Runtime/Extension/MathfExtensions/Vector3Math.cs +++ b/Runtime/Extension/MathfExtensions/Vector3Math.cs @@ -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); + } + /// /// Take projection of point on Plane /// diff --git a/package.json b/package.json index 50b50c5..a7abc55 100644 --- a/package.json +++ b/package.json @@ -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",