Skip to main content

NAO


NAO Class NABall

Overview


An NABall is an n-dimensional Ball:
   Ball = { x | x in R^n, |x-c|<=r }
Where the center c and the radius r can be specified.


User's Guide


To use this class, you must include the header file
NAO/Ball.h
and link against library
libNAOBase.a
The following constructors are provided:

The following member functions are available in addition to those provided by the abstract interface NARegion:


Programmer's Guide


The NABall stores:

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.


Example


This is a very simple example of how to create a unit Ball in five dimensions, centered at the origin. It doesn't do anything with it, but I can imagine all sorts of things that you might do if someone gave you a five dimensional unit ball.

The example follows a basic pattern for creating a new object. First several include files are used.

NAO/Ball.h
Contains the definition of the NABall. We can tell which file to include from the documentation for the NABall class.
NAO/NADblPt.h
Definition of points with double precision coordinates. We'll be using these to create a point inside the Ball.
NAO/UTPTMfld.h
The Utilities for printing points. This provides an easy way to print points in a readable form.

#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.


Related Classes and Subroutines


The parent of this class:

Siblings of this class:


Created: Fri Oct 9 07:28:32 EDT 1998

[Comments | NAO home page ]

[Research home page]

[ IBM home page | Order | Privacy | ContactIBM | Legal ]