daily update on 20240209 by nitload youmu
This commit is contained in:
@@ -4,12 +4,10 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// A two dimension vector defined by two elements.
|
||||
/// Vec2Ds in StgSharp are defaultly usaed as colum vector.
|
||||
/// </summary>
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 16)]
|
||||
public struct Vec2d
|
||||
{
|
||||
@@ -21,10 +19,17 @@ namespace StgSharp.Math
|
||||
|
||||
[FieldOffset(0)]
|
||||
internal Vector4 vec;
|
||||
[FieldOffset(0)]
|
||||
internal Vector2 v;
|
||||
|
||||
public Vec2d(float x, float y)
|
||||
{
|
||||
X = x; Y = y;
|
||||
v = new Vector2(x, y);
|
||||
}
|
||||
|
||||
internal Vec2d(Vector2 vec)
|
||||
{
|
||||
v = vec;
|
||||
}
|
||||
|
||||
public static Vec2d Zero
|
||||
@@ -32,43 +37,36 @@ namespace StgSharp.Math
|
||||
get { return new Vec2d(0, 0); }
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vec2d operator +(Vec2d vec1, Vec2d vec2)
|
||||
public static Vec2d Unit
|
||||
{
|
||||
return new Vec2d(
|
||||
vec1.X + vec2.X,
|
||||
vec1.Y + vec2.Y
|
||||
);
|
||||
get { return new Vec2d(1, 1); }
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vec2d operator -(Vec2d vec1, Vec2d vec2)
|
||||
public static Vec2d operator +(Vec2d left, Vec2d right)
|
||||
{
|
||||
return new Vec2d(
|
||||
vec1.X - vec2.X,
|
||||
vec1.Y - vec2.Y
|
||||
);
|
||||
return new Vec2d(left.v + right.v);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vec2d operator -(Vec2d left, Vec2d right)
|
||||
{
|
||||
return new Vec2d(left.v - right.v);
|
||||
}
|
||||
|
||||
public static Vec2d operator *(Vec2d vec, float value)
|
||||
{
|
||||
return new Vec2d(
|
||||
vec.X * value,
|
||||
vec.Y * value
|
||||
);
|
||||
return new Vec2d(vec.v * value);
|
||||
}
|
||||
|
||||
public static Vec2d operator /(Vec2d vec, float value)
|
||||
{
|
||||
return new Vec2d(
|
||||
vec.X / value,
|
||||
vec.Y / value
|
||||
);
|
||||
return new Vec2d(vec.v / value);
|
||||
}
|
||||
|
||||
public static bool operator ==(Vec2d left, Vec2d right)
|
||||
{
|
||||
return left.X == right.X && left.Y == right.Y;
|
||||
return left.v == right.v;
|
||||
}
|
||||
|
||||
public static bool operator !=(Vec2d left, Vec2d right)
|
||||
|
||||
Reference in New Issue
Block a user