32#ifndef RCSC_GEOM_LINE2D_H
33#define RCSC_GEOM_LINE2D_H
108 M_a = -( p2.
y - p1.
y );
110 M_c = -M_a * p1.
x - M_b * p1.
y;
123 M_a = - linedir.
sin();
125 M_c = -M_a * origin.
x - M_b * origin.
y;
161 double getX(
const double y )
const
163 if ( std::fabs( M_a ) <
EPSILON )
167 return -( M_b * y + M_c ) / M_a;
175 double getY(
const double x )
const
177 if ( std::fabs( M_b ) <
EPSILON )
182 return -( M_a * x + M_c ) / M_b;
192 return std::fabs( ( M_a * p.
x + M_b * p.
y + M_c )
193 / std::sqrt( M_a * M_a + M_b * M_b ) );
202 double d = M_a * p.
x + M_b * p.
y + M_c;
203 return (d * d) / (M_a * M_a + M_b * M_b);
214 return std::fabs(
a() * line.
b() - line.
a() *
b() ) <
EPSILON;
degree wrapper class
Definition: angle_deg.h:45
double cos() const
calculate cosine
Definition: angle_deg.h:292
static AngleDeg bisect(const AngleDeg &left, const AngleDeg &right)
static utility that returns bisect angle of [left, right].
double sin() const
calculate sine
Definition: angle_deg.h:301
2d straight line class
Definition: line_2d.h:47
static const double ERROR_VALUE
error value
Definition: line_2d.h:51
double a() const
accessor
Definition: line_2d.h:133
static Vector2D intersection(const Line2D &line1, const Line2D &line2)
get the intersection point of 2 lines
Line2D(const Vector2D &origin, const AngleDeg &linedir)
construct from origin point + direction
Definition: line_2d.h:93
double getY(const double x) const
get Y-coordinate correspond to 'x'
Definition: line_2d.h:175
static const double EPSILON
tolerance threshold
Definition: line_2d.h:50
double b() const
accessor
Definition: line_2d.h:142
const Line2D & assign(const Vector2D &p1, const Vector2D &p2)
construct from 2 points
Definition: line_2d.h:105
const Line2D & assign(const Vector2D &origin, const AngleDeg &linedir)
construct from origin point + direction
Definition: line_2d.h:120
double dist2(const Vector2D &p) const
get squared distance from this line to point
Definition: line_2d.h:200
static Line2D angle_bisector(const Vector2D &origin, const AngleDeg &left, const AngleDeg &right)
make angle bisector line from two angles
Definition: line_2d.h:269
double c() const
accessor
Definition: line_2d.h:151
double dist(const Vector2D &p) const
calculate distance from point to this line
Definition: line_2d.h:190
double getX(const double y) const
get X-coordinate correspond to 'y'
Definition: line_2d.h:161
bool isParallel(const Line2D &line) const
check if the slope of this line is same to the slope of 'line'
Definition: line_2d.h:212
Vector2D projection(const Vector2D &p) const
calc projection point from p
Definition: line_2d.h:243
Line2D(const Vector2D &p1, const Vector2D &p2)
construct from 2 points
Definition: line_2d.h:82
static Line2D perpendicular_bisector(const Vector2D &p1, const Vector2D &p2)
make perpendicular bisector line from twt points
Line2D perpendicular(const Vector2D &p) const
calc perpendicular line (SUI-SEN)
Definition: line_2d.h:233
Vector2D intersection(const Line2D &line) const
get the intersection point with 'line'
Definition: line_2d.h:223
Line2D(const double a, const double b, const double c)
construct directly
Definition: line_2d.h:69
2D point vector class
Definition: vector_2d.h:46
double y
Y coordinate.
Definition: vector_2d.h:64
double x
X coordinate.
Definition: vector_2d.h:63
2d vector class Header File.