Saga3D API Documentation  1.0-RC4
saga::core::line3d< T > Class Template Reference

3D line between two points with intersection methods. More...

#include <line3d.h>

Public Member Functions

 line3d ()
 Default constructor. More...
 
 line3d (T xa, T ya, T za, T xb, T yb, T zb)
 Constructor with two points. More...
 
 line3d (const glm::vec3 &start, const glm::vec3 &end)
 Constructor with two points as vectors. More...
 
line3d< T > operator+ (const glm::vec3 &point) const
 
line3d< T > & operator+= (const glm::vec3 &point)
 
line3d< T > operator- (const glm::vec3 &point) const
 
line3d< T > & operator-= (const glm::vec3 &point)
 
bool operator== (const line3d< T > &other) const
 
bool operator!= (const line3d< T > &other) const
 
void setLine (const T &xa, const T &ya, const T &za, const T &xb, const T &yb, const T &zb)
 Set this line to a new line going through the two points. More...
 
void setLine (const glm::vec3 &nstart, const glm::vec3 &nend)
 Set this line to a new line going through the two points. More...
 
void setLine (const line3d< T > &line)
 Set this line to new line given as parameter. More...
 
getLength () const
 Get length of line. More...
 
getLengthSQ () const
 Get squared length of line. More...
 
glm::vec3 getMiddle () const
 Get middle of line. More...
 
glm::vec3 getVector () const
 Get vector of line. More...
 
bool isPointBetweenStartAndEnd (const glm::vec3 &point) const
 Check if the given point is between start and end of the line. More...
 
glm::vec3 getClosestPoint (const glm::vec3 &point) const
 Get the closest point on this line to a point. More...
 
bool getIntersectionWithSphere (const glm::vec3 &sorigin, T sradius, double &outdistance) const
 Check if the line intersects with a sphere. More...
 

Public Attributes

glm::vec3 start
 Start point of line. More...
 
glm::vec3 end
 End point of line. More...
 

Detailed Description

template<class T>
class saga::core::line3d< T >

3D line between two points with intersection methods.

Definition at line 17 of file line3d.h.

Constructor & Destructor Documentation

◆ line3d() [1/3]

template<class T >
saga::core::line3d< T >::line3d ( )
inline

Default constructor.

line from (0,0,0) to (1,1,1)

Definition at line 23 of file line3d.h.

◆ line3d() [2/3]

template<class T >
saga::core::line3d< T >::line3d ( xa,
ya,
za,
xb,
yb,
zb 
)
inline

Constructor with two points.

Definition at line 25 of file line3d.h.

◆ line3d() [3/3]

template<class T >
saga::core::line3d< T >::line3d ( const glm::vec3 &  start,
const glm::vec3 &  end 
)
inline

Constructor with two points as vectors.

Definition at line 27 of file line3d.h.

Member Function Documentation

◆ getClosestPoint()

template<class T >
glm::vec3 saga::core::line3d< T >::getClosestPoint ( const glm::vec3 &  point) const
inline

Get the closest point on this line to a point.

Parameters
pointThe point to compare to.
Returns
The nearest point which is part of the line.

Definition at line 88 of file line3d.h.

◆ getIntersectionWithSphere()

template<class T >
bool saga::core::line3d< T >::getIntersectionWithSphere ( const glm::vec3 &  sorigin,
sradius,
double &  outdistance 
) const
inline

Check if the line intersects with a sphere.

Parameters
soriginOrigin of the sphere.
sradiusRadius of the sphere.
outdistanceThe distance to the first intersection point.
Returns
True if there is an intersection. If there is one, the distance to the first intersection point is stored in outdistance.

Definition at line 112 of file line3d.h.

◆ getLength()

template<class T >
T saga::core::line3d< T >::getLength ( ) const
inline

Get length of line.

Returns
Length of line.

Definition at line 55 of file line3d.h.

◆ getLengthSQ()

template<class T >
T saga::core::line3d< T >::getLengthSQ ( ) const
inline

Get squared length of line.

Returns
Squared length of line.

Definition at line 59 of file line3d.h.

◆ getMiddle()

template<class T >
glm::vec3 saga::core::line3d< T >::getMiddle ( ) const
inline

Get middle of line.

Returns
Center of line.

Definition at line 63 of file line3d.h.

◆ getVector()

template<class T >
glm::vec3 saga::core::line3d< T >::getVector ( ) const
inline

Get vector of line.

Returns
vector of line.

Definition at line 70 of file line3d.h.

◆ isPointBetweenStartAndEnd()

template<class T >
bool saga::core::line3d< T >::isPointBetweenStartAndEnd ( const glm::vec3 &  point) const
inline

Check if the given point is between start and end of the line.

Assumes that the point is already somewhere on the line.

Parameters
pointThe point to test.
Returns
True if point is on the line between start and end, else false.

Definition at line 80 of file line3d.h.

◆ operator!=()

template<class T >
bool saga::core::line3d< T >::operator!= ( const line3d< T > &  other) const
inline

Definition at line 39 of file line3d.h.

◆ operator+()

template<class T >
line3d<T> saga::core::line3d< T >::operator+ ( const glm::vec3 &  point) const
inline

Definition at line 31 of file line3d.h.

◆ operator+=()

template<class T >
line3d<T>& saga::core::line3d< T >::operator+= ( const glm::vec3 &  point)
inline

Definition at line 32 of file line3d.h.

◆ operator-()

template<class T >
line3d<T> saga::core::line3d< T >::operator- ( const glm::vec3 &  point) const
inline

Definition at line 34 of file line3d.h.

◆ operator-=()

template<class T >
line3d<T>& saga::core::line3d< T >::operator-= ( const glm::vec3 &  point)
inline

Definition at line 35 of file line3d.h.

◆ operator==()

template<class T >
bool saga::core::line3d< T >::operator== ( const line3d< T > &  other) const
inline

Definition at line 37 of file line3d.h.

◆ setLine() [1/3]

template<class T >
void saga::core::line3d< T >::setLine ( const glm::vec3 &  nstart,
const glm::vec3 &  nend 
)
inline

Set this line to a new line going through the two points.

Definition at line 47 of file line3d.h.

◆ setLine() [2/3]

template<class T >
void saga::core::line3d< T >::setLine ( const line3d< T > &  line)
inline

Set this line to new line given as parameter.

Definition at line 50 of file line3d.h.

◆ setLine() [3/3]

template<class T >
void saga::core::line3d< T >::setLine ( const T &  xa,
const T &  ya,
const T &  za,
const T &  xb,
const T &  yb,
const T &  zb 
)
inline

Set this line to a new line going through the two points.

Definition at line 44 of file line3d.h.

Member Data Documentation

◆ end

template<class T >
glm::vec3 saga::core::line3d< T >::end

End point of line.

Definition at line 131 of file line3d.h.

◆ start

template<class T >
glm::vec3 saga::core::line3d< T >::start

Start point of line.

Definition at line 129 of file line3d.h.


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