IMP  2.0.0
The Integrative Modeling Platform
IMP::algebra::VectorD< D > Class Template Reference

A Cartesian vector in D-dimensions. More...

#include <IMP/algebra/VectorD.h>

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

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)
 

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 More...
 
template<int D>
VectorD< D > get_basis_vector_d (unsigned int coordinate)
 Return the basis vector for the given coordinate. More...
 
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>
const VectorD< D > & get_vector_d_geometry (const VectorD< D > &g)
 
template<int D>
VectorD< D > operator* (double s, const VectorD< D > &o)
 
template<int D>
void set_vector_d_geometry (VectorD< D > &g, const VectorD< D > &v)
 

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. More...
 
Vector3Ds read_pts (base::TextInput input)
 Read a set of 3D vectors from a file. More...
 

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

Detailed Description

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

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.

Definition at line 48 of file VectorD.h.

Constructor & Destructor Documentation

template<int D>
IMP::algebra::VectorD< D >::VectorD ( const Floats f)
Exceptions
base::ValueExceptionif f.size() is not appropriate.

Definition at line 92 of file VectorD.h.

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.

Definition at line 103 of file VectorD.h.

Member Function Documentation

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

Returns a unit vector pointing at the same direction as this vector.

Note
If the magnitude of this vector is smaller than 1e-12 (an arbitrarily selected small number), returns a unit vector pointing at a random direction

Definition at line 201 of file VectorD.h.

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.

Definition at line 164 of file VectorD.h.

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.

Definition at line 171 of file VectorD.h.

Friends And Related Function Documentation

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

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

Definition at line 374 of file VectorD.h.

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

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

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

Definition at line 415 of file VectorD.h.

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.

Definition at line 607 of file VectorD.h.

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.

Definition at line 620 of file VectorD.h.

template<int D>
Vector3Ds get_uniform_surface_cover ( const SpherePatch3D sph,
unsigned int  number_of_points 
)
related
Note
the implementation can be improved
template<int D>
const VectorD< D > & get_vector_d_geometry ( const VectorD< D > &  g)
related

Definition at line 597 of file VectorD.h.

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

Definition at line 386 of file VectorD.h.

template<int D>
Vector3Ds read_pts ( base::TextInput  input)
related
See Also
write_pts
template<int D>
void set_vector_d_geometry ( VectorD< D > &  g,
const VectorD< D > &  v 
)
related

Definition at line 600 of file VectorD.h.

template<int D>
void write_pts ( const Vector3Ds vs,
base::TextOutput  out 
)
related
See Also
read_pts

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