29
Line(NR::Point const &start, NR::Point const &vec, bool is_endpoint = true);
27
Line(Geom::Point const &start, Geom::Point const &vec, bool is_endpoint = true);
30
28
Line(Line const &line);
32
30
Line &operator=(Line const &line);
33
virtual NR::Maybe<NR::Point> intersect(Line const &line);
34
inline NR::Point direction () { return v_dir; }
31
virtual boost::optional<Geom::Point> intersect(Line const &line);
32
inline Geom::Point direction () { return v_dir; }
36
NR::Point closest_to(NR::Point const &pt); // returns the point on the line closest to pt
34
Geom::Point closest_to(Geom::Point const &pt); // returns the point on the line closest to pt
38
36
friend inline std::ostream &operator<< (std::ostream &out_file, const Line &in_line);
39
NR::Maybe<NR::Point> intersection_with_viewbox (SPDesktop *desktop);
40
inline bool lie_on_same_side (NR::Point const &A, NR::Point const &B) {
37
boost::optional<Geom::Point> intersection_with_viewbox (SPDesktop *desktop);
38
inline bool lie_on_same_side (Geom::Point const &A, Geom::Point const &B) {
41
39
/* If A is a point in the plane and n is the normal vector of the line then
42
40
the sign of dot(A, n) specifies the half-plane in which A lies.
43
41
Thus A and B lie on the same side if the dot products have equal sign. */
44
return ((NR::dot(A, normal) - d0) * (NR::dot(B, normal) - d0)) > 0;
42
return ((Geom::dot(A, normal) - d0) * (Geom::dot(B, normal) - d0)) > 0;
47
double lambda (NR::Point const pt);
48
inline NR::Point point_from_lambda (double const lambda) {
49
return (pt + lambda * NR::unit_vector (v_dir)); }
45
double lambda (Geom::Point const pt);
46
inline Geom::Point point_from_lambda (double const lambda) {
47
return (pt + lambda * Geom::unit_vector (v_dir)); }
52
void set_direction(NR::Point const &dir);
53
inline static bool pts_coincide (NR::Point const pt1, NR::Point const pt2)
50
void set_direction(Geom::Point const &dir);
51
inline static bool pts_coincide (Geom::Point const pt1, Geom::Point const pt2)
55
return (NR::L2 (pt2 - pt1) < epsilon);
53
return (Geom::L2 (pt2 - pt1) < epsilon);
64
inline double determinant (NR::Point const &a, NR::Point const &b)
62
inline double determinant (Geom::Point const &a, Geom::Point const &b)
66
return (a[NR::X] * b[NR::Y] - a[NR::Y] * b[NR::X]);
64
return (a[Geom::X] * b[Geom::Y] - a[Geom::Y] * b[Geom::X]);
68
std::pair<double, double> coordinates (NR::Point const &v1, NR::Point const &v2, NR::Point const &w);
69
bool lies_in_sector (NR::Point const &v1, NR::Point const &v2, NR::Point const &w);
70
bool lies_in_quadrangle (NR::Point const &A, NR::Point const &B, NR::Point const &C, NR::Point const &D, NR::Point const &pt);
71
std::pair<NR::Point, NR::Point> side_of_intersection (NR::Point const &A, NR::Point const &B,
72
NR::Point const &C, NR::Point const &D,
73
NR::Point const &pt, NR::Point const &dir);
66
std::pair<double, double> coordinates (Geom::Point const &v1, Geom::Point const &v2, Geom::Point const &w);
67
bool lies_in_sector (Geom::Point const &v1, Geom::Point const &v2, Geom::Point const &w);
68
bool lies_in_quadrangle (Geom::Point const &A, Geom::Point const &B, Geom::Point const &C, Geom::Point const &D, Geom::Point const &pt);
69
std::pair<Geom::Point, Geom::Point> side_of_intersection (Geom::Point const &A, Geom::Point const &B,
70
Geom::Point const &C, Geom::Point const &D,
71
Geom::Point const &pt, Geom::Point const &dir);
75
73
/*** For debugging purposes: Draw a knot/node of specified size and color at the given position ***/
76
void create_canvas_point(NR::Point const &pos, double size = 4.0, guint32 rgba = 0xff00007f);
74
void create_canvas_point(Geom::Point const &pos, double size = 4.0, guint32 rgba = 0xff00007f);
78
76
/*** For debugging purposes: Draw a line between the specified points ***/
79
void create_canvas_line(NR::Point const &p1, NR::Point const &p2, guint32 rgba = 0xff00007f);
77
void create_canvas_line(Geom::Point const &p1, Geom::Point const &p2, guint32 rgba = 0xff00007f);
82
80
/** A function to print out the Line. It just prints out the coordinates of start point and