35 Line() : line_params(3, 1.0) {}
42 Line(
double a,
double b,
double c) : line_params(3, 1.0)
53 if(iparams.
size() != 3)
57 line_params = iparams;
61 Line(
const Line & l) : line_params(l.line_params) { }
66 line_params = l.line_params;
73 return line_params(0);
79 return line_params(1);
85 return line_params(2);
97 if( fabs(line_params(1)) < FLT_EPSILON )
99 throw kjb::KJB_error(
"Cannot compute y coordinate for a vertical line");
101 return (-line_params(0)*ix - line_params(2))/line_params(1);
125 if(iparams.
size() != 3)
129 line_params = iparams;
176 template <
class VectorType>
179 const VectorType& line_point,
180 const VectorType& line_direction,
181 const VectorType& plane_point,
182 const VectorType& plane_normal
185 double numerator =
kjb::dot((plane_point - line_point), plane_normal);
186 double denominator =
kjb::dot(line_direction, plane_normal);
188 if(fabs(denominator) < FLT_EPSILON)
190 if(fabs(numerator) > FLT_EPSILON)
191 return std::numeric_limits<double>::infinity();
193 return std::numeric_limits<double>::quiet_NaN();
195 return numerator/denominator;
239 template <std::
size_t D>
266 "Cannot project point onto line: dimensions are wrong.");
271 double s =
dot(AP, AB) /
dot(AB, AB);
double compute_y_coordinate(double ix)
computes the y coordinate for the input x coordinate
Definition: g_line.h:95
double intersect_line_with_plane_dispatch_(const VectorType &line_point, const VectorType &line_direction, const VectorType &plane_point, const VectorType &plane_normal)
Definition: g_line.h:178
size_type size() const
Alias to get_length(). Required to comply with stl Container concept.
Definition: m_vector.h:510
Line & operator=(const Line &l)
Assignment operator.
Definition: g_line.h:64
Line(double a, double b, double c)
Constructs a new Line_segment from line parameters a, b, c as in ax + by + c = 0. ...
Definition: g_line.h:42
Line(const Line &l)
Copy constructor.
Definition: g_line.h:61
bool intersect_3D_line_with_plane(kjb::Vector &intersection, double &t, const kjb::Vector &point, const kjb::Vector &direction, const kjb::Vector &plane)
Definition: g_line.cpp:181
This class implements vectors, in the linear-algebra sense, with real-valued elements.
Definition: m_vector.h:87
void set_b(double ib)
Sets the b parameter of the line as in ax + by + c = 0.
Definition: g_line.h:111
#define IFT(a, ex, msg)
Definition: l_exception.h:101
Line()
Constructor without initializations.
Definition: g_line.h:35
REAL * point
Definition: triangle.c:537
double get_a() const
Returns the a parameter of the line as in ax + by + c = 0.
Definition: g_line.h:71
bool point_is_on_line(const Vector &point) const
Definition: g_line.h:132
const kjb::Vector & get_params() const
Returns the line parameters.
Definition: g_line.h:89
void set_a(double ia)
Sets the a parameter of the line as in ax + by + c = 0.
Definition: g_line.h:105
Vector project_point_onto_line(const Vector &A, const Vector &B, const Vector &P)
Project a point onto a line, in any dimension.
Definition: g_line.h:263
Vector project_point_onto_line(const Vector &point) const
Project a point onto a line.
Definition: g_line.cpp:153
double find_distance_to_point(const kjb::Vector &point) const
Finds the perpendicular distance between a line and a point.
Definition: g_line.cpp:137
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
double get_b() const
Returns the b parameter of the line as in ax + by + c = 0.
Definition: g_line.h:77
Exception often thrown when wrapped C functions return error codes.
Definition: l_exception.h:262
Line(const kjb::Vector &iparams)
Constructs a new Line_segment from line parameters vector [a, b, c] as in ax + by + c = 0...
Definition: g_line.h:51
Object thrown when an argument to a function is not acceptable.
Definition: l_exception.h:377
double intersect_line_with_plane(const kjb::Vector &line_point, const kjb::Vector &line_direction, const kjb::Vector &plane_point, const kjb::Vector &plane_normal)
Definition: g_line.h:222
double get_c() const
Returns the c parameter of the line as in ax + by + c = 0.
Definition: g_line.h:83
void set_c(double ic)
Sets the c parameter of the line as in ax + by + c = 0.
Definition: g_line.h:117
Definition: g_quaternion.h:37
long int dot(const Int_vector &op1, const Int_vector &op2)
Returns dot product of this and op2.
Definition: l_int_vector.h:1532
Support for error handling exception classes in libKJB.
Definition for the Vector class, a thin wrapper on the KJB Vector struct and its related functionalit...
void set_line_params(const kjb::Vector &iparams)
Sets the line parameters [a,b,c] of the line as in ax + by + c = 0.
Definition: g_line.h:123
static bool find_line_intersection(const Line &l1, const Line &l2, kjb::Vector &ints)
Find the intersection between two lines, Returns false if the lines are parallel. ...
Definition: g_line.cpp:99