refactor: move Dot2D function

This commit is contained in:
ikpil 2023-10-21 00:27:48 +09:00
parent bc7b02d8bb
commit 33fa18cd0e
2 changed files with 22 additions and 23 deletions

View File

@ -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) public override bool Equals(object obj)
{ {
if (!(obj is RcVec3f)) if (!(obj is RcVec3f))

View File

@ -28,11 +28,32 @@ namespace DotRecast.Core.Numerics
default: throw new IndexOutOfRangeException("vector3f index out of range"); default: throw new IndexOutOfRangeException("vector3f index out of range");
} }
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Scale(this RcVec3f v, float scale) public static RcVec3f Scale(this RcVec3f v, float scale)
{ {
return v * 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];
}
} }
} }