Commit 84caab04 authored by Sreekanth Arikatla's avatar Sreekanth Arikatla Committed by Andrew Wilson
Browse files

TEST: Add sdf tests for closed-form geometry

parent daed2750
......@@ -63,11 +63,25 @@ TEST_F(imstkCubeTest, GetVolume)
m_cube.setWidth(0.003);
EXPECT_EQ(m_cube.getVolume(), 0.003 * 0.003 * 0.003);
double w = 400000000;
const double w = 400000000;
m_cube.setWidth(400000000);
EXPECT_EQ(m_cube.getVolume(), w * w * w);
}
///
/// \brief test the cube SDF evaluator
///
TEST_F(imstkCubeTest, GetFunctionValue)
{
m_cube.setWidth(2.);
m_cube.updatePostTransformData();
EXPECT_EQ(m_cube.getFunctionValue(Vec3d(0., 0., 0.)), -1.);
EXPECT_EQ(m_cube.getFunctionValue(Vec3d(0.5, 0., 0.)), -0.5);
EXPECT_EQ(m_cube.getFunctionValue(Vec3d(1., 1., 1.)), 0.);
EXPECT_EQ(m_cube.getFunctionValue(Vec3d(0., -10., 0.)), 9.);
}
///
/// \brief TODO
///
......
......@@ -85,6 +85,29 @@ TEST_F(imstkPlaneTest, GetVolume)
EXPECT_EQ(m_plane.getVolume(), 0);
}
///
/// \brief test the plane SDF evaluator
///
TEST_F(imstkPlaneTest, GetFunctionValue)
{
m_plane.setNormal(Vec3d(0., 1., 0.));
m_plane.updatePostTransformData();
EXPECT_EQ(m_plane.getFunctionValue(Vec3d(0., 0., 0.)), 0.);
EXPECT_EQ(m_plane.getFunctionValue(Vec3d(0.5, 0., 0.)), 0.);
EXPECT_EQ(m_plane.getFunctionValue(Vec3d(1., 1., 1.)), 1.);
EXPECT_EQ(m_plane.getFunctionValue(Vec3d(0., -10., 0.)), -10.);
m_plane.setPosition(Vec3d(1., 1., 1.));
m_plane.setNormal(Vec3d(1., 1., 1.));
m_plane.updatePostTransformData();
EXPECT_FLOAT_EQ(m_plane.getFunctionValue(Vec3d(0., 0., 0.)), -std::sqrt(3.0));
EXPECT_EQ(m_plane.getFunctionValue(Vec3d(1., 1., 1.)), 0.0);
EXPECT_FLOAT_EQ(m_plane.getFunctionValue(Vec3d(1., 0., 0.)), -2.0 / std::sqrt(3.0));
EXPECT_FLOAT_EQ(m_plane.getFunctionValue(Vec3d(0., -10., 0.)), -13.0 / std::sqrt(3.0));
}
///
/// \brief TODO
///
......
......@@ -68,6 +68,21 @@ TEST_F(imstkSphereTest, GetVolume)
EXPECT_EQ(m_sphere.getVolume(), 4.0 / 3.0 * PI * r * r * r);
}
///
/// \brief test the sphere SDF evaluator
///
TEST_F(imstkSphereTest, GetFunctionValue)
{
m_sphere.setRadius(20.);
m_sphere.updatePostTransformData();
EXPECT_EQ(m_sphere.getFunctionValue(Vec3d(0., 0., 0.)), -20.);
EXPECT_EQ(m_sphere.getFunctionValue(Vec3d(5., 0., 0.)), -15);
EXPECT_EQ(m_sphere.getFunctionValue(Vec3d(1., 1., 1.)), -20.0 + std::sqrt(3));
EXPECT_EQ(m_sphere.getFunctionValue(Vec3d(0., 20., 0.)), 0.);
EXPECT_EQ(m_sphere.getFunctionValue(Vec3d(0., 0., 50.)), 30.);
}
///
/// \brief TODO
///
......
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