NDEVR
API Documentation
LineSegment< t_dims, t_type, t_vertex >

Class: LineSegment. More...

Inheritance diagram for LineSegment< t_dims, t_type, t_vertex >:
[legend]
Collaboration diagram for LineSegment< t_dims, t_type, t_vertex >:
[legend]

Public Member Functions

template<uint01 t_new_dims, class t_new_type, class t_new_vertex = Vertex<t_new_dims, t_new_type>>
constexpr LineSegment< t_new_dims, t_new_type, t_new_vertex > as () const
constexpr t_vertex center () const
template<class t_precision, class t_other_vertex>
constexpr LineSegment< t_dims, t_precision > closestPoints (const LineSegment< t_dims, t_type, t_other_vertex > &l2, t_precision epsilon=0) const
 Closest vertices.
template<bool t_clip = true>
constexpr t_type closestPos (const t_vertex &p) const
 Returns the closest value where 0 is.
constexpr t_vertex closestValue (const t_vertex &p) const
template<bool t_clip, class t_precision>
constexpr t_precision getLocationAt (t_precision value, uint01 dim) const
template<class t_precision = t_type>
constexpr Vector< t_dims, t_precision > intersection (const LineSegment &r, t_precision epsilon=0) const
 Intersections.
template<class t_precision = t_type>
constexpr t_precision intersectionPosition (const LineSegment< t_dims, t_type > &segment) const
template<class t_precision = t_type>
constexpr bool intersects (const LineSegment< 3, t_type > &segment, t_precision epsilon=cast< t_precision >(1e-9)) const
 Query if this object intersects the given segment.
template<class t_precision = t_type>
constexpr bool isCollinear (const LineSegment< t_dims, t_type > &line, t_precision epsilon=0) const
 Query if 'line' is collinear.
template<class t_precision = t_type>
constexpr bool isCollinear (const t_vertex &vert, t_precision epsilon=t_precision(1e-10)) const
 Query if the line is collinear with the given vertex.
template<class t_precision = t_type>
constexpr bool isParallel (const LineSegment< t_dims, t_type, t_vertex > &line, t_precision epsilon=0) const
 Query if 'line' is parallel.
template<class t_precision = t_type>
constexpr t_precision length () const
constexpr t_type lengthSquared () const
constexpr t_vertex midpoint () const
 Gets the midpoint.
template<class t_inter_type>
constexpr t_vertex pointAt (t_inter_type index) const
template<bool t_clip, class t_precision>
constexpr t_vertex pointAt (t_precision value, uint01 dim, const t_vertex &nan_return=Constant< t_vertex >::Invalid) const
 Point at.
constexpr t_vertex ray () const
template<class t_inter_type>
constexpr LineSegment< t_dims, t_type > scale (const t_inter_type &scale) const
 Scales.
constexpr t_vertex & vertex (uint01 index)
constexpr const t_vertex & vertex (uint01 index) const
Public Member Functions inherited from Vector< t_dims, t_type >
template<uint01 tdims = t_dims>
constexpr Vector (const t_type &prefix, typename std::enable_if< tdims >=2, const Vector< t_dims - 1, t_type > & >::type vector)
 Creates a vector where the prefix scaler is combined with the suffix vector.
template<uint01 tdims = t_dims>
constexpr Vector (const t_type &prefix_a, const t_type &prefix_b, typename std::enable_if< tdims >=3, const Vector< tdims - 1, t_type > & >::type vector)
 Creates a vector where the prefix scaler values are combined with the suffix vector.
constexpr Vector (const t_type &scaler) noexcept
template<uint01 tdims = t_dims>
constexpr Vector (const t_type &x, const t_type &y, const t_type &z, typename std::enable_if< tdims==4, const t_type & >::type w)
 Sets values in each dimension to the respective value in the passed in scaler.
template<uint01 tdims = t_dims>
constexpr Vector (const t_type &x, const t_type &y, const typename std::enable_if< tdims==3, const t_type & >::type z)
 Sets values in each dimension to the respective value in the passed in scaler.
template<uint01 tdims = t_dims>
constexpr Vector (const t_type &x, typename std::enable_if< tdims==2, const t_type & >::type y)
 Sets values in each dimension to the respective value in the passed in scaler.
constexpr Vector (const t_type(&vector)[t_dims])
 Given a container of statically determined array, transforms it to a vector.
template<uint01 tdims = t_dims>
constexpr Vector (const Vector< getMax(tdims - 2, 0), t_type > &vector, const t_type &suffix_a, typename std::enable_if< tdims >=3, const t_type & >::type suffix_b)
 Creates a vector where the prefix vector is combined with the suffix scalers.
