From c706e16db1ad3336bae7f6d0b92775896c285085 Mon Sep 17 00:00:00 2001 From: "H. Utku Maden" Date: Sat, 14 Dec 2024 16:27:09 +0300 Subject: [PATCH] Create Box3d structure. --- Dashboard/Box3d.cs | 31 +++++++++++++++++++++++++++++++ Dashboard/Class1.cs | 6 ------ 2 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 Dashboard/Box3d.cs delete mode 100644 Dashboard/Class1.cs diff --git a/Dashboard/Box3d.cs b/Dashboard/Box3d.cs new file mode 100644 index 0000000..1849546 --- /dev/null +++ b/Dashboard/Box3d.cs @@ -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); + } + } +} diff --git a/Dashboard/Class1.cs b/Dashboard/Class1.cs deleted file mode 100644 index 70484e5..0000000 --- a/Dashboard/Class1.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Dashboard; - -public class Class1 -{ - -}