MOAB: Mesh Oriented datABase
(version 5.4.1)
|
Sphere. More...
#include <MsqGeomPrim.hpp>
Public Member Functions | |
MsqSphere (const Vector3D &p_center, double p_radius) | |
const Vector3D & | center () const |
double | radius () const |
Vector3D | closest (const Vector3D &point) const |
bool | closest (const Vector3D &point, Vector3D &point_on_sphere, Vector3D &normal_at_point) const |
double | distance (const Vector3D &point) const |
bool | intersect (const MsqPlane &plane, MsqCircle &result) const |
bool | intersect (const MsqSphere &sphere, MsqCircle &result) const |
Private Attributes | |
Vector3D | mCenter |
double | mRadius |
Sphere.
Definition at line 197 of file MsqGeomPrim.hpp.
MBMesquite::MsqSphere::MsqSphere | ( | const Vector3D & | p_center, |
double | p_radius | ||
) | [inline] |
Definition at line 204 of file MsqGeomPrim.hpp.
const Vector3D& MBMesquite::MsqSphere::center | ( | ) | const [inline] |
Definition at line 206 of file MsqGeomPrim.hpp.
Referenced by closest(), intersect(), GeomPrimTest::test_sphere_basic(), GeomPrimTest::test_sphere_intersect_plane(), and GeomPrimTest::test_sphere_intersect_sphere().
{ return mCenter; }
Vector3D MBMesquite::MsqSphere::closest | ( | const Vector3D & | point | ) | const |
Get location on sphere closest to input location. Returns arbitrary point if input location is at center.
Definition at line 158 of file MsqGeomPrim.cpp.
References center(), MBMesquite::Vector3D::length(), and radius().
Referenced by GeomPrimTest::test_sphere_closest_to_point().
bool MBMesquite::MsqSphere::closest | ( | const Vector3D & | point, |
Vector3D & | point_on_sphere, | ||
Vector3D & | normal_at_point | ||
) | const |
Get location on sphere closest to input location, and normal at closest point.
Definition at line 172 of file MsqGeomPrim.cpp.
References center(), MBMesquite::Vector3D::length(), and radius().
double MBMesquite::MsqSphere::distance | ( | const Vector3D & | point | ) | const [inline] |
Definition at line 224 of file MsqGeomPrim.hpp.
References center(), MBMesquite::length(), and radius.
Referenced by GeomPrimTest::test_sphere_intersect_sphere().
bool MBMesquite::MsqSphere::intersect | ( | const MsqPlane & | plane, |
MsqCircle & | result | ||
) | const |
Intersect plane with sphere
Definition at line 183 of file MsqGeomPrim.cpp.
References center(), MBMesquite::MsqPlane::closest(), MBMesquite::Vector3D::length_squared(), MBMesquite::MsqPlane::normal(), and radius().
Referenced by GeomPrimTest::test_sphere_intersect_plane(), and GeomPrimTest::test_sphere_intersect_sphere().
{ const Vector3D plane_pt = plane.closest( center() ); const Vector3D plane_dir = plane_pt - center(); const double dir_sqr = plane_dir.length_squared(); if( dir_sqr < DBL_EPSILON ) { // plane passes through center of sphere result = MsqCircle( center(), plane.normal(), radius() ); return true; } double rad_sqr = radius() * radius() - plane_dir.length_squared(); if( rad_sqr < 0 ) // no intersection return false; result = MsqCircle( plane_pt, plane_dir, sqrt( rad_sqr ) ); return true; }
bool MBMesquite::MsqSphere::intersect | ( | const MsqSphere & | sphere, |
MsqCircle & | result | ||
) | const |
Intersect spheres
Definition at line 202 of file MsqGeomPrim.cpp.
References center(), dist(), MBMesquite::Vector3D::length(), and radius().
{ const Vector3D d = sphere.center() - center(); const double dist = d.length(); if( dist > ( radius() + sphere.radius() ) ) return false; const double r1_sqr = radius() * radius(); const double r2_sqr = sphere.radius() * sphere.radius(); const double f = ( d % d + r1_sqr - r2_sqr ) / 2; // const double d1 = f / dist; const double rad = sqrt( r1_sqr - f * f / ( d % d ) ); Vector3D c = center() + d * f / ( d % d ); result = MsqCircle( c, d, rad ); return true; }
double MBMesquite::MsqSphere::radius | ( | ) | const [inline] |
Definition at line 210 of file MsqGeomPrim.hpp.
Referenced by closest(), intersect(), GeomPrimTest::test_sphere_basic(), GeomPrimTest::test_sphere_intersect_plane(), and GeomPrimTest::test_sphere_intersect_sphere().
{ return mRadius; }
Vector3D MBMesquite::MsqSphere::mCenter [private] |
Definition at line 200 of file MsqGeomPrim.hpp.
double MBMesquite::MsqSphere::mRadius [private] |
Definition at line 201 of file MsqGeomPrim.hpp.