template<class t_vec_type>
constexpr Vector (const Vector< t_dims, t_vec_type > &vector) noexcept
template<uint01 tdims = t_dims>
constexpr Vector (const Vector< tdims - 1, t_type > &vector, typename std::enable_if< tdims >=2, const t_type & >::type suffix)
 Creates a vector where the prefix vector is combined with the suffix scalers.
template<class t_new_type>
constexpr decltype(auto) as () const
 Returns the vector as a new time of vector.
template<LocationValues t_max_min>
constexpr uint01 dimensionalIndex () const
 Used with template arguments MAX or MIN, Gets the dimensional index for the value that is either max or min.
template<LocationValues t_max_min>
constexpr t_type dimensionalValue () const
 Used with template arguments MAX or MIN, Gets the dimensional value for the value that is either max or min.
template<class t_magnitude_type = t_type>
constexpr t_magnitude_type magnitude () const
 Vectors are commonly used to model forces such as wind, sea current, gravity, and electromagnetism.
constexpr t_type magnitudeSquared () const
 Vectors are commonly used to model forces such as wind, sea current, gravity, and electromagnetism.
template<class t_norm_type = t_type>
constexpr Vector< t_dims, t_norm_type > normalized (Vector< t_dims, t_norm_type > value_if_nan=Constant< Vector< t_dims, t_norm_type > >::Invalid) const
 Gets the normalized, or unit length representation of this vector.
template<uint01 tdims = t_dims, typename = typename std::enable_if<tdims == 1>::type>
constexpr operator t_type & ()
 For Single dimensional objects, they may also be considered a scaler, thus allow implicit conversion from a vector to a scaler when the dimension of the vector is 1.
constexpr Vector< t_dims, t_type > operator- () const
 Negation operator.
constexpr Vector< t_dims, t_type > & operator= (const t_type &scaler)
 Assignment operator.
constexpr t_type & operator[] (uint01 dimension_index)
 Accesses the value of a certain dimension.
constexpr t_type product () const
 Returns the product, or value of each dimension multiplied together.
constexpr t_type sum () const
 Returns the sum, or value of each dimension added together.

Static Public Member Functions

template<class t_buffer_type>
static constexpr LineSegment createBestFitLine (const t_buffer_type &vertices, uint01 dim_0, uint01 dim_1)
 Creates best fit line.
Static Public Member Functions inherited from Vector< t_dims, t_type >
static constexpr uint01 NumberOfDimensions ()
 Number of dimensions in this vector class.
static constexpr t_type Type ()
 Returns the type of this class.

Additional Inherited Members

Protected Attributes inherited from Vector< t_dims, t_type >
t_type m_values [t_dims]
 The values[t dims].

Detailed Description

template<uint01 t_dims, class t_type, class t_vertex = Vertex<t_dims, t_type>>
class LineSegment< t_dims, t_type, t_vertex >

Class: LineSegment.

A line segment represented by two vertices, a start and end.

Author: Tyler Parke

Date: 2017-11-19

See also
Vertex, Ray, Polyline, Triangle

Definition at line 51 of file Line.hpp.

Member Function Documentation

◆ as()

template<uint01 t_dims, class t_type, class t_vertex = Vertex<t_dims, t_type>>
template<uint01 t_new_dims, class t_new_type, class t_new_vertex = Vertex<t_new_dims, t_new_type>>
LineSegment< t_new_dims, t_new_type, t_new_vertex > LineSegment< t_dims, t_type, t_vertex >::as ( ) const
inlineconstexpr
    Gets as.

Author: Tyler Parke

Date: 2017-11-19

Returns
A LineSegment<t_new_dims,t_new_type,t_new_vertex>

Definition at line 73 of file Line.hpp.

Referenced by LineSegment< 2, t_type, Vertex< 2, t_type > >::pointAt().

◆ center()

template<uint01 t_dims, class t_type, class t_vertex = Vertex<t_dims, t_type>>
t_vertex LineSegment< t_dims, t_type, t_vertex >::center ( ) const
inlineconstexpr
    Gets the center.

Author: Tyler Parke

Date: 2017-11-19

Returns
A t_vertex.

Definition at line 138 of file Line.hpp.

◆ closestPoints()

template<uint01 t_dims, class t_type, class t_vertex = Vertex<t_dims, t_type>>
template<class t_precision, class t_other_vertex>
LineSegment< t_dims, t_precision > LineSegment< t_dims, t_type, t_vertex >::closestPoints ( const LineSegment< t_dims, t_type, t_other_vertex > & l2,
t_precision epsilon = 0 ) const
inlineconstexpr

Closest vertices.

Author: Tyler Parke

Date: 2017-11-19

Parameters: l2 - The second LineSegment<t_dims,t_type> epsilon - (Optional) The epsilon.

Returns
A LineSegment<t_dims,t_precision>

Definition at line 258 of file Line.hpp.

