27#ifndef EASY3D_CORE_SEGMENT_H
28#define EASY3D_CORE_SEGMENT_H
33#include <easy3d/core/vec.h>
34#include <easy3d/core/line.h>
42 template <
int DIM,
typename FT>
90 template<
int DIM,
typename FT>
inline
92 DLOG_IF(
distance2(s, t) < 1e-15, ERROR) <<
"degenerate segment constructed from 2 points:"
98 template<
int DIM,
typename FT>
inline
101 return (s_ + dir *
dot(p - s_, dir));
105 template<
int DIM,
typename FT>
inline
107 return (
dot(s_ - p, t_ - p) < 0);
111 template<
int DIM,
typename FT>
inline
113 if (projected_inside(p))
118 return std::min(ds, dt);
A generic line representation, which supports both 2D and 3D lines.
Definition: line.h:40
static GenericLine from_two_points(const Point &p, const Point &q)
Constructs a line from two points p and q.
Definition: line.h:50
A generic segmentation representation, which supports both 2D and 3D line segments.
Definition: segment.h:43
FT squared_distance(const Point &p) const
Returns the squared distance of a point p to this segment. The return the value is the min of the fol...
Definition: segment.h:112
Point projection(const Point &p) const
Returns the projection of a point p on the supporting line of this segment.
Definition: segment.h:99
Line supporting_line() const
Returns the supporting line of this line segment.
Definition: segment.h:65
const Point & target() const
Returns the target end point of this line segment.
Definition: segment.h:58
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:106
Vector to_vector() const
Returns a vector originating from source() and pointing to target().
Definition: segment.h:68
const Point & source() const
Returns the source end point of this line segment.
Definition: segment.h:56
void set_target(const Point &t)
Sets/Changes the target end point of this line segment.
Definition: segment.h:62
void set_source(const Point &s)
Sets/Changes the source end point of this line segment.
Definition: segment.h:60
Definition: collider.cpp:182
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:1803
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