Nazara Engine
0.4
A fast, complete, cross-platform API designed for game development
|
Math class that represents a ray or a straight line in 3D space. More...
Public Member Functions | |
Ray (T X, T Y, T Z, T directionX, T directionY, T directionZ) | |
Constructs a Ray object from its position and direction. More... | |
Ray (const Vector3< T > &origin, const Vector3< T > &direction) | |
Constructs a Ray object from two Vector3. More... | |
Ray (const T origin[3], const T direction[3]) | |
Constructs a Ray object from two arrays of three elements. More... | |
Ray (const Plane< T > &planeOne, const Plane< T > &planeTwo) | |
Constructs a Ray object from the intersection of two planes. More... | |
template<typename U > | |
Ray (const Ray< U > &ray) | |
Constructs a Ray object from another type of Ray. More... | |
template<typename U > | |
Ray (const Vector3< U > &origin, const Vector3< U > &direction) | |
Constructs a Ray object from two Vector3 from another type of Ray. More... | |
Ray (const Ray< T > &ray)=default | |
T | ClosestPoint (const Vector3< T > &point) const |
Finds the closest point of the ray from point. More... | |
Vector3< T > | GetPoint (T lambda) const |
Gets the point along the ray for this parameter. More... | |
bool | Intersect (const BoundingVolume< T > &volume, T *closestHit=nullptr, T *furthestHit=nullptr) const |
Checks whether or not this ray intersects with the BoundingVolume. More... | |
bool | Intersect (const Box< T > &box, T *closestHit=nullptr, T *furthestHit=nullptr) const |
Checks whether or not this ray intersects with the Box. More... | |
bool | Intersect (const Box< T > &box, const Matrix4< T > &transform, T *closestHit=nullptr, T *furthestHit=nullptr) const |
Checks whether or not this ray intersects with the transform Matrix4 applied to the Box. More... | |
bool | Intersect (const OrientedBox< T > &orientedBox, T *closestHit=nullptr, T *furthestHit=nullptr) const |
Checks whether or not this ray intersects with the OrientedBox. More... | |
bool | Intersect (const Plane< T > &plane, T *hit=nullptr) const |
Checks whether or not this ray intersects with the plane. More... | |
bool | Intersect (const Sphere< T > &sphere, T *closestHit=nullptr, T *furthestHit=nullptr) const |
Checks whether or not this ray intersects with the sphere. More... | |
bool | Intersect (const Vector3< T > &firstPoint, const Vector3< T > &secondPoint, const Vector3< T > &thirdPoint, T *hit=nullptr) const |
Checks whether or not this ray intersects with the triangle. More... | |
Ray & | MakeAxisX () |
Makes the ray with position (0, 0, 0) and direction (1, 0, 0) More... | |
Ray & | MakeAxisY () |
Makes the ray with position (0, 0, 0) and direction (0, 1, 0) More... | |
Ray & | MakeAxisZ () |
Makes the ray with position (0, 0, 0) and direction (0, 0, 1) More... | |
Ray & | Set (T X, T Y, T Z, T directionX, T directionY, T directionZ) |
Sets the components of the ray with position and direction. More... | |
Ray & | Set (const Vector3< T > &origin, const Vector3< T > &direction) |
Sets the components of the ray with position and direction. More... | |
Ray & | Set (const T origin[3], const T direction[3]) |
Sets the components of this ray from two arrays of three elements. More... | |
Ray & | Set (const Plane< T > &planeOne, const Plane< T > &planeTwo) |
Sets the components of this ray from the intersection of two planes. More... | |
Ray & | Set (const Ray &ray) |
Sets the components of the ray with components from another. More... | |
template<typename U > | |
Ray & | Set (const Ray< U > &ray) |
template<typename U > | |
Ray & | Set (const Vector3< U > &origin, const Vector3< U > &direction) |
String | ToString () const |
Gives a string representation. More... | |
Vector3< T > | operator* (T lambda) const |
Multiplies the direction ray with the lambda to get the point along the ray for this parameter. More... | |
Ray & | operator= (const Ray &other)=default |
bool | operator== (const Ray &ray) const |
Compares the ray to other one. More... | |
bool | operator!= (const Ray &ray) const |
Compares the ray to other one. More... | |
template<typename U > | |
Ray< T > & | Set (const Ray< U > &ray) |
Sets the components of the ray from another type of Ray. More... | |
template<typename U > | |
Ray< T > & | Set (const Vector3< U > &Origin, const Vector3< U > &Direction) |
Sets the components of the ray from another type of Ray. More... | |
Static Public Member Functions | |
static Ray | AxisX () |
Shorthand for the ray (0, 0, 0), (1, 0, 0) More... | |
static Ray | AxisY () |
Shorthand for the ray (0, 0, 0), (0, 1, 0) More... | |
static Ray | AxisZ () |
Shorthand for the ray (0, 0, 0), (0, 0, 1) More... | |
static Ray | Lerp (const Ray &from, const Ray &to, T interpolation) |
Interpolates the ray to other one with a factor of interpolation. More... | |
Public Attributes | |
Vector3< T > | direction |
Vector3< T > | origin |
Math class that represents a ray or a straight line in 3D space.
This ray is meant to be understood like origin + lambda * direction, where lambda is a real positive parameter
Constructs a Ray object from its position and direction.
X | X position |
Y | Y position |
Z | Z position |
DirectionX | X component of the vector direction |
DirectionY | Y component of the vector direction |
DirectionY | Y component of the vector direction |
Constructs a Ray object from two arrays of three elements.
Origin[3] | Origin[0] is X position, Origin[1] is Y position and Origin[2] is Z position |
Direction[3] | Direction[0] is X direction, Direction[1] is Y direction and Direction[2] is Z direction |
Nz::Ray< T >::Ray | ( | const Plane< T > & | planeOne, |
const Plane< T > & | planeTwo | ||
) |
Constructs a Ray object from the intersection of two planes.
planeOne | First plane |
planeTwo | Second secant plane |
std::domain_error | if NAZARA_MATH_SAFE is defined and planes are parallel |
Shorthand for the ray (0, 0, 0), (1, 0, 0)
Shorthand for the ray (0, 0, 0), (0, 1, 0)
Shorthand for the ray (0, 0, 0), (0, 0, 1)
Finds the closest point of the ray from point.
point | The point to get the closest approach to |
Gets the point along the ray for this parameter.
lambda | Parameter to obtain a particular point on the ray |
bool Nz::Ray< T >::Intersect | ( | const BoundingVolume< T > & | volume, |
T * | closestHit = nullptr , |
||
T * | furthestHit = nullptr |
||
) | const |
Checks whether or not this ray intersects with the BoundingVolume.
volume | BoundingVolume to check |
closestHit | Optional argument to get the closest parameter where the intersection is only if it happened |
furthestHit | Optional argument to get the furthest parameter where the intersection is only if it happened |
bool Nz::Ray< T >::Intersect | ( | const Box< T > & | box, |
T * | closestHit = nullptr , |
||
T * | furthestHit = nullptr |
||
) | const |
Checks whether or not this ray intersects with the Box.
box | Box to check |
closestHit | Optional argument to get the closest parameter where the intersection is only if it happened |
furthestHit | Optional argument to get the furthest parameter where the intersection is only if it happened |
bool Nz::Ray< T >::Intersect | ( | const Box< T > & | box, |
const Matrix4< T > & | transform, | ||
T * | closestHit = nullptr , |
||
T * | furthestHit = nullptr |
||
) | const |
Checks whether or not this ray intersects with the transform Matrix4 applied to the Box.
box | Box to check |
transform | Matrix4 which represents the transformation of the box |
closestHit | Optional argument to get the closest parameter where the intersection is only if it happened |
furthestHit | Optional argument to get the furthest parameter where the intersection is only if it happened |
bool Nz::Ray< T >::Intersect | ( | const OrientedBox< T > & | orientedBox, |
T * | closestHit = nullptr , |
||
T * | furthestHit = nullptr |
||
) | const |
Checks whether or not this ray intersects with the OrientedBox.
orientedBox | OrientedBox to check |
closestHit | Optional argument to get the closest parameter where the intersection is only if it happened |
furthestHit | Optional argument to get the furthest parameter where the intersection is only if it happened |
bool Nz::Ray< T >::Intersect | ( | const Sphere< T > & | sphere, |
T * | closestHit = nullptr , |
||
T * | furthestHit = nullptr |
||
) | const |
Checks whether or not this ray intersects with the sphere.
sphere | Sphere to check |
closestHit | Optional argument to get the closest parameter where the intersection is only if it happened |
furthestHit | Optional argument to get the furthest parameter where the intersection is only if it happened |
bool Nz::Ray< T >::Intersect | ( | const Vector3< T > & | firstPoint, |
const Vector3< T > & | secondPoint, | ||
const Vector3< T > & | thirdPoint, | ||
T * | hit = nullptr |
||
) | const |
Checks whether or not this ray intersects with the triangle.
firstPoint | First vertex of the triangle |
secondPoint | Second vertex of the triangle |
thirdPoint | Third vertex of the triangle |
hit | Optional argument to get the parameter where the intersection is only if it happened |
|
static |
Interpolates the ray to other one with a factor of interpolation.
from | Initial ray |
to | Target ray |
interpolation | Factor of interpolation |
Makes the ray with position (0, 0, 0) and direction (1, 0, 0)
Makes the ray with position (0, 0, 0) and direction (0, 1, 0)
Makes the ray with position (0, 0, 0) and direction (0, 0, 1)
Compares the ray to other one.
rec | Other ray to compare with |
Multiplies the direction ray with the lambda to get the point along the ray for this parameter.
lambda | Parameter to obtain a particular point on the ray |
Compares the ray to other one.
rec | Other ray to compare with |
Ray< T > & Nz::Ray< T >::Set | ( | T | X, |
T | Y, | ||
T | Z, | ||
T | directionX, | ||
T | directionY, | ||
T | directionZ | ||
) |
Sets the components of the ray with position and direction.
X | X position |
Y | Y position |
Z | Z position |
DirectionX | X component of the vector direction |
DirectionY | Y component of the vector direction |
DirectionY | Y component of the vector direction |
Ray< T > & Nz::Ray< T >::Set | ( | const Vector3< T > & | Origin, |
const Vector3< T > & | Direction | ||
) |
Sets the components of the ray with position and direction.
Origin | Vector which represents the origin of the ray |
Direction | Vector which represents the direction of the ray |
Sets the components of this ray from two arrays of three elements.
Origin[3] | Origin[0] is X position, Origin[1] is Y position and Origin[2] is Z position |
Direction[3] | Direction[0] is X direction, Direction[1] is Y direction and Direction[2] is Z direction |
Ray< T > & Nz::Ray< T >::Set | ( | const Plane< T > & | planeOne, |
const Plane< T > & | planeTwo | ||
) |
Sets the components of this ray from the intersection of two planes.
planeOne | First plane |
planeTwo | Second secant plane |
std::domain_error | if NAZARA_MATH_SAFE is defined and planes are parallel |
Sets the components of the ray with components from another.
ray | The other ray |
Ray<T>& Nz::Ray< T >::Set | ( | const Vector3< U > & | Origin, |
const Vector3< U > & | Direction | ||
) |
Sets the components of the ray from another type of Ray.
Origin | Origin of type U to convert to type T |
Direction | Direction of type U to convert to type T |
Gives a string representation.