Ball = { x | x in R^n, |x-c|<=r }
Where the center c and the radius r can be
specified.
NAO/Ball.hand link against library
libNAOBase.aThe following constructors are provided:
| NABall(n ); | |||
| Creates an NABall. | |||
|
| NABall(n ,r ); | ||||||
| Creates an NABall. | ||||||
|
| NABall(n ,r ,c ); | |||||||||
| Creates an NABall. | |||||||||
|
| NABall(n ,r ,c ); | |||||||||
| Creates an NABall. | |||||||||
|
The following member functions are available in addition to those provided
by the abstract interface NARegion:
Various constructors are provided. If the radius is not required, a unit ball will be created. If the center is omitted, the ball will be centered at the origin. The center may be passed as a PointOnManifold, or as an array of doubles.
The example follows a basic pattern for creating a new object. First several include files are used.
#include <NAO/Ball.h>
#include <NAO/NADblPt.h>
#include <NAO/UTPtMfld.h>
int main (int argc, char *argv[])
{
NAManifold *Ball=new NABall(5);
NAPointOnManifold *X=new NADoublePointOnManifold(.1,.3,0.,-.02,0.);
cout << "Hey! Did you know that ";
NAPrint(X);
if(Ball->isitinChart(X))
cout << " is inside";
else
cout << " is not inside";
cout << " a five dimensional ball of radius 1 centered at the origin?" << endl;
X->unReference();
Ball->unReference();
return(0);
}
The first statement calls the constructor for the NABall. The second statement constructs a point in R5. The rest of the example prints the point in R5, and tests to see if it is inside the ball or not.
This is what I see when I run this:
Hey! Did you know that [(0.1,0.3,0,-0.02,0),0] is inside a five dimensional ball of radius 1 centered at the origin?
~NATopLevel: Just deleted the last NATopLevel Object
total TopLevels allocated 3
PointOnManifolds 1
Manifolds 1
FunctionSpaces 0
Functions 0
OperatorSpaces 0
Operators 0
We see first the answer to our question. This point happens to be inside the ball. Then we see an informational message that tells us that all of the NAO objects that were created in the program were properly deleted. This means no memory leaks. We see the point X and the Ball.
Siblings of this class:
[Comments | NAO home page ]
[ IBM home page | Order | Privacy | ContactIBM | Legal ]