6 #ifndef MATERIALX_TYPES_H
7 #define MATERIALX_TYPES_H
58 using Iterator =
typename std::array<S, N>::iterator;
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++)
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++)
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++)
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++)
170 for (
size_t i = 0; i <
N; i++)
171 res[i] =
_arr[i] * s;
178 for (
size_t i = 0; i <
N; i++)
187 for (
size_t i = 0; i <
N; i++)
188 res[i] =
_arr[i] / s;
195 for (
size_t i = 0; i <
N; i++)
204 for (
size_t i = 0; i <
N; i++)
217 for (
size_t i = 0; i <
N; i++)
232 for (
size_t i = 0; i <
N; i++)
233 res +=
_arr[i] * rhs[i];
264 for (
size_t i = 0; i <
N; i++)
299 return _arr[0] * rhs[1] - _arr[1] * rhs[0];
319 return Vector3(_arr[1] * rhs[2] - _arr[2] * rhs[1],
320 _arr[2] * rhs[0] - _arr[0] * rhs[2],
321 _arr[0] * rhs[1] - _arr[1] * rhs[0]);
335 _arr = {
x,
y,
z,
w };
354 Color3 linearToSrgb()
const;
358 Color3 srgbToLinear()
const;
371 _arr = {
r,
g,
b,
a };
390 using Iterator =
typename std::array<RowArray, N>::iterator;
412 for (
size_t i = 0; i <
N; i++)
414 for (
size_t j = 0;
j <
N;
j++)
443 for (
size_t i = 0; i <
N; i++)
444 for (
size_t j = 0;
j <
N;
j++)
445 res[i][
j] =
_arr[i][
j] + rhs[i][
j];
460 for (
size_t i = 0; i <
N; i++)
461 for (
size_t j = 0;
j <
N;
j++)
462 res[i][
j] =
_arr[i][
j] - rhs[i][
j];
477 for (
size_t i = 0; i <
N; i++)
478 for (
size_t j = 0;
j <
N;
j++)
479 res[i][
j] =
_arr[i][
j] * s;
494 for (
size_t i = 0; i <
N; i++)
495 for (
size_t j = 0;
j <
N;
j++)
496 res[i][
j] =
_arr[i][
j] / s;
515 for (
size_t i = 0; i <
N; i++)
516 for (
size_t j = 0;
j <
N;
j++)
517 for (
size_t k = 0; k <
N; k++)
518 res[i][
j] +=
_arr[i][k] * rhs[k][
j];
540 *
this *= rhs.getInverse();
591 float m10,
float m11,
float m12,
592 float m20,
float m21,
float m22) :
595 _arr = { RowArray{ m00, m01, m02 },
596 RowArray{ m10, m11, m12 },
597 RowArray{ m20, m21, m22 } };
607 float getDeterminant()
const;
615 return getAdjugate() / getDeterminant();
660 Matrix44(
float m00,
float m01,
float m02,
float m03,
661 float m10,
float m11,
float m12,
float m13,
662 float m20,
float m21,
float m22,
float m23,
663 float m30,
float m31,
float m32,
float m33) :
666 _arr = { RowArray{ m00, m01, m02, m03 },
667 RowArray{ m10, m11, m12, m13 },
668 RowArray{ m20, m21, m22, m23 },
669 RowArray{ m30, m31, m32, m33 } };
679 float getDeterminant()
const;
687 return getAdjugate() / getDeterminant();
MatrixN & operator+=(const M &rhs)
Component-wise addition of two matrices.
MX_CORE_API const string ARRAY_PREFERRED_SEPARATOR
V operator+(const V &rhs) const
Component-wise addition of two vectors.
MX_CORE_API const string VALUE_STRING_TRUE
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
MatrixN(const S *begin, const S *end)
M operator/(S s) const
Component-wise division of a matrix 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
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
MX_CORE_API const string LIGHT_SHADER_TYPE_STRING
MatrixN & operator/=(const M &rhs)
typename std::array< float, N >::const_iterator ConstIterator
VectorN & operator-=(const V &rhs)
Component-wise subtraction of two vectors.
MX_CORE_API const string FILENAME_TYPE_STRING
VectorN & operator/=(const V &rhs)
Component-wise division of two vectors.
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)
MatrixN & operator*=(const M &rhs)
Compute the matrix product.
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.
MatrixN & operator/=(S s)
Component-wise division of a matrix by a scalar.
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.
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.
VectorN & operator*=(S s)
Component-wise multiplication of a vector by a scalar.
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
VectorN & operator/=(S s)
Component-wise division of a vector by a scalar.
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.
MatrixN & operator*=(S s)
Component-wise multiplication of a matrix and a scalar.
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)
ConstIterator begin() const
GLboolean GLboolean GLboolean b
VectorN & operator*=(const V &rhs)
Component-wise multiplication of two vectors.
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
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
S * data()
Return a pointer to the underlying data array.
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)
VectorN & operator+=(const V &rhs)
Component-wise addition of two vectors.
MatrixN & operator-=(const M &rhs)
Component-wise subtraction of two matrices.
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
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
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.
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
Matrix33 getInverse() const
Return the inverse of the matrix.
uint64_t multiply(uint64_t lhs, uint64_t rhs)
MX_CORE_API const string VALUE_STRING_FALSE
Function object for hashing vectors.