Referenced by LineSegment< 2, t_type, Vertex< 2, t_type > >::intersection(), and LineSegment< 2, t_type, Vertex< 2, t_type > >::intersects().

◆ closestValue()

template<uint01 t_dims, class t_type, class t_vertex = Vertex<t_dims, t_type>>
t_vertex LineSegment< t_dims, t_type, t_vertex >::closestValue ( const t_vertex & p) const
inlineconstexpr
    Closest value.

Author: Tyler Parke

Date: 2017-11-19

Parameters: p - A t_vertex to process.

Returns
A t_vertex.

Definition at line 377 of file Line.hpp.

◆ createBestFitLine()

template<uint01 t_dims, class t_type, class t_vertex = Vertex<t_dims, t_type>>
template<class t_buffer_type>
constexpr LineSegment LineSegment< t_dims, t_type, t_vertex >::createBestFitLine ( const t_buffer_type & vertices,
uint01 dim_0,
uint01 dim_1 )
inlinestaticconstexpr

Creates best fit line.

Author: Tyler Parke

Date: 2017-11-19

Parameters: vertices - The vertices. dim_0 - The dim 0. dim_1 - The first dim.

Returns
The new best fit line.

Definition at line 668 of file Line.hpp.

◆ getLocationAt()

template<uint01 t_dims, class t_type, class t_vertex = Vertex<t_dims, t_type>>
template<bool t_clip, class t_precision>
t_precision LineSegment< t_dims, t_type, t_vertex >::getLocationAt ( t_precision value,
uint01 dim ) const
inlineconstexpr
    Gets location at.

Author: Tyler Parke

Date: 2017-11-19

Parameters: value - The value. dim - The dim.

Returns
The location at.

Definition at line 583 of file Line.hpp.

◆ intersection()

template<uint01 t_dims, class t_type, class t_vertex = Vertex<t_dims, t_type>>
template<class t_precision = t_type>
Vector< t_dims, t_precision > LineSegment< t_dims, t_type, t_vertex >::intersection ( const LineSegment< t_dims, t_type, t_vertex > & r,
t_precision epsilon = 0 ) const
inlineconstexpr

Intersections.

Author: Tyler Parke

Date: 2017-11-19

Parameters: r - A LineSegment to process. epsilon - (Optional) The epsilon.

Returns
A Vector<t_dims,t_precision>

Definition at line 484 of file Line.hpp.

◆ intersectionPosition()

template<uint01 t_dims, class t_type, class t_vertex = Vertex<t_dims, t_type>>
template<class t_precision = t_type>
t_precision LineSegment< t_dims, t_type, t_vertex >::intersectionPosition ( const LineSegment< t_dims, t_type > & segment) const
inlineconstexpr
    Intersection position.

Author: Tyler Parke

Date: 2017-11-19

Parameters: segment - The segment.

Returns
A t_precision.

Definition at line 506 of file Line.hpp.

◆ intersects()

template<uint01 t_dims, class t_type, class t_vertex = Vertex<t_dims, t_type>>
template<class t_precision = t_type>
bool LineSegment< t_dims, t_type, t_vertex >::intersects ( const LineSegment< 3, t_type > & segment,
t_precision epsilon = cast<t_precision>(1e-9) ) const
inlinenodiscardconstexpr

Query if this object intersects the given segment.

Author: Tyler Parke

Date: 2017-11-19

Parameters: segment - The segment. epsilon - (Optional) The epsilon.

Returns
True if it succeeds, false if it fails.

Definition at line 529 of file Line.hpp.

◆ isCollinear() [1/2]

template<uint01 t_dims, class t_type, class t_vertex = Vertex<t_dims, t_type>>
template<class t_precision = t_type>
bool LineSegment< t_dims, t_type, t_vertex >::isCollinear ( const LineSegment< t_dims, t_type > & line,
t_precision epsilon = 0 ) const
inlineconstexpr

Query if 'line' is collinear.

Author: Tyler Parke

Date: 2017-11-19

Parameters: line - The line. epsilon - (Optional) The epsilon.

Returns
True if collinear, false if not.

Definition at line 214 of file Line.hpp.

◆ isCollinear() [2/2]

template<uint01 t_dims, class t_type, class t_vertex = Vertex<t_dims, t_type>>
template<class t_precision = t_type>
bool LineSegment< t_dims, t_type, t_vertex >::isCollinear ( const t_vertex & vert,
t_precision epsilon = t_precision(1e-10) ) const
inlineconstexpr

Query if the line is collinear with the given vertex.

Epsilon will adapt based on length of the line segment.

Author: Tyler Parke

Date: 2017-11-19

Parameters: vert - The vertical. epsilon - (Optional) The epsilon.

Returns
True if collinear, false if not.

