daily update on 20230309 by nitload youmu

This commit is contained in:
Nitload
2023-03-10 01:57:31 +08:00
parent 11cdd85b3b
commit 561196bed2
53 changed files with 1491 additions and 360 deletions
+123
View File
@@ -0,0 +1,123 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit)]
public struct Colum3D : IEquatable<Colum3D>
{
[FieldOffset(0)]
public float X;
[FieldOffset(4)]
public float Y;
[FieldOffset(8)]
public float Z;
public Colum3D(float x, float y, float z)
{
X = x;
Y = y;
Z = z;
}
bool IEquatable<Colum3D>.Equals(Colum3D 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(Colum3D))
{
return false;
}
else
{
return this.Equals((Colum3D)obj);
}
}
public override int GetHashCode()
{
return HashCode.Combine(X, Y, Z);
}
public override string ToString()
{
return $"{X}\t{Y}\t{Z}";
}
public static bool operator ==(Colum3D vec1, Colum3D vec2)
{
return vec1.X == vec2.X
&& vec1.Y == vec2.Y
&& vec1.Z == vec2.Z;
}
public static bool operator !=(Colum3D vec1, Colum3D vec2)
{
return !(vec1.X == vec2.X
&& vec1.Y == vec2.Y
&& vec1.Z == vec2.Z);
}
public static Colum3D operator +(Colum3D vec1, Colum3D vec2)
{
return new Colum3D(
vec1.X + vec2.X,
vec1.Y + vec2.Y,
vec1.Z + vec2.Z
);
}
public static Colum3D operator -(Colum3D vec1, Colum3D vec2)
{
return new Colum3D(
vec1.X - vec2.X,
vec1.Y - vec2.Y,
vec1.Z - vec2.Z
);
}
public static float operator *(Colum3D vec1, Colum3D vec2)
{
return
vec1.X * vec2.X
+ vec1.Y + vec2.Y
+ vec1.Z + vec2.Z;
}
public static Colum3D operator *(Colum3D vec, float x)
{
return new Colum3D(
vec.X * x,
vec.Y * x,
vec.Z * x
);
}
public static Colum3D operator /(Colum3D vec, float x)
{
return new Colum3D(
vec.X / x,
vec.Y / x,
vec.Z / x
);
}
}
}