Move CultMath into the CultLib monorepo
This commit is contained in:
commit
ea88cfcd05
98 changed files with 3574 additions and 4 deletions
25
packages/cultmath/src/CultMath/double2.cs
Normal file
25
packages/cultmath/src/CultMath/double2.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
|
||||
namespace CultMath;
|
||||
|
||||
public record struct double2(double x, double y)
|
||||
{
|
||||
public static readonly double2 zero = new(0.0, 0.0);
|
||||
public static readonly double2 one = new(1.0, 1.0);
|
||||
|
||||
public double this[int index] => index switch
|
||||
{
|
||||
0 => x,
|
||||
1 => y,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(index)),
|
||||
};
|
||||
|
||||
public static implicit operator double2(double value) => new(value, value);
|
||||
|
||||
public static double2 operator +(double2 value) => value;
|
||||
public static double2 operator -(double2 value) => new(-value.x, -value.y);
|
||||
public static double2 operator +(double2 left, double2 right) => new(left.x + right.x, left.y + right.y);
|
||||
public static double2 operator -(double2 left, double2 right) => new(left.x - right.x, left.y - right.y);
|
||||
public static double2 operator *(double2 left, double2 right) => new(left.x * right.x, left.y * right.y);
|
||||
public static double2 operator /(double2 left, double2 right) => new(left.x / right.x, left.y / right.y);
|
||||
}
|
||||
Loading…
Reference in a new issue