Move CultMath into the CultLib monorepo

This commit is contained in:
Meta Vens 2026-08-26 17:35:51 +02:00
commit ea88cfcd05
98 changed files with 3574 additions and 4 deletions

View file

@ -0,0 +1,28 @@
using System;
namespace CultMath;
public record struct float2(float x, float y)
{
public static readonly float2 zero = new(0.0f, 0.0f);
public static readonly float2 one = new(1.0f, 1.0f);
public float this[int index] => index switch
{
0 => x,
1 => y,
_ => throw new ArgumentOutOfRangeException(nameof(index)),
};
public static implicit operator float2(float value) => new(value, value);
public static explicit operator System.Numerics.Vector2(float2 value) => new(value.x, value.y);
public static explicit operator float2(System.Numerics.Vector2 value) => new(value.X, value.Y);
public static float2 operator +(float2 value) => value;
public static float2 operator -(float2 value) => new(-value.x, -value.y);
public static float2 operator +(float2 left, float2 right) => new(left.x + right.x, left.y + right.y);
public static float2 operator -(float2 left, float2 right) => new(left.x - right.x, left.y - right.y);
public static float2 operator *(float2 left, float2 right) => new(left.x * right.x, left.y * right.y);
public static float2 operator /(float2 left, float2 right) => new(left.x / right.x, left.y / right.y);
public static float2 operator %(float2 left, float2 right) => new(left.x % right.x, left.y % right.y);
}