A Cartesian vector in D-dimensions.
Store a vector of Cartesian coordinates. It supports all expected mathematical operators, including using * for the dot product.
Examples: nup84 cg, custom filter, kmeans, six particles optimization, XYZR Decorator, range restriction, symmetry, rigid body excluded volume, nup84 rb, grid space, rigid body and excluded volume restraint, domino approach, six particles loopy optimization, XYZ Decorator, filter close pairs, connectivity restraint, rigid collisions, randomize rigid body, simplex, analyze convergence, setup, initialize chains, restrain in sphere
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, 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 x) | |
| Initialize the 1-vector from its value. | |
| VectorD (double x0, double x1, double x2, double x3) | |
| Initialize a 4-vector from separate w,x,y,z values. | |
| VectorD () | |
| Default constructor. | |
| CoordinateConstIterator | coordinates_begin () const |
| CoordinateIterator | coordinates_begin () |
| CoordinateConstIterator | coordinates_end () const |
| CoordinateIterator | coordinates_end () |
| 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 | |
| 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 | |
| SphereD< 3 > | get_enclosing_sphere (const std::vector< VectorD< 3 > > &ss) |
| Return a sphere containing the listed spheres. | |
| 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) |
3D Vectors | |
We provide a specialization of VectorD for 3-space and several additional functions on it. | |
| VectorD< 3 > | get_vector_product (const VectorD< 3 > &p1, const VectorD< 3 > &p2) |
| Returns the vector product (cross product) of two vectors. | |
| VectorD< 3 > | get_orthogonal_vector (const VectorD< 3 > &v) |
| Return a vector that is perpendicular to the given vector. | |
| VectorD< 3 > | get_centroid (const std::vector< VectorD< 3 > > &ps) |
| Returns the centroid of a set of vectors. | |
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 std::vector< VectorD< 3 > > &vs, TextOutput out) |
| Write a set of 3D vectors to a file. | |
| std::vector< VectorD< 3 > > | read_pts (TextInput in) |
| Read a set of 3D vectors from a file. | |
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) |
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. | |
| 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. | |
| IMP::algebra::VectorD< D >::VectorD | ( | const Floats & | f | ) |
| ValueException | if f.size() is not appropriate. |
The distance between b and e must be equal to 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.
| double& IMP::algebra::VectorD< D >::operator[] | ( | unsigned int | i | ) |
Return the ith Cartesian coordinate. In 3D use [0] to get the x coordinate etc.
lexicographic comparison of two vectors
Note that this is not very reliable and probably should not be used.
| 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);
Returns the centroid of a set of vectors.
<3>
| SphereD< 3 > get_enclosing_sphere | ( | const std::vector< VectorD< 3 > > & | ss | ) | [related] |
Return a sphere containing the listed spheres.
<3> <3>
Return a vector that is perpendicular to the given vector.
Or, if you are Israeli, it is a vertical vector. <3>
| Segment3D get_shortest_segment | ( | const Segment3D & | s, |
| const VectorD< 3 > & | p | ||
| ) | [related] |
<3>
| 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.
| VectorD< 3 > get_vector_product | ( | const VectorD< 3 > & | p1, |
| const VectorD< 3 > & | p2 | ||
| ) | [related] |
Returns the vector product (cross product) of two vectors.
<3>
Read a set of 3D vectors from a file.
| void write_pts | ( | const std::vector< VectorD< 3 > > & | vs, |
| TextOutput | out | ||
| ) | [related] |
Write a set of 3D vectors to a file.