2 #ifndef vgl_vector_2d_hxx_ 3 #define vgl_vector_2d_hxx_ 13 # include <vcl_msvc_warnings.h> 40 if (eps <= 0 ||
dot == T(0))
return dot == T(0);
50 if (eps <= 0 || cross == T(0))
return cross == T(0);
52 return cross*cross < eps;
68 return s <<
"<vgl_vector_2d "<< p.
x() <<
',' << p.
y() <<
"> ";
79 if (! is.good())
return is;
83 if (is.eof())
return is;
85 if (c ==
'(') { is.ignore(); paren=
true; }
87 is >> std::ws >> tx >> std::ws;
88 if (is.eof())
return is;
89 if (is.peek() ==
',') is.ignore();
90 is >> std::ws >> ty >> std::ws;
91 if (is.eof())
return is;
92 if (is.peek() ==
')') is.ignore();
96 is >> temp >> std::ws;
100 std::cout <<
"Invalid syntax: >> vgl_vector_2d" << std::endl;
105 if(is.peek() !=
'>'){
106 std::cout <<
"Invalid syntax: >> vgl_vector_2d" << std::endl;
113 if(c ==
',') is.ignore();
128 #undef VGL_VECTOR_2D_INSTANTIATE 129 #define VGL_VECTOR_2D_INSTANTIATE(T) \ 130 template class vgl_vector_2d<T >;\ 146 template double angle (vgl_vector_2d<T > const&, vgl_vector_2d<T > const&);\ 147 template double signed_angle (vgl_vector_2d<T > const&, vgl_vector_2d<T > const&);\ 148 template bool orthogonal (vgl_vector_2d<T > const&, vgl_vector_2d<T > const&, double);\ 149 template bool parallel (vgl_vector_2d<T > const&, vgl_vector_2d<T > const&, double);\ 153 template vgl_vector_2d<T > rotated (vgl_vector_2d<T > const&, double);\ 154 template std::ostream& operator<< (std::ostream&, vgl_vector_2d<T >const&);\ 155 template std::istream& operator>> (std::istream&, vgl_vector_2d<T >&) 157 #endif // vgl_vector_2d_hxx_ std::istream & read(std::istream &is)
Read from stream, possibly with formatting.
T dot_product(v const &a, v const &b)
dot product or inner product of two vectors.
Direction vector in Euclidean 2D space, templated by type of element.
T sqr_length() const
Return the squared length of this vector.
bool orthogonal(v const &a, v const &b, double eps=0.0)
are two vectors orthogonal, i.e., is their dot product zero?.
double length() const
Return the length of this vector.
std::ostream & operator<<(std::ostream &s, vgl_orient_box_3d< Type > const &p)
Write box to stream.
v rotated(v const &a, double angle)
Return a CCW rotated version of a (angle in radian).
T cross_product(v const &a, v const &b)
cross product of two vectors (area of enclosed parallellogram).
double signed_angle(v const &a, v const &b)
signed angle between two vectors (in radians, between -Pi and Pi).
direction vector in Euclidean 2D space
std::istream & operator>>(std::istream &is, vgl_orient_box_3d< Type > &p)
Read box from stream.
T sqr_length(v const &a)
Return the squared length of a vector.
double angle(v const &a, v const &b)
smallest angle between two vectors (in radians, between 0 and Pi).
bool parallel(v const &a, v const &b, double eps=0.0)
are two vectors parallel, i.e., is one a scalar multiple of the other?.
double cos_angle(v const &a, v const &b)
cosine of the angle between two vectors.