MOAB: Mesh Oriented datABase  (version 5.4.1)
sphere Class Reference
+ Inheritance diagram for sphere:
+ Collaboration diagram for sphere:

Public Member Functions

 sphere (double x=0, double y=0, double z=0, double r=1)
virtual ~sphere ()
void project_points2geom (int dim, double *oldcoords, double *newcoords, double *derivs) const

Private Attributes

double centerx
double centery
double centerz
double radius

Detailed Description

Definition at line 58 of file geomObject.cpp.


Constructor & Destructor Documentation

sphere::sphere ( double  x = 0,
double  y = 0,
double  z = 0,
double  r = 1 
) [inline]

Definition at line 61 of file geomObject.cpp.

        : centerx( x ), centery( y ), centerz( z ), radius( r )
    {
        assert( r > 0 );
    }
virtual sphere::~sphere ( ) [inline, virtual]

Definition at line 66 of file geomObject.cpp.

{}

Member Function Documentation

void sphere::project_points2geom ( int  dim,
double *  oldcoords,
double *  newcoords,
double *  derivs 
) const [inline, virtual]

Implements geomObject.

Definition at line 67 of file geomObject.cpp.

References centerx, centery, centerz, dim, radius, and geomObject::Twonorm().

    {
        if( oldcoords == NULL || newcoords == NULL )
        {
            throw std::invalid_argument( "NULL pointer" );
        }

        std::vector< double > direction;
        direction.push_back( oldcoords[0] - centerx );
        direction.push_back( oldcoords[1] - centery );

        if( dim == 3 )
        {
            direction.push_back( oldcoords[2] - centerz );
        }

        double len = geomObject::Twonorm( dim, &( direction[0] ) );
        assert( len > 0 );

        for( int i = 0; i < dim; ++i )
        {
            direction[i] /= len;
        }

        newcoords[0] = centerx + direction[0] * radius;
        newcoords[1] = centery + direction[1] * radius;

        if( dim == 2 )
        {
            if( derivs )
            {
                derivs[0] = -direction[1];
                derivs[1] = direction[0];
            }

            return;
        }
        else if( dim == 3 )
        {
            newcoords[2] = centerz + direction[2] * radius;

            if( derivs )
            {
                derivs[0] = direction[0];
                derivs[1] = direction[1];
                derivs[2] = direction[2];
            }
        }
        else
        {
            throw std::invalid_argument( "dim must be 2 or 3" );
        }
    }

Member Data Documentation

double sphere::centerx [private]

Definition at line 122 of file geomObject.cpp.

Referenced by project_points2geom().

double sphere::centery [private]

Definition at line 122 of file geomObject.cpp.

Referenced by project_points2geom().

double sphere::centerz [private]

Definition at line 122 of file geomObject.cpp.

Referenced by project_points2geom().

double sphere::radius [private]

Definition at line 122 of file geomObject.cpp.

Referenced by project_points2geom().

List of all members.


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