daily update on 20240209 by nitload youmu
This commit is contained in:
@@ -3,6 +3,7 @@ using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.AccessControl;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
@@ -11,6 +12,8 @@ namespace StgSharp.Math
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
internal Vector4 vec;
|
||||
[FieldOffset(0)]
|
||||
internal Vector3 v;
|
||||
|
||||
[FieldOffset(0)] public float X;
|
||||
[FieldOffset(4)] public float Y;
|
||||
@@ -28,7 +31,7 @@ namespace StgSharp.Math
|
||||
#if NET5_0_OR_GREATER
|
||||
Unsafe.SkipInit(out vec);
|
||||
#endif
|
||||
X = x; Y = y; Z = z;
|
||||
v = new Vector3(x, y, z);
|
||||
}
|
||||
|
||||
internal vec3d(Vector4 vector)
|
||||
@@ -36,6 +39,11 @@ namespace StgSharp.Math
|
||||
vec = vector;
|
||||
}
|
||||
|
||||
internal vec3d(Vector3 vector)
|
||||
{
|
||||
v = vector;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public float Dot(vec3d right)
|
||||
{
|
||||
@@ -76,61 +84,42 @@ namespace StgSharp.Math
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static vec3d operator -(vec3d left, vec3d right)
|
||||
{
|
||||
return new vec3d(
|
||||
left.X - right.X,
|
||||
left.Y - right.Y,
|
||||
left.Z - right.Z
|
||||
);
|
||||
return new vec3d(left.v - right.v);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static vec3d operator *(vec3d vec, float value)
|
||||
{
|
||||
return new vec3d(
|
||||
vec.X * value,
|
||||
vec.Y * value,
|
||||
vec.Z * value
|
||||
);
|
||||
return new vec3d(vec.v * value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static vec3d operator /(vec3d vec, float value)
|
||||
{
|
||||
return new vec3d(
|
||||
vec.X / value,
|
||||
vec.Y / value,
|
||||
vec.Z / value
|
||||
);
|
||||
return new vec3d(vec.v / value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float operator *(vec3d left, vec3d right)
|
||||
{
|
||||
return
|
||||
left.X * right.X +
|
||||
left.Y * right.Y +
|
||||
left.Z * right.Z;
|
||||
return Vector3.Dot(left.v, right.v);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator ==(vec3d left, vec3d right)
|
||||
{
|
||||
return left.X == right.X
|
||||
&& left.Y == right.Y
|
||||
&& left.Z == right.Z;
|
||||
return left.v == right.v;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator !=(vec3d left, vec3d right)
|
||||
{
|
||||
return left.X != right.X
|
||||
&& left.Y != right.Y
|
||||
&& left.Z != right.Z;
|
||||
return left.v != right.v;
|
||||
}
|
||||
|
||||
public string ToString(string sample)
|
||||
{
|
||||
return $"{this.X}\t{this.Y}\t{this.Z}\t";
|
||||
return $"[{X.ToString(sample)},{Y.ToString(sample)},{Z.ToString(sample)}]";
|
||||
}
|
||||
|
||||
public bool Equals(vec3d other)
|
||||
|
||||
Reference in New Issue
Block a user