Nebula
Loading...
Searching...
No Matches
Math::line Class Reference

#include <line.h>

Detailed Description

A line in 3d space.

Public Member Functions

 line ()
 default constructor
 
 line (const point &startPoint, const point &endPoint)
 component constructor
 
 line (const line &rhs)
 copy constructor
 
void set (const point &startPoint, const point &endPoint)
 set start and end point
 
void set_point_dir (const point &startPoint, const vector &direction)
 set start point and direction
 
const pointstart () const
 get start point
 
point end () const
 get end point
 
const vectorvec () const
 get vector
 
scalar length () const
 get length
 
scalar lengthsq () const
 get squared length
 
scalar distance (const point &p) const
 minimal distance of point to line
 
bool intersect (const line &l, point &pa, point &pb) const
 intersect with line
 
scalar distance (const line &l, point &pa, point &pb) const
 calculates shortest distance between lines
 
scalar closestpoint (const point &p) const
 return t of the closest point on the line
 
point pointat (scalar t) const
 return p = b + m*t
 

Public Attributes

point b
 
vector m
 

Constructor & Destructor Documentation

◆ line() [1/3]

Math::line::line ( )
inline

default constructor

◆ line() [2/3]

Math::line::line ( const point & startPoint,
const point & endPoint )
inline

component constructor

◆ line() [3/3]

Math::line::line ( const line & rhs)
inline

copy constructor

Member Function Documentation

◆ closestpoint()

scalar Math::line::closestpoint ( const point & p) const
inline

return t of the closest point on the line

Returns a point on the line which is closest to a another point in space.

This just returns the parameter t on where the point is located. If t is between 0 and 1, the point is on the line, otherwise not. To get the actual 3d point p:

p = m + b*t

◆ distance() [1/2]

Math::scalar Math::line::distance ( const line & l,
point & pa,
point & pb ) const

calculates shortest distance between lines

◆ distance() [2/2]

scalar Math::line::distance ( const point & p) const
inline

minimal distance of point to line

◆ end()

point Math::line::end ( ) const
inline

get end point

◆ intersect()

bool Math::line::intersect ( const line & l,
point & pa,
point & pb ) const

intersect with line

Get line/line intersection.

Returns the shortest line between two lines.

Todo
: Untested! Replace with simpler code.

◆ length()

scalar Math::line::length ( ) const
inline

get length

◆ lengthsq()

scalar Math::line::lengthsq ( ) const
inline

get squared length

◆ pointat()

point Math::line::pointat ( scalar t) const
inline

return p = b + m*t

Returns p = b + m * t, given t.

Note that the point is not on the line if 0.0 > t > 1.0

◆ set()

void Math::line::set ( const point & startPoint,
const point & endPoint )
inline

set start and end point

◆ set_point_dir()

void Math::line::set_point_dir ( const point & startPoint,
const vector & direction )
inline

set start point and direction

◆ start()

const point & Math::line::start ( ) const
inline

get start point

◆ vec()

const vector & Math::line::vec ( ) const
inline

get vector

Member Data Documentation

◆ b

point Math::line::b

◆ m

vector Math::line::m

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