Definition at line 234 of file Line.hpp.

◆ isParallel()

template<uint01 t_dims, class t_type, class t_vertex = Vertex<t_dims, t_type>>
template<class t_precision = t_type>
bool LineSegment< t_dims, t_type, t_vertex >::isParallel ( const LineSegment< t_dims, t_type, t_vertex > & line,
t_precision epsilon = 0 ) const
inlineconstexpr

Query if 'line' is parallel.

Author: Tyler Parke

Date: 2017-11-19

Parameters: line - The line. epsilon - (Optional) The epsilon.

Returns
True if parallel, false if not.

Definition at line 192 of file Line.hpp.

Referenced by LineSegment< 2, t_type, Vertex< 2, t_type > >::isCollinear().

◆ length()

template<uint01 t_dims, class t_type, class t_vertex = Vertex<t_dims, t_type>>
template<class t_precision = t_type>
t_precision LineSegment< t_dims, t_type, t_vertex >::length ( ) const
inlineconstexpr
    Gets the length.

Author: Tyler Parke

Date: 2017-11-19

Returns
A t_precision.

Definition at line 447 of file Line.hpp.

◆ lengthSquared()

template<uint01 t_dims, class t_type, class t_vertex = Vertex<t_dims, t_type>>
t_type LineSegment< t_dims, t_type, t_vertex >::lengthSquared ( ) const
inlineconstexpr
    Length squared.

Author: Tyler Parke

Date: 2017-11-19

Returns
A t_type.

Definition at line 462 of file Line.hpp.

Referenced by GravityIntersection::calculateIntersection(), and intersection().

◆ midpoint()

template<uint01 t_dims, class t_type, class t_vertex = Vertex<t_dims, t_type>>
t_vertex LineSegment< t_dims, t_type, t_vertex >::midpoint ( ) const
inlineconstexpr

Gets the midpoint.

Author: Tyler Parke

Date: 2017-11-19

Returns
A t_vertex.

Definition at line 106 of file Line.hpp.

Referenced by LineSegment< 2, t_type, Vertex< 2, t_type > >::center().

◆ pointAt() [1/2]

template<uint01 t_dims, class t_type, class t_vertex = Vertex<t_dims, t_type>>
template<class t_inter_type>
t_vertex LineSegment< t_dims, t_type, t_vertex >::pointAt ( t_inter_type index) const
inlineconstexpr
    Point at.

Author: Tyler Parke

Date: 2017-11-19

Parameters: index - Zero-based index of the.

Returns
A t_vertex.

Definition at line 91 of file Line.hpp.

Referenced by LineSegment< 2, t_type, Vertex< 2, t_type > >::closestValue(), and LineSegment< 2, t_type, Vertex< 2, t_type > >::scale().

◆ pointAt() [2/2]

template<uint01 t_dims, class t_type, class t_vertex = Vertex<t_dims, t_type>>
template<bool t_clip, class t_precision>
t_vertex LineSegment< t_dims, t_type, t_vertex >::pointAt ( t_precision value,
uint01 dim,
const t_vertex & nan_return = Constant<t_vertex>::Invalid ) const
inlineconstexpr

Point at.

Author: Tyler Parke

Date: 2017-11-19

Parameters: value - The value. dim - The dim. nan_return - (Optional) The Invalid return.

Returns
A t_vertex.

Definition at line 624 of file Line.hpp.

◆ ray()

template<uint01 t_dims, class t_type, class t_vertex = Vertex<t_dims, t_type>>
t_vertex LineSegment< t_dims, t_type, t_vertex >::ray ( ) const
inlineconstexpr

◆ scale()

template<uint01 t_dims, class t_type, class t_vertex = Vertex<t_dims, t_type>>
template<class t_inter_type>
LineSegment< t_dims, t_type > LineSegment< t_dims, t_type, t_vertex >::scale ( const t_inter_type & scale) const
inlineconstexpr

Scales.

Author: Tyler Parke

Date: 2017-11-19

Parameters: scale - The scale. center - The center.

Returns
A LineSegment<t_dims,t_type>

Scales.

Author: Tyler Parke

Date: 2017-11-19

Parameters: scale - The scale. center - The center.

Returns
A LineSegment<t_dims,t_type>

Definition at line 417 of file Line.hpp.

◆ vertex() [1/2]

template<uint01 t_dims, class t_type, class t_vertex = Vertex<t_dims, t_type>>
t_vertex & LineSegment< t_dims, t_type, t_vertex >::vertex ( uint01 index)
inlineconstexpr
    Vertices the given index.

Author: Tyler Parke

Date: 2017-11-19

Parameters: index - Zero-based index of the.

Returns
A reference to a t_vertex.

Definition at line 172 of file Line.hpp.

◆ vertex() [2/2]


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