IMP logo

IMP::algebra::VectorD< D > Class Template Reference


Detailed Description

template<unsigned int D>
class IMP::algebra::VectorD< D >

A Cartesian vector in D-dimensions.

Store a vector of Cartesian coordinates. It supports all expected mathematical operators, including using * for the dot product.

See also:
VectorD<3>

VectorD<2>

Note:
This class is a geometric primitive. Also, this class is not not initialized by its default constructor.
Inheritance diagram for IMP::algebra::VectorD< D >:

Inheritance graph
[legend]

Public Types

typedef const double * CoordinateConstIterator
typedef double * CoordinateIterator

Public Member Functions

CoordinateConstIterator coordinates_begin () const
CoordinateIterator coordinates_begin ()
CoordinateConstIterator coordinates_end () const
CoordinateIterator coordinates_end ()
double get_magnitude () const
double get_scalar_product (const VectorD< D > &o) const
double get_squared_magnitude () const
VectorD get_unit_vector () const
double & operator[] (unsigned int i)
double operator[] (unsigned int i) const
 VectorD ()
 Default constructor.
 VectorD (double x0, double x1, double x2, double x3)
 Initialize a 4-vector from separate w,x,y,z values.
 VectorD (double x, double y, double z)
 Initialize a 3-vector from separate x,y,z values.
 VectorD (double x, double y)
 Initialize a 2-vector from separate x,y values.
 VectorD (double x)
 Initialize the 1-vector from its value.
template<class It >
 VectorD (It b, It e)

Related Functions

(Note that these are not member functions.)

template<unsigned int D>
int compare (const VectorD< D > &a, const VectorD< D > &b)
 lexicographic comparison of two vectors
template<unsigned int D>
VectorD< D > get_basis_vector_d (unsigned int coordinate)
 Return the basis vector for the given coordinate.
template<unsigned int D>
double get_distance (const VectorD< D > &v1, const VectorD< D > &v2)
 compute the distance between two vectors
SphereD< 3 > get_enclosing_sphere (const std::vector< VectorD< 3 > > &ss)
 Return a sphere containing the listed spheres.
template<unsigned int D>
double get_squared_distance (const VectorD< D > &v1, const VectorD< D > &v2)
 compute the squared distance between two vectors
template<unsigned int D>
VectorD< D > operator* (double s, const VectorD< D > &o)
3D Vectors
We provide a specialization of VectorD for 3-space and several additional functions on it.

VectorD< 3 > get_centroid (const std::vector< VectorD< 3 > > &ps)
 Returns the centroid of a set of vectors.
VectorD< 3 > get_orthogonal_vector (const VectorD< 3 > &v)
 Return a vector that is perpendicular to the given vector.
VectorD< 3 > get_vector_product (const VectorD< 3 > &p1, const VectorD< 3 > &p2)
 Returns the vector product (cross product) of two vectors.
Vector Generators
These functions generate vector objects. Some of the methods, those with random in their name, generate a single vector chosen uniformly from the specified domain. Others, the cover methods, generate a set of points distributed (somewhat) evenly over the domain.

template<unsigned int D>
VectorD< D > get_random_vector_in (const BoundingBoxD< D > &bb)
 Generate a random vector in a box with uniform density.
template<unsigned int D>
VectorD< D > get_random_vector_on (const BoundingBoxD< D > &bb)
 Generate a random vector on a box with uniform density.
std::vector< VectorD< 3 > > get_uniform_surface_cover (const SpherePatch3D &sph, unsigned int number_of_points)
 Generate a set of 3d points that uniformly cover a patch of a sphere.
Shortest segments
These methods return the shortest segment connecting two geometric objects. Such segments can be used to give the direction of the derivative of the distance between the two objects. The 0 point on the segment is in the first passed object and the 1 point is in the second.

Segment3D get_shortest_segment (const Segment3D &s, const VectorD< 3 > &p)
Simple geometric IO
These functions write geometry to text files, one line per geometric primitive. Each line has the form “x y z” for points or “x y z r” for spheres. We can easily add general dimension support if requested.. Lines beginning with "#" are treated as comments.

std::vector< VectorD< 3 > > read_pts (TextInput in)
 Read a set of 3D vectors from a file.
void write_pts (const std::vector< VectorD< 3 > > &vs, TextOutput out)
 Write a set of 3D vectors to a file.

Constructor & Destructor Documentation

template<unsigned int D>
template<class It >
IMP::algebra::VectorD< D >::VectorD ( It  b,
It  e 
)

The distance between b and e must be equal to D.


Member Function Documentation

template<unsigned int D>
double& IMP::algebra::VectorD< D >::operator[] ( unsigned int  i  ) 

Return the ith Cartesian coordinate. In 3D use [0] to get the x coordinate etc.

template<unsigned int D>
double IMP::algebra::VectorD< D >::operator[] ( unsigned int  i  )  const

Return the ith Cartesian coordinate. In 3D use [0] to get the x coordinate etc.


Friends And Related Function Documentation

template<unsigned int D>
VectorD< D > get_basis_vector_d ( unsigned int  coordinate  )  [related]

Return the basis vector for the given coordinate.

Return the unit vector pointing in the direction of the requested coordinate. That is

    get_basis_vector_d<3>(2)== VectorD<3>(0,0,1);

template<unsigned int D>
VectorD< 3 > get_centroid ( const std::vector< VectorD< 3 > > &  ps  )  [related]

Returns the centroid of a set of vectors.

<3>

template<unsigned int D>
SphereD< 3 > get_enclosing_sphere ( const std::vector< VectorD< 3 > > &  ss  )  [related]

Return a sphere containing the listed spheres.

<3> <3>

Note:
This method produces tighter bounding spheres if CGAL is used.

template<unsigned int D>
VectorD< 3 > get_orthogonal_vector ( const VectorD< 3 > &  v  )  [related]

Return a vector that is perpendicular to the given vector.

Or, if you are Israeli, it is a vertical vector. <3>

template<unsigned int D>
Segment3D get_shortest_segment ( const Segment3D s,
const VectorD< 3 > &  p 
) [related]

<3>

template<unsigned int D>
std::vector< VectorD< 3 > > get_uniform_surface_cover ( const SpherePatch3D sph,
unsigned int  number_of_points 
) [related]

Generate a set of 3d points that uniformly cover a patch of a sphere.

Note:
the implementation can be improved

template<unsigned int D>
VectorD< 3 > get_vector_product ( const VectorD< 3 > &  p1,
const VectorD< 3 > &  p2 
) [related]

Returns the vector product (cross product) of two vectors.

<3>

template<unsigned int D>
VectorD< D > operator* ( double  s,
const VectorD< D > &  o 
) [related]

template<unsigned int D>
std::vector< VectorD< 3 > > read_pts ( TextInput  in  )  [related]

Read a set of 3D vectors from a file.

See also:
write_pts

template<unsigned int D>
void write_pts ( const std::vector< VectorD< 3 > > &  vs,
TextOutput  out 
) [related]

Write a set of 3D vectors to a file.

See also:
read_pts


The documentation for this class was generated from the following files:

Generated on Mon Mar 8 23:08:47 2010 for IMP by doxygen 1.5.8