23#ifndef VCL_SPACE_CORE_SEGMENT_H
24#define VCL_SPACE_CORE_SEGMENT_H
39template<Po
intConcept Po
intT>
60 static const uint
DIM = PointT::DIM;
81 PointT&
p0() {
return mPoint0; }
88 const PointT&
p0()
const {
return mPoint0; }
95 PointT&
p1() {
return mPoint1; }
102 const PointT&
p1()
const {
return mPoint1; }
104 PointT midPoint()
const {
return (mPoint0 + mPoint1) / 2.0; }
106 PointT direction()
const {
return mPoint1 - mPoint0; }
108 PointT normalizedDirection()
const
110 return (mPoint1 - mPoint0).normalize();
113 ScalarType length()
const {
return (mPoint0 - mPoint1).norm(); }
117 return (mPoint0 - mPoint1).squaredNorm();
120 void flip() { std::swap(mPoint0, mPoint1); }
148 mPoint0 += s.mPoint0;
149 mPoint1 += s.mPoint1;
155 mPoint0 -= s.mPoint0;
156 mPoint1 -= s.mPoint1;
178using Segment2 = Segment<Point2<S>>;
180using Segment2i = Segment<Point2i>;
181using Segment2f = Segment<Point2f>;
182using Segment2d = Segment<Point2d>;
185using Segment3 = Segment<Point3<S>>;
187using Segment3i = Segment<Point3i>;
188using Segment3f = Segment<Point3f>;
189using Segment3d = Segment<Point3d>;
205 std::remove_cvref_t<T>,
206 Segment<typename RemoveRef<T>::PointType>>;
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:41
PointT::ScalarType ScalarType
The scalar type of the endpoint points.
Definition segment.h:55
static const uint DIM
The dimensionality of the segment.
Definition segment.h:60
PointT & p0()
Returns the first endpoint of the segment.
Definition segment.h:81
PointT & p1()
Returns the second endpoint of the segment.
Definition segment.h:95
Segment()
Default constructor. Creates a segment with endpoints at the origin.
Definition segment.h:66
const PointT & p1() const
Returns the second endpoint of the segment.
Definition segment.h:102
Segment(const PointT &p0, const PointT &p1)
Creates a segment with the given endpoints.
Definition segment.h:74
const PointT & p0() const
Returns the first endpoint of the segment.
Definition segment.h:88
PointT PointType
The type of point used to represent the endpoint points of the segment.
Definition segment.h:50
A concept representing a 2D Segment.
Definition segment.h:219
A concept representing a 3D Segment.
Definition segment.h:232
A concept representing a Segment.
Definition segment.h:204