6 #ifndef MATERIALX_TYPES_H
7 #define MATERIALX_TYPES_H
58 using Iterator =
typename std::array<S, N>::iterator;
66 explicit VectorN(
const vector<S>& vec) { std::copy(vec.begin(), vec.end(),
_arr.begin()); }
81 return _arr < rhs._arr;
102 for (
size_t i = 0; i <
N; i++)
103 res[i] =
_arr[i] + rhs[i];
110 for (
size_t i = 0; i <
N; i++)
112 return *
static_cast<V*
>(
this);
119 for (
size_t i = 0; i <
N; i++)
120 res[i] =
_arr[i] - rhs[i];
127 for (
size_t i = 0; i <
N; i++)
129 return *
static_cast<V*
>(
this);
136 for (
size_t i = 0; i <
N; i++)
137 res[i] =
_arr[i] * rhs[i];
144 for (
size_t i = 0; i <
N; i++)
146 return *
static_cast<V*
>(
this);
153 for (
size_t i = 0; i <
N; i++)
154 res[i] =
_arr[i] / rhs[i];
161 for (
size_t i = 0; i <
N; i++)
163 return *
static_cast<V*
>(
this);
170 for (
size_t i = 0; i <
N; i++)
171 res[i] =
_arr[i] * s;
178 for (
size_t i = 0; i <
N; i++)
180 return *
static_cast<V*
>(
this);
187 for (
size_t i = 0; i <
N; i++)
188 res[i] =
_arr[i] / s;
195 for (
size_t i = 0; i <
N; i++)
197 return *
static_cast<V*
>(
this);
204 for (
size_t i = 0; i <
N; i++)
213 for (
size_t i = 0; i <
N; i++)
226 for (
size_t i = 0; i <
N; i++)
241 for (
size_t i = 0; i <
N; i++)
242 res +=
_arr[i] * rhs[i];
273 for (
size_t i = 0; i <
N; i++)
308 return _arr[0] * rhs[1] - _arr[1] * rhs[0];
328 return Vector3(_arr[1] * rhs[2] - _arr[2] * rhs[1],
329 _arr[2] * rhs[0] - _arr[0] * rhs[2],
330 _arr[0] * rhs[1] - _arr[1] * rhs[0]);
344 _arr = {
x,
y,
z,
w };
363 Color3 linearToSrgb()
const;
367 Color3 srgbToLinear()
const;
380 _arr = {
r,
g,
b,
a };
399 using Iterator =
typename std::array<RowArray, N>::iterator;
421 for (
size_t i = 0; i <
N; i++)
423 for (
size_t j = 0;
j <
N;
j++)
452 for (
size_t i = 0; i <
N; i++)
453 for (
size_t j = 0;
j <
N;
j++)
454 res[i][
j] =
_arr[i][
j] + rhs[i][
j];
462 return *
static_cast<M*
>(
this);
469 for (
size_t i = 0; i <
N; i++)
470 for (
size_t j = 0;
j <
N;
j++)
471 res[i][
j] =
_arr[i][
j] - rhs[i][
j];
479 return *
static_cast<M*
>(
this);
486 for (
size_t i = 0; i <
N; i++)
487 for (
size_t j = 0;
j <
N;
j++)
488 res[i][
j] =
_arr[i][
j] * s;
496 return *
static_cast<M*
>(
this);
503 for (
size_t i = 0; i <
N; i++)
504 for (
size_t j = 0;
j <
N;
j++)
505 res[i][
j] =
_arr[i][
j] / s;
513 return *
static_cast<M*
>(
this);
524 for (
size_t i = 0; i <
N; i++)
525 for (
size_t j = 0;
j <
N;
j++)
526 for (
size_t k = 0; k <
N; k++)
527 res[i][
j] +=
_arr[i][k] * rhs[k][
j];
535 return *
static_cast<M*
>(
this);
550 return *
static_cast<M*
>(
this);
557 for (
size_t i = 0; i <
N; i++)
558 for (
size_t j = 0;
j <
N;
j++)
567 for (
size_t i = 0; i <
N; i++)
568 for (
size_t j = 0;
j <
N;
j++)
620 float m10,
float m11,
float m12,
621 float m20,
float m21,
float m22) :
624 _arr = { RowArray{ m00, m01, m02 },
625 RowArray{ m10, m11, m12 },
626 RowArray{ m20, m21, m22 } };
636 float getDeterminant()
const;
644 return getAdjugate() / getDeterminant();
689 Matrix44(
float m00,
float m01,
float m02,
float m03,
690 float m10,
float m11,
float m12,
float m13,
691 float m20,
float m21,
float m22,
float m23,
692 float m30,
float m31,
float m32,
float m33) :
695 _arr = { RowArray{ m00, m01, m02, m03 },
696 RowArray{ m10, m11, m12, m13 },
697 RowArray{ m20, m21, m22, m23 },
698 RowArray{ m30, m31, m32, m33 } };
708 float getDeterminant()
const;
716 return getAdjugate() / getDeterminant();
V operator+() const
Unary plus of a vector. Returns the unaltered vector.
MX_CORE_API const string ARRAY_PREFERRED_SEPARATOR
V & operator*=(S s)
Component-wise multiplication of a vector by a scalar.
M operator+() const
Unary plus of a matrix.
V operator+(const V &rhs) const
Component-wise addition of two vectors.
MX_CORE_API const string VALUE_STRING_TRUE
M & operator+=(const M &rhs)
Component-wise addition of two matrices.
S getMagnitude() const
Return the magnitude of the vector.
M operator+(const M &rhs) const
Component-wise addition of two matrices.
MX_CORE_API const string NONE_TYPE_STRING
bool isEquivalent(const M &rhs, S tolerance) const
UT_Vector4T< Float > Vector4
MatrixN(const S *begin, const S *end)
M operator/(S s) const
Component-wise division of a matrix by a scalar.
V & operator/=(S s)
Component-wise division of a vector by a scalar.
M operator*(S s) const
Component-wise multiplication of a matrix and a scalar.
V getNormalized() const
Return a normalized vector.
SIM_API const UT_StringHolder angle
#define MATERIALX_NAMESPACE_BEGIN
MX_CORE_API const string VDF_TYPE_STRING
MX_CORE_API const string LIGHT_SHADER_TYPE_STRING
typename std::array< float, N >::const_iterator ConstIterator
MX_CORE_API const string FILENAME_TYPE_STRING
M operator-(const M &rhs) const
Component-wise subtraction of two matrices.
vfloat4 sqrt(const vfloat4 &a)
GLdouble GLdouble GLdouble z
GLboolean GLboolean GLboolean GLboolean a
MX_CORE_API const string VOLUME_SHADER_TYPE_STRING
const S * data() const
Return a const pointer to the underlying data array.
Color4(float r, float g, float b, float a)
ConstIterator end() const
FMT_CONSTEXPR auto fill_n(OutputIt out, Size count, const T &value) -> OutputIt
bool operator==(const M &rhs) const
Return true if the given matrix is identical to this one.
VectorN(const vector< S > &vec)
The base class for square matrices of scalar values.
MX_CORE_API const string EDF_TYPE_STRING
const S & operator[](size_t i) const
Return the const scalar value at the given index.
bool operator!=(const V &rhs) const
Return true if the given vector differs from this one.
V operator*(S s) const
Component-wise multiplication of a vector by a scalar.
static constexpr size_t numRows()
Return the number of rows in this matrix.
bool operator<(const V &rhs) const
Compare two vectors lexicographically.
A tag class for constructing vectors and matrices without initialization.
MX_CORE_API const string VOLUME_MATERIAL_NODE_STRING
VectorN(const S *begin, const S *end)
typename std::array< float, N >::iterator Iterator
V operator-(const V &rhs) const
Component-wise subtraction of two vectors.
ConstIterator begin() const
static constexpr size_t numElements()
Return the number of scalar elements for the vector.
V & operator+=(const V &rhs)
Component-wise addition of two vectors.
The base class for vectors of scalar values.
MX_CORE_API const string GEOMNAME_TYPE_STRING
Matrix44 getInverse() const
Return the inverse of the matrix.
bool operator!=(const M &rhs) const
Return true if the given matrix differs from this one.
MX_CORE_API const string MULTI_OUTPUT_TYPE_STRING
M & operator/=(const M &rhs)
Vector3 cross(const Vector3 &rhs) const
Return the cross product of two vectors.
void hashCombine(size_t &seed, const T &value)
Combine the hash of a value with an existing seed.
MX_CORE_API const string NAME_PREFIX_SEPARATOR
S * data()
Return a pointer to the underlying data array.
std::array< RowArray, N > _arr
Matrix44(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
Vector3(float x, float y, float z)
M & operator*=(S s)
Component-wise multiplication of a matrix and a scalar.
ConstIterator begin() const
GLboolean GLboolean GLboolean b
V operator/(S s) const
Component-wise division of a vector by a scalar.
bool operator==(const V &rhs) const
Return true if the given vector is identical to this one.
float cross(const Vector2 &rhs) const
Return the cross product of two vectors.
static constexpr size_t numColumns()
Return the number of columns in this matrix.
typename std::array< RowArray, N >::iterator Iterator
MX_CORE_API const string MATERIAL_TYPE_STRING
MX_CORE_API const string BSDF_TYPE_STRING
VectorN(const std::array< S, N > &arr)
MX_CORE_API const string STRING_TYPE_STRING
V & operator/=(const V &rhs)
Component-wise division of two vectors.
RowArray & operator[](size_t i)
Return the row array at the given index.
S & operator[](size_t i)
Return the scalar value at the given index.
GLfloat GLfloat GLfloat GLfloat h
MATERIALX_NAMESPACE_BEGIN MX_CORE_API const string DEFAULT_TYPE_STRING
size_t operator()(const V &v) const noexcept
V & operator*=(const V &rhs)
Component-wise multiplication of two vectors.
S * data()
Return a pointer to the underlying data array.
UT_Vector2T< Float > Vector2
M operator/(const M &rhs) const
MX_CORE_API const string SURFACE_SHADER_TYPE_STRING
MX_CORE_API const string DISPLACEMENT_SHADER_TYPE_STRING
Vector2(float x, float y)
Vec3< T1 > transformNormal(const Mat4< T0 > &m, const Vec3< T1 > &n)
ConstIterator end() const
S dot(const V &rhs) const
Return the dot product of two vectors.
GA_API const UT_StringHolder N
V & operator-=(const V &rhs)
Component-wise subtraction of two vectors.
Color3(float r, float g, float b)
V operator-() const
Unary negation of a vector.
MX_CORE_API const string NAME_PATH_SEPARATOR
MX_CORE_API const string SURFACE_MATERIAL_NODE_STRING
M & operator-=(const M &rhs)
Component-wise subtraction of two matrices.
V operator*(const V &rhs) const
Component-wise multiplication of two vectors.
const S * data() const
Return a const pointer to the underlying data array.
static const Matrix33 IDENTITY
GLubyte GLubyte GLubyte GLubyte w
MX_CORE_API const string ARRAY_VALID_SEPARATORS
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER IMATH_HOSTDEVICE constexpr T abs(T a) IMATH_NOEXCEPT
Vector4(float x, float y, float z, float w)
#define MATERIALX_NAMESPACE_END
static const Matrix44 IDENTITY
M operator*(const M &rhs) const
Compute the matrix product.
M & operator*=(const M &rhs)
Compute the matrix product.
UT_Vector3T< Float > Vector3
Matrix33(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
typename std::array< RowArray, N >::const_iterator ConstIterator
V operator/(const V &rhs) const
Component-wise division of two vectors.
const RowArray & operator[](size_t i) const
Return the const row array at the given index.
typename std::array< float, N > RowArray
M operator-() const
Unary negation of a matrix.
Matrix33 getInverse() const
Return the inverse of the matrix.
MX_CORE_API const string VALUE_STRING_FALSE
M & operator/=(S s)
Component-wise division of a matrix by a scalar.
Function object for hashing vectors.