22 #ifndef GR_CPP_LINE_SEGMENT_H
23 #define GR_CPP_LINE_SEGMENT_H
205 throw KJB_error(
"Vertical segment, there is no y intercept");
219 throw KJB_error(
"Horizontal segment, there is no x intercept");
247 void read(std::istream& in);
250 void write(std::ostream& out)
const;
359 std::pair<Vector, Vector>& projected_points,
360 double& length_inside,
361 double& length_outside
402 double collinear_threshold
Line_segment & operator=(const Line_segment &ls)
Assignment operator.
Definition: gr_line_segment.cpp:115
void get_direction(kjb::Vector &idirection) const
Returns a vector representing the normalized direction of this line_segment.
Definition: gr_line_segment.cpp:677
void write(std::ostream &out) const
Writes this Line segment to an output stream.
Definition: gr_line_segment.cpp:346
kjb::Vector start_point
Definition: gr_line_segment.h:438
Abstract class to write this object to an output stream.
Definition: l_writeable.h:41
Int_matrix::Value_type max(const Int_matrix &mat)
Return the maximum value in this matrix.
Definition: l_int_matrix.h:1397
bool is_collinear(const Line_segment &ls, double collinear_threshold) const
Definition: gr_line_segment.cpp:1074
Abstract class to read this object from an input stream.
Definition: l_readable.h:39
double get_end_y() const
Returns the y-coordinate of the rightmost point of the segment.
Definition: gr_line_segment.h:174
bool operator==(const Line_segment &ls) const
Definition: gr_line_segment.cpp:133
void randomly_color(kjb::Image &img, double width=1.0) const
Randomly colors this line segment on an image.
Definition: gr_line_segment.cpp:438
bool get_intersection(const Line_segment &line, kjb::Vector &point) const
Finds the intersection point of the this line_segment and the input Line_segment line. Return false if these two lines are parallel and therefore do not intersect.
Definition: gr_line_segment.cpp:717
static bool collision_detection_with_direction(double start_1, double end_1, double start_2, double end_2, int &direction, double &delta, int idirection)
Definition: gr_line_segment.cpp:986
double get_angle_between_line(const Line_segment &line) const
Returns the angle between this line segment and the input line.
Definition: gr_line_segment.cpp:650
bool is_vertical() const
Function object of testing whehter a line is horizontal.
Definition: gr_line_segment.h:316
double orientation
Orientation of this line segment, defined as the angle between the x axis and the segment...
Definition: gr_line_segment.h:428
void init_vertical_segment(double y_start, double y_end, double x)
Initialize a vertical Line_segment from y_start, y_end, x coord.
Definition: gr_line_segment.cpp:235
static Matrix _line_segment_rotation
Definition: gr_line_segment.h:448
const kjb::Vector & get_centre() const
Returns the mid-point.
Definition: gr_line_segment.h:150
This class implements vectors, in the linear-algebra sense, with real-valued elements.
Definition: m_vector.h:87
void init_from_centre_and_orientation(double icentre_x, double icentre_y, double iorientation, double ilength)
Definition: gr_line_segment.cpp:158
Declarations for Line class.
double get_start_y() const
Returns the y-coordinate of the leftmost point of the segment.
Definition: gr_line_segment.h:159
double get_centre_x() const
Returns the x-coordinate of the mid-point.
Definition: gr_line_segment.h:132
const Line & get_line() const
Definition: gr_line_segment.h:229
double get_distance_from_point(const kjb::Vector &point) const
Returns distance between this line segment and the input point.
Definition: gr_line_segment.cpp:559
double get_orientation() const
Returns the orientation.
Definition: gr_line_segment.h:235
bool is_line_segment_consistent()
Definition: gr_line_segment.cpp:459
void draw(kjb::Image &img, double ir, double ig, double ib, double width=1.0) const
Draws this line segment.
Definition: gr_line_segment.cpp:423
REAL * point
Definition: triangle.c:537
void init_from_slope_and_intercept(double x_start, double x_end, double islope, double iintercept)
Initialize from x_start, x_end, slope, y_axis intercept.
Definition: gr_line_segment.cpp:183
double get_a() const
Returns the a parameter of the line as in ax + by + c = 0.
Definition: g_line.h:71
double get_slope() const
Returns the slope of the line segment.
Definition: gr_line_segment.h:187
double get_start_x() const
Returns the x-coordinate of the leftmost point of the segment.
Definition: gr_line_segment.h:153
static std::pair< Vector, Vector > project_line_segment_onto_line(const Line_segment &segment, const Line &iline)
Project a line segment onto a line.
Definition: gr_line_segment.cpp:731
const kjb::Vector & get_params() const
Returns the line parameters.
Definition: g_line.h:89
x
Definition: APPgetLargeConnectedEdges.m:100
void read(std::istream &in)
Reads this Line segment from an input stream.
Definition: gr_line_segment.cpp:298
double get_centre_y() const
Returns the y-coordinate of the mid-point.
Definition: gr_line_segment.h:138
static double get_overlap(double start_1, double end_1, double start_2, double end_2)
Definition: gr_line_segment.cpp:917
double get_dx() const
Returns the dx of this segment.
Definition: gr_line_segment.h:299
double find_t(const kjb::Vector &point) const
Definition: gr_line_segment.cpp:593
kjb::Vector centre
X coordinate of the centre of this line segment.
Definition: gr_line_segment.h:423
Parametric representation of a 2D line in terms of three parameters (a,b,c) (as in ax+by+c = 0)...
Definition: g_line.h:30
void init_from_end_points(double x_1, double y_1, double x_2, double y_2)
Initialize a new Line_segment from position of its end points.
Definition: gr_line_segment.cpp:271
std::ofstream & operator<<(std::ofstream &out, const Quaternion &q)
Definition: turntable_camera.cpp:77
const kjb::Vector & get_end() const
Returns the rightmost point of the segment.
Definition: gr_line_segment.h:180
Exception often thrown when wrapped C functions return error codes.
Definition: l_exception.h:262
const kjb::Vector & get_start() const
Returns the leftmost point of the segment.
Definition: gr_line_segment.h:165
static bool less_than(const Vector &point1, const Vector &point2)
Returns true if point1.x < point2.x || (point1.x == point2.x && point1.y < point2.y.
Definition: gr_line_segment.cpp:806
double get_length() const
Returns the length.
Definition: gr_line_segment.h:241
static bool project_line_segment_onto_line_segment(const Line_segment &segment_project, const Line_segment &segment_target, std::pair< Vector, Vector > &projected_points, double &length_inside, double &length_outside)
Project a line segment onto a line segment.
Definition: gr_line_segment.cpp:763
Line line
Definition: gr_line_segment.h:446
bool is_horizontal() const
Function object of testing whehter a line is horizontal.
Definition: gr_line_segment.h:310
double get_c() const
Returns the c parameter of the line as in ax + by + c = 0.
Definition: g_line.h:83
This class implements matrices, in the linear-algebra sense, with real-valued elements.
Definition: m_matrix.h:94
Line_segment()
Constructor without initializations.
Definition: gr_line_segment.h:67
kjb::Vector end_point
Definition: gr_line_segment.h:439
Wrapped version of the C struct KJB_image.
Definition: i_image.h:76
bool operator<(const Line_segment &ls) const
Definition: gr_line_segment.h:98
bool point_outside_segment(const Vector &point) const
Check whether point is inside the ending points of this segment Note point is collinear with this lin...
Definition: gr_line_segment.cpp:544
double get_end_x() const
Returns the x-coordinate of the rightmost point of the segment.
Definition: gr_line_segment.h:168
const Vector & get_line_params() const
Definition: gr_line_segment.h:224
static bool collision_detection(double start_1, double end_1, double start_2, double end_2, int &direction, double &delta)
Definition: gr_line_segment.cpp:817
double get_x_intercept() const
Returns the x-intercept of the line segment.
Definition: gr_line_segment.h:215
Definition for the Vector class, a thin wrapper on the KJB Vector struct and its related functionalit...
double length
length of the line segment
Definition: gr_line_segment.h:431
double get_dy() const
Returns the dy of this segment.
Definition: gr_line_segment.h:305
Class to manipulate a line segment The class is parametrized in terms the position of the centre...
Definition: gr_line_segment.h:62
void compute_line_parameters()
Definition: gr_line_segment.cpp:397
friend std::ostream & operator<<(std::ostream &, const Line_segment &)
Definition: gr_line_segment.cpp:691
double get_y_intercept() const
Returns the y-intercept of the line segment.
Definition: gr_line_segment.h:201
void compute_extrema()
Computes the extrema of this line segments from centre, orientation, and length. This information is ...
Definition: gr_line_segment.cpp:358