Skip to content
This repository was archived by the owner on Mar 30, 2019. It is now read-only.

Commit e354acf

Browse files
committed
[Maths] Add properties for bounding box (size + center)
1 parent 8f830b5 commit e354acf

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

Source/SharpDX.Mathematics/BoundingBox.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,46 @@ public BoundingBox(Vector3 minimum, Vector3 maximum)
7777
this.Maximum = maximum;
7878
}
7979

80+
/// <summary>
81+
/// Returns the width of the bounding box
82+
/// </summary>
83+
public float Width
84+
{
85+
get { return this.Maximum.X - this.Minimum.X; }
86+
}
87+
88+
/// <summary>
89+
/// Returns the height of the bounding box
90+
/// </summary>
91+
public float Height
92+
{
93+
get { return this.Maximum.Y - this.Minimum.Y; }
94+
}
95+
96+
/// <summary>
97+
/// Returns the height of the bounding box
98+
/// </summary>
99+
public float Depth
100+
{
101+
get { return this.Maximum.Z - this.Minimum.Z; }
102+
}
103+
104+
/// <summary>
105+
/// Returns the size of the bounding box
106+
/// </summary>
107+
public Vector3 Size
108+
{
109+
get { return this.Maximum - this.Minimum; }
110+
}
111+
112+
/// <summary>
113+
/// Returns the size of the bounding box
114+
/// </summary>
115+
public Vector3 Center
116+
{
117+
get { return this.Minimum + (this.Maximum - this.Minimum) * 0.5f; }
118+
}
119+
80120
/// <summary>
81121
/// Retrieves the eight corners of the bounding box.
82122
/// </summary>

0 commit comments

Comments
 (0)