Jimcpp 2.1.0
Jimcpp is a high-performance c++ graphics engine.
Loading...
Searching...
No Matches
jpp::core::line3d< T > Class Template Reference

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

#include <jimcpp/core/engine/line3d.hpp>

Public Member Functions

 line3d ()
 Default constructor.
 
 line3d (T xa, T ya, T za, T xb, T yb, T zb)
 Constructor with two points.
 
 line3d (const vector3d< T > &start, const vector3d< T > &end)
 Constructor with two points as vectors.
 
line3d< Toperator+ (const vector3d< T > &point) const
 
line3d< T > & operator+= (const vector3d< T > &point)
 
line3d< Toperator- (const vector3d< T > &point) const
 
line3d< T > & operator-= (const vector3d< T > &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.
 
void setLine (const vector3d< T > &nstart, const vector3d< T > &nend)
 Set this line to a new line going through the two points.
 
void setLine (const line3d< T > &line)
 Set this line to new line given as parameter.
 
T getLength () const
 Get length of line.
 
T getLengthSQ () const
 Get squared length of line.
 
vector3d< TgetMiddle () const
 Get middle of line.
 
vector3d< TgetVector () const
 Get vector of line.
 
bool isPointBetweenStartAndEnd (const vector3d< T > &point) const
 Check if the given point is between start and end of the line.
 
vector3d< TgetClosestPoint (const vector3d< T > &point) const
 Get the closest point on this line to a point.
 
bool getIntersectionWithSphere (const vector3d< T > &sorigin, T sradius, f64 &outdistance) const
 Check if the line intersects with a sphere.
 

Public Attributes

vector3d< Tstart
 Start point of line.
 
vector3d< Tend
 End point of line.
 

Detailed Description

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

3D line between two points with intersection methods.

Constructor & Destructor Documentation

◆ line3d()

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

Default constructor.

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

Member Function Documentation

◆ getClosestPoint()

template<class T >
vector3d< T > jpp::core::line3d< T >::getClosestPoint ( const vector3d< T > &  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.

◆ getIntersectionWithSphere()

template<class T >
bool jpp::core::line3d< T >::getIntersectionWithSphere ( const vector3d< T > &  sorigin,
T  sradius,
f64 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.

◆ getLength()

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

Get length of line.

Returns
Length of line.

◆ getLengthSQ()

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

Get squared length of line.

Returns
Squared length of line.

◆ getMiddle()

template<class T >
vector3d< T > jpp::core::line3d< T >::getMiddle ( ) const
inline

Get middle of line.

Returns
Center of line.

◆ getVector()

template<class T >
vector3d< T > jpp::core::line3d< T >::getVector ( ) const
inline

Get vector of line.

Returns
vector of line.

◆ isPointBetweenStartAndEnd()

template<class T >
bool jpp::core::line3d< T >::isPointBetweenStartAndEnd ( const vector3d< T > &  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.

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

Jimcpp    @cppfx.xyz

K