27#ifndef EASY3D_CORE_LINE_H
28#define EASY3D_CORE_LINE_H
30#include <easy3d/core/vec.h>
31#include <easy3d/core/constant.h>
32#include <easy3d/util/logging.h>
44 template <
int DIM,
typename FT>
127 template <
int DIM,
typename FT>
130 LOG_IF(
length(dir_) < 1e-15, ERROR)
131 <<
"degenerate line constructed from point (" << p <<
") and direction (" << dir <<
")";
135 template <
int DIM,
typename FT>
139 FT b =
dot(dir_, dir_);
143 FT d =
dot(other.
point() - p_, dir_);
152 t1 = (a * e - c * d) / (a * a - b * c);
153 t2 = b / a * t1 - d / a;
169 template <
int DIM,
typename FT>
182 template <
int DIM,
typename FT>
A generic line representation, which supports both 2D and 3D lines.
Definition line.h:45
GenericLine()=default
Default constructor.
FT squared_distance(const Point &p) const
Returns the squared distance of a point p to this line.
Definition line.h:106
static GenericLine from_two_points(const Point &p, const Point &q)
Constructs a line from two points p and q.
Definition line.h:65
void set(const Point &p, const Vector &dir)
Sets a line from a point p and its direction dir.
Definition line.h:77
Point projection(const Point &p) const
Returns the projection of a point p on this line.
Definition line.h:99
const Vector & direction() const
Returns the direction of the line.
Definition line.h:86
GenericLine< DIM, FT > thisclass
The type of this class.
Definition line.h:49
const Point & point() const
Returns an arbitrary point on the line.
Definition line.h:92
Vec< DIM, FT > Vector
The type of the vector.
Definition line.h:48
static GenericLine from_point_and_direction(const Point &p, const Vector &dir)
Constructs a line from a point p and its direction dir.
Definition line.h:58
Vec< DIM, FT > Point
The type of the point.
Definition line.h:47
bool feet(const thisclass &other, Point &p1, Point &p2) const
Computes the perpendicular feet with another line.
Definition line.h:136
Base class for vector types. It provides generic functionality for N dimensional vectors.
Definition vec.h:30
Definition collider.cpp:182
Vec< N, T > normalize(const Vec< N, T > &v)
Computes and returns the normalized vector (Note: the input vector is not modified).
Definition vec.h:299
T length(const Vec< N, T > &v)
Computes the length/magnitude of a vector.
Definition vec.h:289
FT epsilon()
Function returning the epsilon value for a given type.
std::ostream & operator<<(std::ostream &os, Graph::Vertex v)
Output stream support for Graph::Vertex.
Definition graph.h:1300
T length2(const Vec< N, T > &v)
Computes the squared length/magnitude of a vector.
Definition vec.h:293
std::istream & operator>>(std::istream &is, GenericLine< DIM, FT > &line)
Input stream support for GenericLine.
Definition line.h:183
FT dot(const std::vector< FT > &, const std::vector< FT > &)
Inner product for vectors.
Definition matrix.h:1834