raytracer
Parallel Ray Tracer written from scratch (no graphics API).
Loading...
Searching...
No Matches
raytracer::common::Vec3 Struct Reference

#include <vec3.h>

Collaboration diagram for raytracer::common::Vec3:

Public Member Functions

constexpr Vec3 (const double _x, const double _y, const double _z)
void normalize ()
Vec3 to_normalized () const
double length () const
constexpr Vec3 cross (Vec3 const &other) const
constexpr bool operator== (Vec3 const &other) const
constexpr Vec3 operator+ (Vec3 const &other) const
constexpr void operator+= (Vec3 const &other)
constexpr Vec3 operator- (Vec3 const &other) const
constexpr Vec3 operator- () const
constexpr double operator* (Vec3 const &other) const
constexpr Vec3 operator* (const double d) const
constexpr Vec3 operator/ (const double d) const

Public Attributes

double x
double y
double z

Static Public Attributes

static const Vec3 ZERO = {0, 0, 0}

Detailed Description

A 3D vector, used for directions, positions in 3D space, and colors

Constructor & Destructor Documentation

◆ Vec3()

raytracer::common::Vec3::Vec3 ( const double _x,
const double _y,
const double _z )
inlineconstexpr
Here is the caller graph for this function:

Member Function Documentation

◆ cross()

Vec3 raytracer::common::Vec3::cross ( Vec3 const & other) const
inlinenodiscardconstexpr

Returns the cross product between this vector and the vector passed as a parameter.

Parameters
otherThe vector with which to compute the cross product.
Returns
The cross product between this vector and the vector passed as a parameter.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ length()

double raytracer::common::Vec3::length ( ) const
inlinenodiscard

Returns the length of the vector, which is equal to the square root of its squared dimensions.

Returns
The length of the vector, which is equal to the square root of its squared dimensions.
Here is the caller graph for this function:

◆ normalize()

void raytracer::common::Vec3::normalize ( )
inline

Normalizes the current vector in-place by dividing its dimension by its length, making the length one while keeping the ratios between the dimensions.

Here is the call graph for this function:

◆ operator*() [1/2]

Vec3 raytracer::common::Vec3::operator* ( const double d) const
inlineconstexpr
Here is the call graph for this function:

◆ operator*() [2/2]

double raytracer::common::Vec3::operator* ( Vec3 const & other) const
inlineconstexpr
Here is the call graph for this function:

◆ operator+()

Vec3 raytracer::common::Vec3::operator+ ( Vec3 const & other) const
inlineconstexpr
Here is the call graph for this function:

◆ operator+=()

void raytracer::common::Vec3::operator+= ( Vec3 const & other)
inlineconstexpr
Here is the call graph for this function:

◆ operator-() [1/2]

Vec3 raytracer::common::Vec3::operator- ( ) const
inlineconstexpr
Here is the call graph for this function:

◆ operator-() [2/2]

Vec3 raytracer::common::Vec3::operator- ( Vec3 const & other) const
inlineconstexpr
Here is the call graph for this function:

◆ operator/()

Vec3 raytracer::common::Vec3::operator/ ( const double d) const
inlineconstexpr
Here is the call graph for this function:

◆ operator==()

bool raytracer::common::Vec3::operator== ( Vec3 const & other) const
inlineconstexpr
Here is the call graph for this function:

◆ to_normalized()

Vec3 raytracer::common::Vec3::to_normalized ( ) const
inlinenodiscard

Returns a normalized instance of the current vector, without modifying it.

Returns
A normalized instance of the current vector.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ x

double raytracer::common::Vec3::x

◆ y

double raytracer::common::Vec3::y

◆ z

double raytracer::common::Vec3::z

◆ ZERO

Vec3 raytracer::common::Vec3::ZERO = {0, 0, 0}
inlinestaticconstexpr

The zero vector.


The documentation for this struct was generated from the following file:
  • common/include/common/util/vec3.h