Go::Point Class Reference
['utils' - a collection of useful math and programming tools]

Run-time sized point class. More...

#include <Point.h>

List of all members.

Public Member Functions

 Point ()
 Default constructor, does not initialize elements.
 Point (int dim)
 Constructor taking a dimension argument.
 Point (double x, double y)
 Constructor taking 2 arguments, makes the 2D-point (x,y).
 Point (double x, double y, double z)
 Constructor taking 3 arguments, makes the 3D-point (x,y,z).
template<typename T, int Dim>
 Point (const Array< T, Dim > &v)
 Constructor making a Point as a copy of an Array.
template<typename RandomAccessIterator>
 Point (RandomAccessIterator first, RandomAccessIterator last)
 Constructor making a Point from an iterator range.
 Point (double *begin, double *end, bool own)
 Make a point from an existing range of doubles.
 Point (const Point &v)
 Copy constructor.
Pointoperator= (const Point &v)
 Assignment operator.
 ~Point ()
 Destructor.
void swap (Point &other)
 Swaps two Point instances. Never throws.
void read (std::istream &is)
 Reads a Point elementwise from a standard istream.
void write (std::ostream &os) const
 Writes a Point elementwise to a standard ostream.
const double & operator[] (int i) const
 Read-only index access.
double & operator[] (int i)
 Index access.
const double * begin () const
 Get a read-only start iterator.
double * begin ()
 Get a start iterator.
const double * end () const
 Get a read-only end iterator.
double * end ()
 Get a end iterator.
int size () const
 Get the dimension of the Point.
int dimension () const
 Get the dimension of the Point. Same as size().
void resize (int d)
 Changing dimension. This loses all info in the point.
void setValue (double x, double y)
 Set function for 2D.
void setValue (double x, double y, double z)
 Set function for 3D.
void setValue (const double *array)
 Set function that copies values from an input array.
void setValue (double val)
 Set function that sets all elements equal to the input.
void resetValue (int idx, double val)
double length2 () const
 Get the square of the euclidian length of the vector.
double length () const
 Get the euclidian length of the vector.
double lengthInf () const
 Get the infinity-norm (or max-norm) length of the vector.
double dist2 (const Point &v) const
 Get the square of the euclidian length of the difference between this vector and another vector.
double dist (const Point &v) const
 Get the euclidian length of the difference between this vector and another vector.
double distInf (const Point &v) const
 Get the infinity-norm (or max-norm) length of the difference between this vector and another vector.
void normalize ()
 Normalize this vector, i.e.
double normalize_checked ()
Point operator+ (const Point &v) const
 The sum of two vectors.
void operator+= (const Point &v)
 Add a vector to this vector.
Point operator- (const Point &v) const
 The difference between two vectors.
void operator-= (const Point &v)
 Subtract a vector from this vector.
Point operator * (double d) const
 The product of a vector and a scalar.
void operator *= (double d)
 Multiply this vector by a scalar.
Point operator/ (double d) const
 A vector divided by a scalar.
void operator/= (double d)
 Divide this vector with a scalar.
Point operator- () const
 The negation of a vector.
double operator * (const Point &v) const
 The scalar product (or inner product, or dot product) of two vectors.
Point operator% (const Point &v) const
 The cross product of two vectors.
Point cross (const Point &v) const
 The cross product of two vectors.
void setToCrossProd (const Point &u, const Point &v)
 Set this Point to the cross product of two other Points.
double cosAngle (const Point &v) const
 The cosine of the angle between this and another vector.
double angle (const Point &v) const
 The angle between this and another vector.
double angle_smallest (const Point &v) const
 The smallest angle between this and another vector regardless of orientation.


Detailed Description

Run-time sized point class.

Encapsulates a point or vector with full value semantics, i.e. copying and assignment works as expected. The class has some vector algebra functionality, such as scalar product, multiplication by scalars etc, and objects will sometimes be called 'vectors' in the following. Based on double precision floating point numbers.

Definition at line 56 of file Point.h.


Constructor & Destructor Documentation

Go::Point::Point (  )  [inline]

Default constructor, does not initialize elements.

The only functions you are allowed to use with a default constructed (0-dim) Point are the assignment operator, resize and setValue(...). This is not enforced.

Definition at line 68 of file Point.h.

Referenced by operator%().

Go::Point::Point ( int  dim  )  [inline, explicit]

Constructor taking a dimension argument.

Resulting point is of the specified dimension, but not initialized.

Definition at line 74 of file Point.h.

template<typename T, int Dim>
Go::Point::Point ( const Array< T, Dim > &  v  )  [inline, explicit]

Constructor making a Point as a copy of an Array.

The Array must have a value type convertible to double.

Definition at line 101 of file Point.h.

References Go::Array< T, Dim >::begin(), and Go::Array< T, Dim >::end().

Go::Point::Point ( double *  begin,
double *  end,
bool  own 
) [inline]

Make a point from an existing range of doubles.

If the own parmeter is false, the Point will refer to the input data, and not own them. If it is true, it will act as a regular point, owning its data.

Definition at line 147 of file Point.h.


Member Function Documentation

void Go::Point::read ( std::istream &  is  ) 

Reads a Point elementwise from a standard istream.

The Point must already be initialized with the correct dimension.

Referenced by Go::operator>>().

void Go::Point::write ( std::ostream &  os  )  const

Writes a Point elementwise to a standard ostream.

Precision is set to 16 by this function. Dimension is not stored.

Referenced by Go::operator<<().

void Go::Point::setValue ( const double *  array  )  [inline]

Set function that copies values from an input array.

Dimension must already be initialized!

Definition at line 246 of file Point.h.

void Go::Point::setValue ( double  val  )  [inline]

Set function that sets all elements equal to the input.

Dimension must already be initialized!

Definition at line 255 of file Point.h.

void Go::Point::normalize (  )  [inline]

Normalize this vector, i.e.

divide every element by length().

Definition at line 329 of file Point.h.

References length().

Referenced by Go::DirectionCone::DirectionCone().

Point Go::Point::operator% ( const Point v  )  const [inline]

The cross product of two vectors.

Dimensions should be 3.

Definition at line 428 of file Point.h.

References n_, Point(), and pstart_.

Referenced by cross().

Point Go::Point::cross ( const Point v  )  const [inline]

The cross product of two vectors.

Throws if dimensions are not 3.

Definition at line 439 of file Point.h.

References operator%().


The documentation for this class was generated from the following file:
Generated on Mon Jun 11 14:48:19 2007 for GoTools Core Library by  doxygen 1.5.1