TeiaCareSDK  v0.1.0
TeiaCareSDK is a collection of reusable C++ components
Loading...
Searching...
No Matches
tc::sdk::line< T > Class Template Reference

2D line specified by a pair of start/end points. More...

#include <line.hpp>

Public Member Functions

constexpr line ()=default
 Default Constructor. Creates a default tc::sdk::line instance.
 
constexpr line (const line &)=default
 Copy Constructor. Copy a tc::sdk::line instance into another one.
 
constexpr line (line &&)=default
 Move Constructor. Copy a tc::sdk::line instance into another one.
 
constexpr line (tc::sdk::point< T > start, tc::sdk::point< T > end) noexcept
 Constructor. Creates tc::sdk::line instance with given start and end points.
 
lineoperator= (const line &)=default
 Assignment operator. Assign a tc::sdk::line instance to another one.
 
lineoperator= (line &&)=default
 Move assignment operator. Assign a tc::sdk::line instance to another one.
 
constexpr bool operator== (const line &other) const noexcept
 Equality operator.
 
constexpr bool operator!= (const line &other) const noexcept
 Inequality operator.
 
constexpr bool is_null () const noexcept
 Check if the line is a point.
 
bool is_vertical () const noexcept
 Check if the line is vertical.
 
bool is_horizontal () const noexcept
 Check if the line is horizontal.
 
constexpr tc::sdk::point< T > start () const noexcept
 Start point getter.
 
constexpr tc::sdk::point< T > end () const noexcept
 End point getter.
 
void set_start (tc::sdk::point< T > start) noexcept
 Start point setter. Set the start point of the line.
 
void set_end (tc::sdk::point< T > end) noexcept
 End point setter. Set the end point of the line.
 
bool intersects (tc::sdk::line< T > other) const noexcept
 Check if the given line segments intersects the current instance.
 
std::optional< tc::sdk::point< double > > get_intersection (tc::sdk::line< T > other) const noexcept
 Computes the intersection between the given line and the current one.
 
constexpr std::string to_string () const
 Get the line string representation.
 

Friends

std::ostream & operator<< (std::ostream &stream, const line &l)
 Output stream operator.
 

Detailed Description

template<typename T>
class tc::sdk::line< T >

2D line specified by a pair of start/end points.

Template Parameters
TUnderlying points coordinate type.
Examples
example_geometry_line.cpp.

Definition at line 31 of file line.hpp.

Constructor & Destructor Documentation

◆ line()

template<typename T >
constexpr tc::sdk::line< T >::line ( tc::sdk::point< T >  start,
tc::sdk::point< T >  end 
)
inlineexplicitconstexprnoexcept

Constructor. Creates tc::sdk::line instance with given start and end points.

Parameters
startthe start point of the line.
endthe end point of the line.

Definition at line 54 of file line.hpp.

Member Function Documentation

◆ operator==()

template<typename T >
constexpr bool tc::sdk::line< T >::operator== ( const line< T > &  other) const
inlineconstexprnoexcept

Equality operator.

Parameters
otherthe line to compare against.
Returns
true if the two lines have the same start and end points.

Definition at line 75 of file line.hpp.

◆ operator!=()

template<typename T >
constexpr bool tc::sdk::line< T >::operator!= ( const line< T > &  other) const
inlineconstexprnoexcept

Inequality operator.

Parameters
otherthe line to compare against.
Returns
true if the two lines have different start or end points.

Definition at line 86 of file line.hpp.

◆ is_null()

template<typename T >
constexpr bool tc::sdk::line< T >::is_null ( ) const
inlineconstexprnoexcept

Check if the line is a point.

Returns
true if the start and end points are the same.

Definition at line 95 of file line.hpp.

◆ is_vertical()

template<typename T >
bool tc::sdk::line< T >::is_vertical ( ) const
inlinenoexcept

Check if the line is vertical.

Returns
true if the start and end points have the same x coordinate.

Definition at line 104 of file line.hpp.

◆ is_horizontal()

template<typename T >
bool tc::sdk::line< T >::is_horizontal ( ) const
inlinenoexcept

Check if the line is horizontal.

Returns
true if the start and end points have the same y coordinate.

Definition at line 113 of file line.hpp.

◆ start()

template<typename T >
constexpr tc::sdk::point< T > tc::sdk::line< T >::start ( ) const
inlineconstexprnoexcept

Start point getter.

Returns
Start point of the line.

Definition at line 122 of file line.hpp.

◆ end()

template<typename T >
constexpr tc::sdk::point< T > tc::sdk::line< T >::end ( ) const
inlineconstexprnoexcept

End point getter.

Returns
End point of the line.

Definition at line 131 of file line.hpp.

◆ set_start()

template<typename T >
void tc::sdk::line< T >::set_start ( tc::sdk::point< T >  start)
inlinenoexcept

Start point setter. Set the start point of the line.

Definition at line 139 of file line.hpp.

◆ set_end()

template<typename T >
void tc::sdk::line< T >::set_end ( tc::sdk::point< T >  end)
inlinenoexcept

End point setter. Set the end point of the line.

Definition at line 147 of file line.hpp.

◆ intersects()

template<typename T >
bool tc::sdk::line< T >::intersects ( tc::sdk::line< T >  other) const
inlinenoexcept

Check if the given line segments intersects the current instance.

Parameters
otherthe line to check the intersection against.
Returns
true if the two lines intersects.

Definition at line 157 of file line.hpp.

◆ get_intersection()

template<typename T >
std::optional< tc::sdk::point< double > > tc::sdk::line< T >::get_intersection ( tc::sdk::line< T >  other) const
inlinenoexcept

Computes the intersection between the given line and the current one.

Parameters
otherthe compute to check the intersection against.
Returns
std::nullopt if the two lines do not intersect, otherwise a std::optional<tc::sdk::point<double>> with the intersection point.

Definition at line 167 of file line.hpp.

◆ to_string()

template<typename T >
constexpr std::string tc::sdk::line< T >::to_string ( ) const
inlineconstexpr

Get the line string representation.

Returns
String representation of the current line.

Definition at line 207 of file line.hpp.

Friends And Related Symbol Documentation

◆ operator<<

template<typename T >
std::ostream & operator<< ( std::ostream &  stream,
const line< T > &  l 
)
friend

Output stream operator.

Parameters
streamthe output stream to write into.
lthe line object to stream.
Returns
reference to the output stream operator, with the line string representation written into it.

Definition at line 218 of file line.hpp.


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