23#ifndef VCL_SPACE_CORE_SEGMENT_H
24#define VCL_SPACE_CORE_SEGMENT_H
28#include <vclib/concepts/space/segment.h>
41template<Po
intConcept Po
intT>
62 static const uint
DIM = PointT::DIM;
83 PointT&
p0() {
return mPoint0; }
90 const PointT&
p0()
const {
return mPoint0; }
97 PointT&
p1() {
return mPoint1; }
104 const PointT&
p1()
const {
return mPoint1; }
106 PointT midPoint()
const {
return (mPoint0 + mPoint1) / 2.0; }
108 PointT direction()
const {
return mPoint1 - mPoint0; }
110 PointT normalizedDirection()
const
112 return (mPoint1 - mPoint0).normalize();
119 void flip() { std::swap(mPoint0, mPoint1); }
147 mPoint0 += s.mPoint0;
148 mPoint1 += s.mPoint1;
154 mPoint0 -= s.mPoint0;
155 mPoint1 -= s.mPoint1;
177using Segment2 = Segment<Point2<S>>;
179using Segment2i = Segment<Point2i>;
180using Segment2f = Segment<Point2f>;
181using Segment2d = Segment<Point2d>;
184using Segment3 = Segment<Point3<S>>;
186using Segment3i = Segment<Point3i>;
187using Segment3f = Segment<Point3f>;
188using Segment3d = Segment<Point3d>;
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
PointT::ScalarType ScalarType
The scalar type of the endpoint points.
Definition segment.h:57
static const uint DIM
The dimensionality of the segment.
Definition segment.h:62
PointT & p0()
Returns the first endpoint of the segment.
Definition segment.h:83
PointT & p1()
Returns the second endpoint of the segment.
Definition segment.h:97
Segment()
Default constructor. Creates a segment with endpoints at the origin.
Definition segment.h:68
const PointT & p1() const
Returns the second endpoint of the segment.
Definition segment.h:104
Segment(const PointT &p0, const PointT &p1)
Creates a segment with the given endpoints.
Definition segment.h:76
const PointT & p0() const
Returns the first endpoint of the segment.
Definition segment.h:90
PointT PointType
The type of point used to represent the endpoint points of the segment.
Definition segment.h:52