MOAB: Mesh Oriented datABase  (version 5.4.1)
MBMesquite::MsqPlane Class Reference

Plane. More...

#include <MsqGeomPrim.hpp>

+ Collaboration diagram for MBMesquite::MsqPlane:

Public Member Functions

 MsqPlane (const Vector3D &p_normal, double coeff)
 MsqPlane (const Vector3D &p_normal, const Vector3D &p_point)
 MsqPlane (double a, double b, double c, double d)
 ax+by+cz+d=0
const Vector3Dnormal () const
 get unit normal vector for plane
double coefficient () const
 get coefficient term for plane
Vector3D point () const
 Get point on plane closest to origin.
double distance (const Vector3D &p_point) const
 Get distance from point to plane.
Vector3D closest (const Vector3D &p_point) const
 Get closest location on plane to input position.
bool intersect (const MsqPlane &plane, MsqLine &result) const
bool intersect (const MsqLine &line, double &line_param) const

Private Attributes

Vector3D mNormal
 unit normal
double mCoeff

Detailed Description

Plane.

Definition at line 145 of file MsqGeomPrim.hpp.


Constructor & Destructor Documentation

MBMesquite::MsqPlane::MsqPlane ( const Vector3D p_normal,
double  coeff 
)

Definition at line 117 of file MsqGeomPrim.cpp.

References MBMesquite::Vector3D::length(), mCoeff, and mNormal.

{
    const double len = p_normal.length();
    mNormal          = p_normal / len;
    mCoeff           = coeff / len;
}
MBMesquite::MsqPlane::MsqPlane ( const Vector3D p_normal,
const Vector3D p_point 
)

Definition at line 124 of file MsqGeomPrim.cpp.

    : mNormal( p_normal / p_normal.length() ), mCoeff( -( mNormal % p_point ) )
{
}
MBMesquite::MsqPlane::MsqPlane ( double  a,
double  b,
double  c,
double  d 
)

ax+by+cz+d=0

Definition at line 129 of file MsqGeomPrim.cpp.

References MBMesquite::Vector3D::length(), mCoeff, and mNormal.

                                                           : mNormal( a, b, c ), mCoeff( d )
{
    const double len = mNormal.length();
    mNormal /= len;
    mCoeff /= len;
}

Member Function Documentation

Vector3D MBMesquite::MsqPlane::closest ( const Vector3D p_point) const [inline]

Get closest location on plane to input position.

Definition at line 182 of file MsqGeomPrim.hpp.

Referenced by MBMesquite::MsqSphere::intersect(), and GeomPrimTest::test_plane_closest_to_point().

    {
        return p_point - normal() * ( normal() % p_point + coefficient() );
    }
double MBMesquite::MsqPlane::coefficient ( ) const [inline]

get coefficient term for plane

Definition at line 164 of file MsqGeomPrim.hpp.

Referenced by intersect(), and GeomPrimTest::test_plane_basic().

    {
        return mCoeff;
    }
double MBMesquite::MsqPlane::distance ( const Vector3D p_point) const [inline]

Get distance from point to plane.

Definition at line 176 of file MsqGeomPrim.hpp.

Referenced by GeomPrimTest::test_plane_distance(), and GeomPrimTest::test_plane_intersect_plane().

    {
        return fabs( normal() % p_point + coefficient() );
    }
bool MBMesquite::MsqPlane::intersect ( const MsqPlane plane,
MsqLine result 
) const

Find intersection of this plane with another.

Returns:
false if parallel or invalid plane, true otherwise

Definition at line 136 of file MsqGeomPrim.cpp.

References coefficient(), MBMesquite::det(), moab::dot(), and normal().

Referenced by GeomPrimTest::test_plane_intersect_line(), and GeomPrimTest::test_plane_intersect_plane().

{
    const double dot = normal() % plane.normal();
    const double det = dot * dot - 1.0;
    if( fabs( det ) < DBL_EPSILON )  // parallel
        return false;

    const double s1 = ( coefficient() - dot * plane.coefficient() ) / det;
    const double s2 = ( plane.coefficient() - dot * coefficient() ) / det;
    result          = MsqLine( s1 * normal() + s2 * plane.normal(), normal() * plane.normal() );
    return true;
}
bool MBMesquite::MsqPlane::intersect ( const MsqLine line,
double &  line_param 
) const

Find point of itersection with a line

Returns:
false if parallel, true otherwise

Definition at line 149 of file MsqGeomPrim.cpp.

References coefficient(), MBMesquite::MsqLine::direction(), moab::dot(), normal(), and MBMesquite::MsqLine::point().

{
    const double dot = line.direction() % normal();
    if( fabs( dot ) < DBL_EPSILON ) return false;

    result = -( normal() % line.point() + coefficient() ) / dot;
    return true;
}
const Vector3D& MBMesquite::MsqPlane::normal ( ) const [inline]

get unit normal vector for plane

Definition at line 158 of file MsqGeomPrim.hpp.

Referenced by intersect(), MBMesquite::MsqSphere::intersect(), GeomPrimTest::test_plane_basic(), and GeomPrimTest::test_plane_intersect_plane().

    {
        return mNormal;
    }

Get point on plane closest to origin.

Definition at line 170 of file MsqGeomPrim.hpp.

Referenced by GeomPrimTest::test_plane_basic().

    {
        return -mCoeff * mNormal;
    }

Member Data Documentation

double MBMesquite::MsqPlane::mCoeff [private]

Definition at line 149 of file MsqGeomPrim.hpp.

Referenced by MsqPlane().

unit normal

Definition at line 148 of file MsqGeomPrim.hpp.

Referenced by MsqPlane().

List of all members.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines