#include <vgl_vector_2d.h>
(typically float or double). A vgl_vector_2d<T> represents the difference (or connecting vector) between two vgl_point_2d<T>s.
Use this class to do arithmetic (adding and scaling) in 2d geometric space.
Definition at line 29 of file vgl_vector_2d.h.
Public Member Functions | |
| T | x () const |
| T | y () const |
| vgl_vector_2d () | |
| Creates the vector (0,0) of zero length. | |
| vgl_vector_2d (T vx, T vy) | |
| Creates the vector (x,y). | |
| void | set (T vx, T vy) |
| Assignment. | |
| bool | operator== (vgl_vector_2d< T >const &v) const |
| Comparison. | |
| bool | operator!= (vgl_vector_2d< T >const &v) const |
| double | length () const |
| Return the length of this vector. | |
| T | sqr_length () const |
| Return the squared length of this vector. | |
Public Attributes | |
| T | x_ |
| T | y_ |
Related Functions | |
| (Note that these are not member functions.) | |
| vcl_ostream & | operator<< (vcl_ostream &s, v const &p) |
| Write "<vgl_vector_2d x,y> " to stream. | |
| vcl_istream & | operator>> (vcl_istream &s, v &p) |
| Read x y from stream. | |
| double | length (v const &a) |
| Return the length of a vector. | |
| T | sqr_length (v const &a) |
| Return the squared length of a vector. | |
| v | operator+ (v const &a, v const &b) |
| c=a+b: add two vectors. | |
| v | operator- (v const &a, v const &b) |
| c=a-b: subtract two vectors. | |
| v & | operator+= (v &a, v const &b) |
| a+=b: add b to a and return a. | |
| v & | operator-= (v &a, v const &b) |
| a-=b: subtract b from a and return a. | |
| v | operator+ (v const &b) |
| +b: unary plus operator (no-op). | |
| v | operator- (v const &b) |
| -a: unary minus operator (additive inverse). | |
| v | operator * (double s, v const &b) |
| c=f*b: return a scaled version of the vector. | |
| v | operator * (v const &a, double s) |
| c=a*f: return a scaled version of the vector. | |
| v | operator/ (v const &a, double s) |
| c=b/f: return an inversely scaled version of the vector (scale must be nonzero). | |
| v & | operator *= (v &a, double s) |
| a*=f: scale the vector. | |
| v & | operator/= (v &a, double s) |
| a/=f: inversely scale the vector (scale must be nonzero). | |
| T | dot_product (v const &a, v const &b) |
| dot product or inner product of two vectors. | |
| T | inner_product (v const &a, v const &b) |
| dot product or inner product of two vectors. | |
| T | cross_product (v const &a, v const &b) |
| cross product of two vectors (area of enclosed parallellogram). | |
| double | cos_angle (v const &a, v const &b) |
| cosine of the angle between two vectors. | |
| double | angle (v const &a, v const &b) |
| smallest angle between two vectors (in radians, between 0 and Pi). | |
| double | signed_angle (v const &a, v const &b) |
| signed angle between two vectors (in radians, between -Pi and Pi). | |
| bool | orthogonal (v const &a, v const &b, double eps=0.0) |
| are two vectors orthogonal, i.e. | |
| bool | parallel (v const &a, v const &b, double eps=0.0) |
| are two vectors parallel, i.e. | |
| double | operator/ (v const &a, v const &b) |
| f=a/b: return the ratio of two vectors, if they are parallel. | |
| v & | normalize (v &a) |
| Normalise by dividing through by the length, thus returning a length 1 vector. | |
| v | normalized (v const &a) |
| Return a normalised version of a. | |
| v | rotated (v const &a, double angle) |
| Return a CCW rotated version of a (angle in radian). | |
|
|||||||||
|
Creates the vector (0,0) of zero length.
Definition at line 38 of file vgl_vector_2d.h. |
|
||||||||||||||||
|
Creates the vector (x,y).
Definition at line 41 of file vgl_vector_2d.h. |
|
|||||||||
|
Return the length of this vector.
Definition at line 13 of file vgl_vector_2d.txx. |
|
||||||||||
|
Definition at line 58 of file vgl_vector_2d.h. |
|
||||||||||
|
Comparison.
Definition at line 57 of file vgl_vector_2d.h. |
|
||||||||||||||||
|
Assignment.
Definition at line 54 of file vgl_vector_2d.h. |
|
|||||||||
|
Return the squared length of this vector.
Definition at line 64 of file vgl_vector_2d.h. |
|
|||||||||
|
Definition at line 34 of file vgl_vector_2d.h. |
|
|||||||||
|
Definition at line 35 of file vgl_vector_2d.h. |
|
||||||||||||||||
|
smallest angle between two vectors (in radians, between 0 and Pi).
|
|
||||||||||||||||
|
cosine of the angle between two vectors.
Definition at line 150 of file vgl_vector_2d.h. |
|
||||||||||||||||
|
cross product of two vectors (area of enclosed parallellogram).
Definition at line 146 of file vgl_vector_2d.h. |
|
||||||||||||||||
|
dot product or inner product of two vectors.
Definition at line 138 of file vgl_vector_2d.h. |
|
||||||||||||||||
|
dot product or inner product of two vectors.
Definition at line 142 of file vgl_vector_2d.h. |
|
||||||||||
|
Return the length of a vector.
Definition at line 84 of file vgl_vector_2d.h. |
|
||||||||||
|
Normalise by dividing through by the length, thus returning a length 1 vector. If a is zero length, return (0,0). Definition at line 184 of file vgl_vector_2d.h. |
|
||||||||||
|
Return a normalised version of a. If a is zero length, return (0,0). Definition at line 189 of file vgl_vector_2d.h. |
|
||||||||||||||||
|
c=a*f: return a scaled version of the vector.
Definition at line 120 of file vgl_vector_2d.h. |
|
||||||||||||||||
|
c=f*b: return a scaled version of the vector.
Definition at line 116 of file vgl_vector_2d.h. |
|
||||||||||||||||
|
a*=f: scale the vector.
Definition at line 130 of file vgl_vector_2d.h. |
|
||||||||||
|
+b: unary plus operator (no-op).
Definition at line 108 of file vgl_vector_2d.h. |
|
||||||||||||||||
|
c=a+b: add two vectors.
Definition at line 92 of file vgl_vector_2d.h. |
|
||||||||||||||||
|
a+=b: add b to a and return a.
Definition at line 100 of file vgl_vector_2d.h. |
|
||||||||||
|
-a: unary minus operator (additive inverse).
Definition at line 112 of file vgl_vector_2d.h. |
|
||||||||||||||||
|
c=a-b: subtract two vectors.
Definition at line 96 of file vgl_vector_2d.h. |
|
||||||||||||||||
|
a-=b: subtract b from a and return a.
Definition at line 104 of file vgl_vector_2d.h. |
|
||||||||||||||||
|
f=a/b: return the ratio of two vectors, if they are parallel. (If not, return a "least squares" approximation.) Note that the return type is double, not Type, since the ratio of e.g. two vgl_vector_2d<int> need not be an int. Definition at line 178 of file vgl_vector_2d.h. |
|
||||||||||||||||
|
c=b/f: return an inversely scaled version of the vector (scale must be nonzero). Note that the argument type is double, not T, to avoid rounding errors when type T has no multiplicative inverses (like T=int). Definition at line 126 of file vgl_vector_2d.h. |
|
||||||||||||||||
|
a/=f: inversely scale the vector (scale must be nonzero).
Definition at line 134 of file vgl_vector_2d.h. |
|
||||||||||||||||
|
Write "<vgl_vector_2d x,y> " to stream.
|
|
||||||||||||||||
|
Read x y from stream.
|
|
||||||||||||||||||||
|
are two vectors orthogonal, i.e. , is their dot product zero?. If the third argument is specified, it is taken as the "tolerance", i.e. in that case this function returns true if the vectors are almost orthogonal. |
|
||||||||||||||||||||
|
are two vectors parallel, i.e. , is one a scalar multiple of the other?. If the third argument is specified, it is taken as the "tolerance", i.e. in that case this function returns true if the vectors are almost parallel. |
|
||||||||||||||||
|
Return a CCW rotated version of a (angle in radian).
|
|
||||||||||||||||
|
signed angle between two vectors (in radians, between -Pi and Pi). return the rotation angle to go from `a' to `b' |
|
||||||||||
|
Return the squared length of a vector.
Definition at line 88 of file vgl_vector_2d.h. |
|
|||||
|
Definition at line 32 of file vgl_vector_2d.h. |
|
|||||
|
Definition at line 33 of file vgl_vector_2d.h. |
1.4.4