5#ifndef NIRT_LINE_3D_HPP_INCLUDED
6#define NIRT_LINE_3D_HPP_INCLUDED
8#include <nirtcpp/core/engine/nirt_types.hpp>
9#include <nirtcpp/core/engine/vector3d.hpp>
26 line3d(
T xa,
T ya,
T za,
T xb,
T yb,
T zb) :
start(
xa,
ya,
za),
end(
xb,
yb,
zb) {}
33 line3d<T>& operator+=(
const vector3d<T>& point) {
start += point;
end += point;
return *
this; }
35 line3d<T> operator-(
const vector3d<T>& point)
const {
return line3d<T>(
start - point,
end - point); }
36 line3d<T>& operator-=(
const vector3d<T>& point) {
start -= point;
end -= point;
return *
this; }
38 bool operator==(
const line3d<T>& other)
const
39 {
return (
start==other.start &&
end==other.end) || (
end==other.start &&
start==other.end);}
40 bool operator!=(
const line3d<T>& other)
const
41 {
return !(
start==other.start &&
end==other.end) || (
end==other.start &&
start==other.end);}
93 T d = (
T)v.getLength();
95 T t = v.dotProduct(c);
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
3D line between two points with intersection methods.
Definition line3d.hpp:19
T getLengthSQ() const
Get squared length of line.
Definition line3d.hpp:60
vector3d< T > getVector() const
Get vector of line.
Definition line3d.hpp:71
vector3d< T > getMiddle() const
Get middle of line.
Definition line3d.hpp:64
vector3d< T > getClosestPoint(const vector3d< T > &point) const
Get the closest point on this line to a point.
Definition line3d.hpp:89
vector3d< T > start
Start point of line.
Definition line3d.hpp:130
bool isPointBetweenStartAndEnd(const vector3d< T > &point) const
Check if the given point is between start and end of the line.
Definition line3d.hpp:81
vector3d< T > end
End point of line.
Definition line3d.hpp:132
line3d(T xa, T ya, T za, T xb, T yb, T zb)
Constructor with two points.
Definition line3d.hpp:26
void setLine(const line3d< T > &line)
Set this line to new line given as parameter.
Definition line3d.hpp:51
line3d()
Default constructor.
Definition line3d.hpp:24
line3d(const vector3d< T > &start, const vector3d< T > &end)
Constructor with two points as vectors.
Definition line3d.hpp:28
void setLine(const vector3d< T > &nstart, const vector3d< T > &nend)
Set this line to a new line going through the two points.
Definition line3d.hpp:48
T getLength() const
Get length of line.
Definition line3d.hpp:56
bool getIntersectionWithSphere(const vector3d< T > &sorigin, T sradius, f64 &outdistance) const
Check if the line intersects with a sphere.
Definition line3d.hpp:113
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.
Definition line3d.hpp:45
As of Nirtcpp 1.6, position2d is a synonym for vector2d.
Definition vector3d.hpp:11
double f64
64 bit floating point variable.
Definition irrTypes.hpp:114