2 #ifndef vgl_vector_3d_hxx_ 3 #define vgl_vector_3d_hxx_ 13 #include <vcl_compiler_detection.h> 15 # include <vcl_msvc_warnings.h> 18 #include <vcl_deprecated.h> 31 VXL_DEPRECATED_MACRO(
"vgl_vector_3d<T>::orthogonal_vectors(double s)");
48 return std::acos(-1.0);
55 if (eps <= 0 ||
dot == T(0))
return dot == T(0);
65 if (eps <= 0 || cross == 0.0)
return cross == 0.0;
79 double nx = static_cast<double>(a.
x_);
80 double ny = static_cast<double>(a.
y_);
81 double nz = static_cast<double>(a.
z_);
82 double two_pi = 2*std::acos(-1.0);
83 double co = std::cos(two_pi*s);
84 double si = std::sin(two_pi*s);
86 double mnz = std::fabs(nz);
91 double q = co*rx +si*ry;
92 double a = 1.0/std::sqrt(1+q*q);
93 T vx = static_cast<T>(a*co);
94 T vy = static_cast<T>(a*si);
95 T vz = -static_cast<T>(rx*vx + ry*vy);
100 double mny = std::fabs(ny);
104 double a = 1/std::sqrt(1+co*co*r*r);
105 T vx = static_cast<T>(a*co);
106 T vz = static_cast<T>(a*si);
107 T vy = -static_cast<T>(a*co*r);
114 double a = 1/std::sqrt(1+co*co*r*r);
115 T vy = static_cast<T>(a*co);
116 T vz = static_cast<T>(a*si);
117 T vx = -static_cast<T>(a*co*r);
127 return s <<
"<vgl_vector_3d "<< p.
x() <<
',' << p.
y() <<
',' << p.
z() <<
"> ";
138 if (! is.good())
return is;
142 if (is.eof())
return is;
144 if (c ==
'(') { is.ignore(); paren=
true; }
146 is >> std::ws >> tx >> std::ws;
147 if (is.eof())
return is;
148 if (is.peek() ==
',') is.ignore();
149 is >> std::ws >> ty >> std::ws;
150 if (is.eof())
return is;
151 if (is.peek() ==
',') is.ignore();
152 is >> std::ws >> tz >> std::ws;
153 if (is.eof())
return is;
154 if (is.peek() ==
')') is.ignore();
158 is >> temp >> std::ws;
162 std::cout <<
"Invalid syntax: >> vgl_vector_3d" << std::endl;
169 std::cout <<
"Invalid syntax: >> vgl_vector_3d" << std::endl;
174 if(is.peek() !=
'>'){
175 std::cout <<
"Invalid syntax: >> vgl_vector_3d" << std::endl;
182 if(c ==
',') is.ignore();
183 is >> std::ws >> ty >> std::ws;
185 if(c ==
',') is.ignore();
186 is >> std::ws >> tz >> std::ws;
203 #undef VGL_VECTOR_3D_INSTANTIATE 204 #define VGL_VECTOR_3D_INSTANTIATE(T) \ 205 template class vgl_vector_3d<T >;\ 221 template double angle (vgl_vector_3d<T > const&, vgl_vector_3d<T > const&);\ 222 template bool orthogonal (vgl_vector_3d<T > const&, vgl_vector_3d<T > const&, double);\ 223 template bool parallel (vgl_vector_3d<T > const&, vgl_vector_3d<T > const&, double);\ 224 template vgl_vector_3d<T > orthogonal_vectors(vgl_vector_3d<T > const&, double);\ 228 template std::ostream& operator<< (std::ostream&, vgl_vector_3d<T >const&);\ 229 template std::istream& operator>> (std::istream&, vgl_vector_3d<T >&) 231 #endif // vgl_vector_3d_hxx_ T dot_product(v const &a, v const &b)
dot product or inner product of two vectors.
vgl_vector_3d< T > orthogonal_vectors(vgl_vector_3d< T > const &a, double s)
direction vector in Euclidean 3D space
bool orthogonal(v const &a, v const &b, double eps=0.0)
are two vectors orthogonal, i.e., is their dot product zero?.
std::ostream & operator<<(std::ostream &s, vgl_orient_box_3d< Type > const &p)
Write box to stream.
vgl_vector_3d< T > orthogonal_vectors(double s) const
One-parameter family of unit vectors that are orthogonal to *this, v(s).
double length() const
Return the length of this vector.
T cross_product(v const &a, v const &b)
cross product of two vectors (area of enclosed parallellogram).
T sqr_length() const
Return the squared length of this vector.
Direction vector in Euclidean 3D space, templated by type of element.
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).
std::istream & read(std::istream &is)
Read from stream, possibly with formatting.
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.