From 33fa18cd0effc33445b44bf1f269c1d28c541763 Mon Sep 17 00:00:00 2001 From: ikpil Date: Sat, 21 Oct 2023 00:27:48 +0900 Subject: [PATCH] refactor: move Dot2D function --- src/DotRecast.Core/Numerics/RcVec3f.cs | 22 ------------------ .../Numerics/RcVecExtensions.cs | 23 ++++++++++++++++++- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/DotRecast.Core/Numerics/RcVec3f.cs b/src/DotRecast.Core/Numerics/RcVec3f.cs index 4543f14..683b69d 100644 --- a/src/DotRecast.Core/Numerics/RcVec3f.cs +++ b/src/DotRecast.Core/Numerics/RcVec3f.cs @@ -122,28 +122,6 @@ namespace DotRecast.Core.Numerics } - - - /// Derives the dot product of two vectors on the xz-plane. (@p u . @p v) - /// @param[in] u A vector [(x, y, z)] - /// @param[in] v A vector [(x, y, z)] - /// @return The dot product on the xz-plane. - /// - /// The vectors are projected onto the xz-plane, so the y-values are - /// ignored. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public readonly float Dot2D(RcVec3f v) - { - return X * v.X + Z * v.Z; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public readonly float Dot2D(float[] v, int vi) - { - return X * v[vi] + Z * v[vi + 2]; - } - - public override bool Equals(object obj) { if (!(obj is RcVec3f)) diff --git a/src/DotRecast.Core/Numerics/RcVecExtensions.cs b/src/DotRecast.Core/Numerics/RcVecExtensions.cs index d2e5dd7..b17786c 100644 --- a/src/DotRecast.Core/Numerics/RcVecExtensions.cs +++ b/src/DotRecast.Core/Numerics/RcVecExtensions.cs @@ -28,11 +28,32 @@ namespace DotRecast.Core.Numerics default: throw new IndexOutOfRangeException("vector3f index out of range"); } } - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static RcVec3f Scale(this RcVec3f v, float scale) { return v * scale; } + + /// Derives the dot product of two vectors on the xz-plane. (@p u . @p v) + /// @param[in] u A vector [(x, y, z)] + /// @param[in] v A vector [(x, y, z)] + /// @return The dot product on the xz-plane. + /// + /// The vectors are projected onto the xz-plane, so the y-values are + /// ignored. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static float Dot2D(this RcVec3f @this, RcVec3f v) + { + return @this.X * v.X + + @this.Z * v.Z; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static float Dot2D(this RcVec3f @this, float[] v, int vi) + { + return @this.X * v[vi] + + @this.Z * v[vi + 2]; + } } } \ No newline at end of file