27#ifndef EASY3D_CORE_SEGMENT_H
28#define EASY3D_CORE_SEGMENT_H
33#include <easy3d/core/vec.h>
34#include <easy3d/core/line.h>
45 template <
int DIM,
typename FT>
130 template<
int DIM,
typename FT>
inline
132 DLOG_IF(
distance2(s, t) < 1e-15, ERROR) <<
"degenerate segment constructed from 2 points:"
134 <<
"\t(" << t <<
")";
138 template<
int DIM,
typename FT>
inline
141 return (s_ + dir *
dot(p - s_, dir));
145 template<
int DIM,
typename FT>
inline
147 return (
dot(s_ - p, t_ - p) < 0);
151 template<
int DIM,
typename FT>
inline
158 return std::min(ds, dt);
A generic line representation, which supports both 2D and 3D lines.
Definition line.h:45
static GenericLine from_two_points(const Point &p, const Point &q)
Constructs a line from two points p and q.
Definition line.h:65
FT squared_distance(const Point &p) const
Returns the squared distance of a point p to this segment.
Definition segment.h:152
GenericSegment< DIM, FT > thisclass
The type of this class.
Definition segment.h:51
GenericSegment()=default
Default constructor.
Point projection(const Point &p) const
Returns the projection of a point p on the supporting line of this segment.
Definition segment.h:139
Line supporting_line() const
Returns the supporting line of this line segment.
Definition segment.h:91
GenericLine< DIM, FT > Line
The type of the line.
Definition segment.h:50
const Point & target() const
Returns the target end point of this line segment.
Definition segment.h:74
bool projected_inside(const Point &p) const
Tests if the projection of a point p is within the two end points of this segment.
Definition segment.h:146
GenericSegment(const Point &s, const Point &t)
Constructs a line segment from its two end points s and t.
Definition segment.h:131
Vector to_vector() const
Returns a vector originating from source() and pointing to target().
Definition segment.h:97
const Point & source() const
Returns the source end point of this line segment.
Definition segment.h:69
Vec< DIM, FT > Vector
The type of the vector.
Definition segment.h:49
void set_target(const Point &t)
Sets/Changes the target end point of this line segment.
Definition segment.h:85
Vec< DIM, FT > Point
The type of the point.
Definition segment.h:48
void set_source(const Point &s)
Sets/Changes the source end point of this line segment.
Definition segment.h:80
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 distance2(const Vec< N, T > &v1, const Vec< N, T > &v2)
Computes the squared distance between two vectors/points.
Definition vec.h:297
FT dot(const std::vector< FT > &, const std::vector< FT > &)
Inner product for vectors.
Definition matrix.h:1834