daily update on 20230807 by nitload youmu

This commit is contained in:
Nitload
2023-08-07 22:12:37 +08:00
parent 0601a6dcce
commit f9f339405e
16 changed files with 573 additions and 355 deletions
-144
View File
@@ -5,150 +5,6 @@ using System.Runtime.InteropServices;
namespace StgSharp.Math
{
/*
[StructLayout(LayoutKind.Explicit, Size = 12, Pack = 16)]
public struct Vec3d : IEquatable<Vec3d>
{
[FieldOffset(0)]
public float X;
[FieldOffset(4)]
public float Y;
[FieldOffset(8)]
public float Z;
public Vec3d(float x, float y, float z)
{
X = x;
Y = y;
Z = z;
}
bool IEquatable<Vec3d>.Equals(Vec3d other)
{
if (this.GetHashCode() != other.GetHashCode())
{
return false;
}
else
{
return this.X == other.X
&& this.Y == other.Y
&& this.Z == other.Z;
}
}
public override bool Equals(object obj)
{
if (obj == null)
{
return false;
}
else if (obj.GetType() != typeof(Vec3d))
{
return false;
}
else
{
return this.Equals((Vec3d)obj);
}
}
public override int GetHashCode()
{
return HashCode.Combine(X, Y, Z);
}
public override string ToString()
{
return $"{X}\t{Y}\t{Z}";
}
public string ToString(string sample)
{
return $"{X.ToString(sample)}\t{Y.ToString(sample)}\t{Z.ToString(sample)}";
}
public static bool operator ==(Vec3d vec1, Vec3d vec2)
{
return vec1.X == vec2.X
&& vec1.Y == vec2.Y
&& vec1.Z == vec2.Z;
}
public static bool operator !=(Vec3d vec1, Vec3d vec2)
{
return !(vec1.X == vec2.X
&& vec1.Y == vec2.Y
&& vec1.Z == vec2.Z);
}
public static Vec3d operator +(Vec3d vec1, Vec3d vec2)
{
return new Vec3d(
vec1.X + vec2.X,
vec1.Y + vec2.Y,
vec1.Z + vec2.Z
);
}
public static Vec3d operator -(Vec3d vec1, Vec3d vec2)
{
return new Vec3d(
vec1.X - vec2.X,
vec1.Y - vec2.Y,
vec1.Z - vec2.Z
);
}
public static float operator *(Vec3d vec1, Vec3d vec2)
{
return
vec1.X * vec2.X
+ vec1.Y + vec2.Y
+ vec1.Z + vec2.Z;
}
public static Vec3d operator *(Vec3d vec, float x)
{
return new Vec3d(
vec.X * x,
vec.Y * x,
vec.Z * x
);
}
public static Vec3d operator *(float x, Vec3d vec)
{
return new Vec3d(
vec.X * x,
vec.Y * x,
vec.Z * x
);
}
public static Vec3d operator /(Vec3d vec, float x)
{
return new Vec3d(
vec.X / x,
vec.Y / x,
vec.Z / x
);
}
public static implicit operator float[](Vec3d vec)
{
return new float[3] { vec.X, vec.Y, vec.Y };
}
public static implicit operator Vec3d(float[] floatArray)
{
return new Vec3d(floatArray[0], floatArray[1], floatArray[2]);
}
}
/**/
public class Vec3d
{
public static Vec3d defaultValue =