Create Box3d structure.

This commit is contained in:
H. Utku Maden 2024-12-14 16:27:09 +03:00
parent 8bc2685206
commit c706e16db1
2 changed files with 31 additions and 6 deletions

31
Dashboard/Box3d.cs Normal file

@ -0,0 +1,31 @@
using System.Numerics;
namespace Dashboard
{
public readonly record struct Box3d(Vector3 Min, Vector3 Max)
{
public float Left => Min.X;
public float Right => Max.X;
public float Top => Min.Y;
public float Bottom => Max.Y;
public float Far => Min.Z;
public float Near => Max.Z;
public Vector3 Size => Max - Min;
public Vector3 Center => Min + Size / 2f;
public static Box3d Union(Box3d left, Box3d right)
{
Vector3 min = Vector3.Min(left.Min, right.Min);
Vector3 max = Vector3.Max(left.Max, right.Max);
return new Box3d(min, max);
}
public static Box3d Intersect(Box3d left, Box3d right)
{
Vector3 min = Vector3.Max(left.Min, right.Min);
Vector3 max = Vector3.Min(left.Max, right.Max);
return new Box3d(min, max);
}
}
}

@ -1,6 +0,0 @@
namespace Dashboard;
public class Class1
{
}