IMP logo
Public Types | Public Member Functions | Related Functions
IMP::algebra::VectorD< D > Class Template Reference

Detailed Description

template<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:
Vector3D
Vector2D
Note:
This class is a geometric primitive. Also, this class is not not initialized by its default constructor.

Examples: XYZR Decorator, range restriction, symmetry, decay, grid space, cube, XYZ Decorator, filter close pairs, restraint cache, randomize rigid body, custom filter, markers, cg pdb, rigid collisions, simplex, dock with crosslinks, six particles optimization, rigid brownian dynamics, geometry, simulation, tasks, kmeans, interactive with containers, ms connectivity restraint, multiscale, rigid body excluded volume, analyze convergence, setup, rigid body and excluded volume restraint, interactive, nup84 cg, nup84 rb, domino approach, optimize balls, connectivity restraint, basic geometry, incremental mc, restrain in sphere

+ Inheritance diagram for IMP::algebra::VectorD< D >:

List of all members.

Public Types

typedef const double * CoordinateConstIterator
typedef double * CoordinateIterator

Public Member Functions

 VectorD (const Floats &f)
template<class It >
 VectorD (It b, It e)
 VectorD (double x)
 Initialize the 1-vector from its value.
 VectorD (double x, double y)
 Initialize a 2-vector from separate x,y values.
 VectorD (double x, double y, double z)
 Initialize a 3-vector from separate x,y,z values.
 VectorD (double x0, double x1, double x2, double x3)
 Initialize a 4-vector from separate w,x,y,z values.
 VectorD ()
 Default constructor.
CoordinateIterator coordinates_begin ()
CoordinateConstIterator coordinates_begin () const
CoordinateIterator coordinates_end ()
CoordinateConstIterator coordinates_end () const
Floats get_coordinates () const
unsigned int get_dimension () const
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) const
double & operator[] (unsigned int i)

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.

void write_pts (const Vector3Ds &vs, base::TextOutput out)
 Write a set of 3D vectors to a file.
Vector3Ds read_pts (base::TextInput input)
 Read a set of 3D vectors from a file.

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<int D>
VectorD< D > get_random_vector_in (const BoundingBoxD< D > &bb)
 Generate a random vector in a box with uniform density.
template<int D>
VectorD< D > get_random_vector_on (const BoundingBoxD< D > &bb)
 Generate a random vector on a box with uniform density.
Vector3Ds 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.

Related Functions

(Note that these are not member functions.)

template<int D>
int compare (const VectorD< D > &a, const VectorD< D > &b)
 lexicographic comparison of two vectors
template<int D>
VectorD< D > get_basis_vector_d (unsigned int coordinate)
 Return the basis vector for the given coordinate.
template<int D>
double get_distance (const VectorD< D > &v1, const VectorD< D > &v2)
 compute the distance between two vectors
template<int D>
VectorD< D > get_elementwise_product (const algebra::VectorD< D > &a, const algebra::VectorD< D > &b)
template<int D>
VectorD< D > get_elementwise_product (const Ints &a, const algebra::VectorD< D > &b)
template<int D>
double get_squared_distance (const VectorD< D > &v1, const VectorD< D > &v2)
 compute the squared distance between two vectors
template<int D>
VectorD< D > operator* (double s, const VectorD< D > &o)

Constructor & Destructor Documentation

template<int D>
IMP::algebra::VectorD< D >::VectorD ( const Floats &  f)
Exceptions:
base::ValueExceptionif f.size() is not appropriate.
template<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.

template<int D>
IMP::algebra::VectorD< D >::VectorD ( double  x)
explicit

Initialize the 1-vector from its value.

template<int D>
IMP::algebra::VectorD< D >::VectorD ( double  x,
double  y 
)

Initialize a 2-vector from separate x,y values.

template<int D>
IMP::algebra::VectorD< D >::VectorD ( double  x,
double  y,
double  z 
)

Initialize a 3-vector from separate x,y,z values.

template<int D>
IMP::algebra::VectorD< D >::VectorD ( double  x0,
double  x1,
double  x2,
double  x3 
)

Initialize a 4-vector from separate w,x,y,z values.

template<int D>
IMP::algebra::VectorD< D >::VectorD ( )

Default constructor.


Member Function Documentation

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

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


Friends And Related Function Documentation

template<int D>
int compare ( const VectorD< D > &  a,
const VectorD< D > &  b 
)
related

lexicographic comparison of two vectors

Note that this is not very reliable and probably should not be used.

template<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)== Vector3D(0,0,1);
template<int D>
double get_distance ( const VectorD< D > &  v1,
const VectorD< D > &  v2 
)
related

compute the distance between two vectors

template<int D>
VectorD< D > get_elementwise_product ( const algebra::VectorD< D > &  a,
const algebra::VectorD< D > &  b 
)
related

Return the vector that is the elementwise product of the two.

template<int D>
VectorD< D > get_elementwise_product ( const Ints &  a,
const algebra::VectorD< D > &  b 
)
related

Return the vector that is the elementwise product of the two.

template<int D>
VectorD< D > get_random_vector_in ( const BoundingBoxD< D > &  bb)
related

Generate a random vector in a box with uniform density.

template<int D>
VectorD< D > get_random_vector_on ( const BoundingBoxD< D > &  bb)
related

Generate a random vector on a box with uniform density.

template<int D>
double get_squared_distance ( const VectorD< D > &  v1,
const VectorD< D > &  v2 
)
related

compute the squared distance between two vectors

template<int D>
Vector3Ds 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<int D>
VectorD< D > operator* ( double  s,
const VectorD< D > &  o 
)
related
template<int D>
Vector3Ds read_pts ( base::TextInput  input)
related

Read a set of 3D vectors from a file.

See also:
write_pts
template<int D>
void write_pts ( const Vector3Ds vs,
base::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 Tue May 22 2012 23:33:25 for IMP by doxygen 1.8.1