1#include "primitives/BufferAttribute.hpp"
40 bufferAttribute.
array.at(index * bufferAttribute.
itemSize + 1),
41 bufferAttribute.
array.at(index * bufferAttribute.
itemSize + 2));
55 a.
x * b.
y - b.
x * a.
y);
68 return a.
x * b.
x + a.
y * b.
y + a.
z * b.
z;
84 const Vector3 &surfaceOrientation) {
86 2.0 *
dot(surfaceOrientation, incident) * surfaceOrientation;
96 Vector3(
double _x,
double _y,
double _z) :
x(_x),
y(_y),
z(_z) {}
172 return Vector3(std::abs(
x), std::abs(
y), std::abs(
z));
200 x = std::clamp(
x, min.
x, max.
x);
201 y = std::clamp(
y, min.
y, max.
y);
202 z = std::clamp(
z, min.
z, max.
z);
216 x = std::clamp(
x, min, max);
217 y = std::clamp(
y, min, max);
218 z = std::clamp(
z, min, max);
239 throw std::invalid_argument(
"Index to Vector3 must be 0, 1, or 2.");
A class representing attributes, such as vertex positions, face indices, and vertex normals.
Definition BufferAttribute.hpp:27
int itemSize
The number of values of the array that are associated with a particular vertex e.g.
Definition BufferAttribute.hpp:31
std::vector< BufferType > array
The array holding the data of the attribute.
Definition BufferAttribute.hpp:30
The 3D vector class.
Definition Vector3.hpp:20
Vector3 & operator/=(const Vector3 &v)
Divides the components of this vector by the corresponding components of another 3D vector.
Definition Vector3.hpp:338
double length() const
Returns the length of this 3D vector.
Definition Vector3.hpp:142
friend bool operator==(const Vector3 &a, const Vector3 &b)=default
Returns whether if two 3D vectors are equal.
friend Vector3 operator-(const Vector3 &a)
Returns the negation of this 3D vector.
Definition Vector3.hpp:372
Vector3 clone() const
Returns a copy of this 3D vector.
Definition Vector3.hpp:103
friend Vector3 operator+(const Vector3 &a, const Vector3 &b)
Adds two 3D vectors.
Definition Vector3.hpp:381
friend Vector3 operator-(double s, const Vector3 &a)
Subtracts a 3D vector from a constant 3D vector.
Definition Vector3.hpp:438
friend Vector3 operator/(double s, const Vector3 &a)
Returns the element-wise division of a constant 3D vector and a 3D vector.
Definition Vector3.hpp:508
Vector3 absolute() const
Returns a new 3D vector with the absolute values of the components of this 3D vector.
Definition Vector3.hpp:171
friend Vector3 operator-(const Vector3 &a, const Vector3 &b)
Subtracts two 3D vectors.
Definition Vector3.hpp:412
friend Vector3 operator+(const Vector3 &a, double s)
Adds a constant to all components of a 3D vector.
Definition Vector3.hpp:392
static double dot(const Vector3 &a, const Vector3 &b)
Returns the dot product of two vectors.
Definition Vector3.hpp:67
static Vector3 cross(const Vector3 &a, const Vector3 &b)
Returns the cross product of two vectors.
Definition Vector3.hpp:53
double z
The z component of this 3D vector.
Definition Vector3.hpp:24
Vector3 & clamp(double min, double max)
Clamps the components of this 3D vector to the specified minimum and maximum values.
Definition Vector3.hpp:215
Vector3 & operator+=(const Vector3 &v)
Adds the specified 3D vector to this vector.
Definition Vector3.hpp:249
Vector3 & operator/=(double s)
Divides the components of this 3D vector by the specified constant.
Definition Vector3.hpp:352
friend Vector3 operator/(const Vector3 &a, const Vector3 &b)
Returns the element-wise division of two 3D vectors.
Definition Vector3.hpp:484
Vector3 & clamp(const Vector3 &min, const Vector3 &max)
Clamps the components of this 3D vector to the specified minimum and maximum 3D vectors component-wis...
Definition Vector3.hpp:199
Vector3 & normalize()
Normalizes this 3D vector.
Definition Vector3.hpp:159
friend Vector3 operator*(const Vector3 &a, double s)
Multiplies all components of a 3D vector with a constant.
Definition Vector3.hpp:463
Vector3 & operator-=(double s)
Subtracts the specified constant from all components in this 3D vector.
Definition Vector3.hpp:291
Vector3 & abs()
Sets the components of this 3D vector to their absolute values.
Definition Vector3.hpp:183
double y
The y component of this 3D vector.
Definition Vector3.hpp:23
Vector3 & operator-=(const Vector3 &v)
Subtracts the specified 3D vector from this vector.
Definition Vector3.hpp:277
friend Vector3 operator*(const Vector3 &a, const Vector3 &b)
Returns the element-wise product of two 3D vectors, also known as the Hadamard product.
Definition Vector3.hpp:451
friend Vector3 operator/(const Vector3 &a, double s)
Divides the components of a 3D vector by a constant.
Definition Vector3.hpp:495
static Vector3 reflect(const Vector3 &incident, const Vector3 &surfaceOrientation)
Returns the reflection of an incident vector off a surface that has the specified orientation.
Definition Vector3.hpp:83
Vector3 unit() const
Returns the unit vector of this 3D vector.
Definition Vector3.hpp:149
Vector3 & operator+=(double s)
Adds the specified constant to all components in this 3D vector.
Definition Vector3.hpp:263
Vector3 & set(double _x, double _y, double _z)
Sets the components of this vector.
Definition Vector3.hpp:126
double x
The x component of this 3D vector.
Definition Vector3.hpp:22
Vector3 & operator*=(const Vector3 &v)
Multiplies the components of this vector with the corresponding components of the specified 3D vector...
Definition Vector3.hpp:309
friend Vector3 operator*(double s, const Vector3 &a)
Multiplies all components of a 3D vector with a constant.
Definition Vector3.hpp:475
static Vector3 fromBufferAttribute(const BufferAttribute< double > &bufferAttribute, int index)
Returns 3 consecutive values at the specified index in a BufferAttribute at the specified in a Vector...
Definition Vector3.hpp:36
Vector3 & copy(const Vector3 &source)
Copies the components of the specified 3D vector to this 3D vector.
Definition Vector3.hpp:111
friend Vector3 operator+(double s, const Vector3 &a)
Adds a constant to all components of a 3D vector.
Definition Vector3.hpp:403
Vector3 & operator*=(double s)
Multiplies all components of this 3D vector with the specified constant.
Definition Vector3.hpp:323
Vector3(double _x, double _y, double _z)
Creates a new 3D vector with the specified components.
Definition Vector3.hpp:96
double operator[](std::size_t index) const
Returns the component at the specified index of this 3D vector.
Definition Vector3.hpp:230
friend Vector3 operator-(const Vector3 &a, double s)
Subtracts a constant from all components of a 3D vector.
Definition Vector3.hpp:424
The t software 3D graphics library namespace.
Definition algorithms.hpp:12