Commit a01095ad authored by hybrid's avatar hybrid

Add getRadius method for aabbox3d, as suggested by hendu

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4474 dfc29bdd-3216-0410-991c-e03cc46cb475
parent a36cdf07
......@@ -115,6 +115,14 @@ class aabbox3d
return MaxEdge - MinEdge;
}
//! Get radius of the bounding sphere
/** \return Radius of the bounding sphere. */
T getRadius() const
{
const T radius = getExtent().getLength() / 2;
return radius;
}
//! Check if the box is empty.
/** This means that there is no space between the min and max edge.
\return True if box is empty, else false. */
......
......@@ -211,6 +211,11 @@ static bool doTests()
logTestString("default aabbox3d<T> has wrong Extent\n");
return false;
}
if (!core::equals(empty.getRadius(), (T)sqrt(3.0)))
{
logTestString("default aabbox3d<T> has wrong radius\n");
return false;
}
if (empty.isEmpty())
{
logTestString("default aabbox3d<T> is empty\n");
......@@ -242,6 +247,11 @@ static bool doTests()
logTestString("extended aabbox3d<T> has wrong Extent\n");
return false;
}
if (!core::equals(two.getRadius(), (T)sqrt(27./4.)))
{
logTestString("extended aabbox3d<T> has wrong radius\n");
return false;
}
if (two.isEmpty())
{
logTestString("extended aabbox3d<T> is empty\n");
......@@ -273,6 +283,11 @@ static bool doTests()
logTestString("singular aabbox3d<T> has Extent\n");
return false;
}
if (one.getRadius() != 0)
{
logTestString("singular aabbox3d<T> has radius\n");
return false;
}
if (!one.isEmpty())
{
logTestString("empty aabbox3d<T> is not empty\n");
......@@ -337,6 +352,11 @@ static bool doTests()
logTestString("large aabbox3d<T> has wrong Extent\n");
return false;
}
if (!core::equals(one.getRadius(), (T)sqrt(50./4.)))
{
logTestString("large aabbox3d<T> has wrong radius\n");
return false;
}
if (one.isEmpty())
{
logTestString("large aabbox3d<T> is empty\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment