Class Ray#
Defined in File Ray.h
Class Documentation#
-
class Ray#
Represents a 3D ray with an origin and direction.
It is not required or checked that the direction has unit norm.
Public Functions
-
Ray()#
No argument constructor.
Initializes direction to notReadyNaN and origin to zero.
-
Ray(ConstVec3Slice direction, ConstVec3Slice origin = Vec3{0, 0, 0})#
Constructor from a pair of 3-vectors.
- Parameters:
direction – Direction of the ray
origin – Origin of the ray
-
Ray &operator=(const Ray &other)#
Copy assignment operator.
- Parameters:
other – The Ray to assign from.
- Returns:
Reference to this object.
-
Ray &operator=(Ray &&other) noexcept#
Move assignment operator.
- Parameters:
other – The Ray to move from.
- Returns:
Reference to this object.
-
bool operator==(const Ray &other) const#
Equality operator.
- Parameters:
other – Another Ray to compare with.
- Returns:
True if both components are equal.
-
bool isApprox(const Ray &other, double prec = MATH_EPSILON) const#
Check if another ray is approximately equal within precision.
- Parameters:
other – The Ray to compare to this one.
prec – Precision tolerance.
- Returns:
True if approximately equal.
-
const Vec3 &getDirection() const#
Get the direction of the ray.
- Returns:
Const reference to the ray direction.
-
void setDirection(ConstVec3Slice direction)#
Set the direction of the ray.
- Parameters:
direction – New direction.
-
const Vec3 &getOrigin() const#
Get the origin of the ray.
- Returns:
Const reference to the ray origin.
-
void setOrigin(ConstVec3Slice origin)#
Set the origin of the ray.
- Parameters:
origin – New origin.
-
std::string_view typeString() const#
Return object type as a string.
- Returns:
String “Ray”.
-
std::string dumpString(std::string_view prefix = "", unsigned int precision = 10, DumpFormatType format_type = DumpFormatType::DEFAULT_FLOAT, bool skip_new_line = false) const#
Dump the object as a formatted string.
- Parameters:
prefix – Optional prefix for each line.
precision – Number of digits to use for floating point values.
format_type – The format type to use.
skip_new_line – If true, do not add a new line at the end.
- Returns:
Formatted string representation.
-
void dump(std::string_view prefix = "", unsigned int precision = 10, DumpFormatType format_type = DumpFormatType::DEFAULT_FLOAT) const#
Write dumpString to standard output.
- Parameters:
prefix – Optional prefix for each line.
precision – Number of digits to use for floating point values.
format_type – The format type to use.
-
void makeNotReady()#
Mark the ray as not ready.
-
bool isReady() const#
Check if the ray is initialized.
- Returns:
True if both direction and origin are initialized.
-
Ray()#