16 constexpr Vec3(
const double _x,
const double _y,
const double _z) :
x(_x),
y(_y),
z(_z)
31 const double denominator =
length();
44 const double denominator =
length();
45 return {
x / denominator,
y / denominator,
z / denominator};
55 return std::sqrt(
x *
x +
y *
y +
z *
z);
66 return {
y * other.
z -
z * other.
y,
z * other.
x -
x * other.
z,
x * other.
y -
y * other.
x};
71 return x == other.
x &&
y == other.
y &&
z == other.
z;
76 return {
x + other.
x,
y + other.
y,
z + other.
z};
88 return {
x - other.
x,
y - other.
y,
z - other.
z};
98 return x * other.
x +
y * other.
y +
z * other.
z;
103 return {
x * d,
y * d,
z * d};
108 return {
x / d,
y / d,
z / d};
114 return os <<
"Vec3(" << v.
x <<
", " << v.
y <<
", " << v.
z <<
")";
Definition raytracer.cpp:24
std::ostream & operator<<(std::ostream &os, Vec3 const &v)
Definition vec3.h:112
constexpr Vec3 operator/(const double d) const
Definition vec3.h:106
double y
Definition vec3.h:13
constexpr Vec3 operator-(Vec3 const &other) const
Definition vec3.h:86
double length() const
Definition vec3.h:53
constexpr Vec3 cross(Vec3 const &other) const
Definition vec3.h:64
constexpr double operator*(Vec3 const &other) const
Definition vec3.h:96
constexpr Vec3 operator+(Vec3 const &other) const
Definition vec3.h:74
constexpr void operator+=(Vec3 const &other)
Definition vec3.h:79
Vec3 to_normalized() const
Definition vec3.h:42
double z
Definition vec3.h:14
constexpr Vec3 operator-() const
Definition vec3.h:91
constexpr Vec3 operator*(const double d) const
Definition vec3.h:101
double x
Definition vec3.h:12
constexpr Vec3(const double _x, const double _y, const double _z)
Definition vec3.h:16
static const Vec3 ZERO
Definition vec3.h:23
constexpr bool operator==(Vec3 const &other) const
Definition vec3.h:69
void normalize()
Definition vec3.h:29