Visual Computing Library
Loading...
Searching...
No Matches
vcl::Segment< PointT > Class Template Reference

A class representing a line segment in n-dimensional space. The class is parameterized by a PointConcept, which must provide the DIM constant and the [] operator for accessing the point coordinates. More...

#include <vclib/space/core/segment.h>

Public Types

using PointType = PointT
 The type of point used to represent the endpoint points of the segment.
 
using ScalarType = PointT::ScalarType
 The scalar type of the endpoint points.
 

Public Member Functions

 Segment ()
 Default constructor. Creates a segment with endpoints at the origin.
 
 Segment (const PointT &p0, const PointT &p1)
 Creates a segment with the given endpoints.
 
PointT & p0 ()
 Returns the first endpoint of the segment.
 
const PointT & p0 () const
 Returns the first endpoint of the segment.
 
PointT & p1 ()
 Returns the second endpoint of the segment.
 
const PointT & p1 () const
 Returns the second endpoint of the segment.
 
PointT midPoint () const
 
PointT direction () const
 
PointT normalizedDirection () const
 
ScalarType length () const
 
ScalarType squaredLength () const
 
void flip ()
 
bool operator== (const Segment< PointT > &s) const =default
 
bool operator!= (const Segment< PointT > &s) const =default
 
Segment< PointT > operator+ (const Segment< PointT > &s) const
 
Segment< PointT > operator- (const Segment< PointT > &s) const
 
Segment< PointT > operator* (const ScalarType &s) const
 
Segment< PointT > operator/ (const ScalarType &s) const
 
Segment< PointT > & operator+= (const Segment< PointT > &s) const
 
Segment< PointT > & operator-= (const Segment< PointT > &s) const
 
Segment< PointT > & operator*= (const ScalarType &s) const
 
Segment< PointT > & operator/= (const ScalarType &s) const
 

Static Public Attributes

static const uint DIM = PointT::DIM
 The dimensionality of the segment.
 

Private Attributes

PointT mPoint0
 
PointT mPoint1
 

Detailed Description

template<PointConcept PointT>
class vcl::Segment< PointT >

A class representing a line segment in n-dimensional space. The class is parameterized by a PointConcept, which must provide the DIM constant and the [] operator for accessing the point coordinates.

Template Parameters
PointTThe type of the two endpoint points of the segment.

Constructor & Destructor Documentation

◆ Segment()

template<PointConcept PointT>
vcl::Segment< PointT >::Segment ( const PointT &  p0,
const PointT &  p1 
)
inline

Creates a segment with the given endpoints.

Parameters
[in]p0The first endpoint of the segment.
[in]p1The second endpoint of the segment.

Member Function Documentation

◆ p0() [1/2]

template<PointConcept PointT>
PointT & vcl::Segment< PointT >::p0 ( )
inline

Returns the first endpoint of the segment.

Returns
A reference to the first endpoint of the segment.

◆ p0() [2/2]

template<PointConcept PointT>
const PointT & vcl::Segment< PointT >::p0 ( ) const
inline

Returns the first endpoint of the segment.

Returns
A const reference to the first endpoint of the segment.

◆ p1() [1/2]

template<PointConcept PointT>
PointT & vcl::Segment< PointT >::p1 ( )
inline

Returns the second endpoint of the segment.

Returns
A reference to the second endpoint of the segment.

◆ p1() [2/2]

template<PointConcept PointT>
const PointT & vcl::Segment< PointT >::p1 ( ) const
inline

Returns the second endpoint of the segment.

Returns
A reference to the second endpoint of the segment.

The documentation for this class was generated from the following file: