2 #ifndef vgl_line_segment_2d_hxx_ 3 #define vgl_line_segment_2d_hxx_ 10 # include <vcl_msvc_warnings.h> 16 return s <<
"<vgl_line_segment_2d " << p.
point1() <<
" to " << p.
point2() <<
" >";
23 s >> std::skipws >> std::ws;
32 s >> std::ws >> p2 >> temp;
40 return point1_.y()-point2_.y();
46 return point2_.x()-point1_.x();
52 return point1_.x()*point2_.y()-point2_.x()*point1_.y();
72 static const double deg_per_rad = 45.0/std::atan2(1.0,1.0);
73 double dy = point2_.y()-point1_.y();
74 double dx = point2_.x()-point1_.x();
76 if (dx == 0)
return dy<0 ? -90.0 : 90.0;
77 if (dy == 0)
return dx<0 ? 180.0 : 0.0;
78 if (dy == dx)
return dy<0 ? -135.0 : 45.0;
79 if (dy+dx == 0)
return dy<0 ? -45.0 : 135.0;
81 return deg_per_rad * std::atan2(dy,dx);
87 double dy = point2_.y()-point1_.y();
88 double dx = point2_.x()-point1_.x();
89 return std::atan2(dy,dx);
92 #undef VGL_LINE_SEGMENT_2D_INSTANTIATE 93 #define VGL_LINE_SEGMENT_2D_INSTANTIATE(Type) \ 94 template class vgl_line_segment_2d<Type >;\ 95 template std::istream& operator>>(std::istream&, vgl_line_segment_2d<Type >&);\ 96 template std::ostream& operator<<(std::ostream&, vgl_line_segment_2d<Type > const&) 98 #endif // vgl_line_segment_2d_hxx_ Represents a 2D line segment using two points.
v normalized(v const &a)
Return a normalised version of a.
Type b() const
Parameter b of line a*x + b*y + c = 0.
vgl_vector_2d< Type > normal() const
unit vector orthogonal to line.
Type a() const
Parameter a of line a*x + b*y + c = 0.
double slope_degrees() const
angle with the oriented horizontal line y=0, measured in 360-degrees.
Type c() const
Parameter c of line a*x + b*y + c = 0.
vgl_point_2d< Type > point2() const
The other end-point of the line segment.
std::ostream & operator<<(std::ostream &s, vgl_orient_box_3d< Type > const &p)
Write box to stream.
vgl_vector_2d< Type > direction() const
unit vector describing line direction.
std::istream & operator>>(std::istream &is, vgl_orient_box_3d< Type > &p)
Read box from stream.
double slope_radians() const
angle with the oriented horizontal line y=0, measured in radians.
Represents a cartesian 2D point.
void set(vgl_point_2d< Type > const &p1, vgl_point_2d< Type > const &p2)
Assignment.
vgl_point_2d< Type > point1() const
One end-point of the line segment.