Create Box3d structure.
This commit is contained in:
parent
8bc2685206
commit
c706e16db1
31
Dashboard/Box3d.cs
Normal file
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
|
||||
{
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user