HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Types.h
Go to the documentation of this file.
1 //
2 // Copyright Contributors to the MaterialX Project
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 
6 #ifndef MATERIALX_TYPES_H
7 #define MATERIALX_TYPES_H
8 
9 /// @file
10 /// Data type classes
11 
12 #include <MaterialXCore/Export.h>
13 
14 #include <MaterialXCore/Util.h>
15 
16 #include <array>
17 #include <cmath>
18 
20 
21 extern MX_CORE_API const string DEFAULT_TYPE_STRING;
22 extern MX_CORE_API const string FILENAME_TYPE_STRING;
23 extern MX_CORE_API const string GEOMNAME_TYPE_STRING;
24 extern MX_CORE_API const string STRING_TYPE_STRING;
25 extern MX_CORE_API const string BSDF_TYPE_STRING;
26 extern MX_CORE_API const string EDF_TYPE_STRING;
27 extern MX_CORE_API const string VDF_TYPE_STRING;
28 extern MX_CORE_API const string SURFACE_SHADER_TYPE_STRING;
30 extern MX_CORE_API const string VOLUME_SHADER_TYPE_STRING;
31 extern MX_CORE_API const string LIGHT_SHADER_TYPE_STRING;
32 extern MX_CORE_API const string MATERIAL_TYPE_STRING;
33 extern MX_CORE_API const string SURFACE_MATERIAL_NODE_STRING;
34 extern MX_CORE_API const string VOLUME_MATERIAL_NODE_STRING;
35 extern MX_CORE_API const string MULTI_OUTPUT_TYPE_STRING;
36 extern MX_CORE_API const string NONE_TYPE_STRING;
37 extern MX_CORE_API const string VALUE_STRING_TRUE;
38 extern MX_CORE_API const string VALUE_STRING_FALSE;
39 extern MX_CORE_API const string NAME_PREFIX_SEPARATOR;
40 extern MX_CORE_API const string NAME_PATH_SEPARATOR;
41 extern MX_CORE_API const string ARRAY_VALID_SEPARATORS;
42 extern MX_CORE_API const string ARRAY_PREFERRED_SEPARATOR;
43 
44 /// The base class for vectors of scalar values
45 class VectorBase { };
46 
47 /// A tag class for constructing vectors and matrices without initialization
48 class Uninit { };
49 
50 /// The class template for vectors of scalar values. Inherited by Vector2,
51 /// Vector3, Vector4, Color3, and Color4.
52 ///
53 /// Template parameter V is the vector subclass, S is the scalar element type,
54 /// and N is the number of scalar elements in the vector.
55 template <class V, class S, size_t N> class VectorN : public VectorBase
56 {
57  public:
58  using Iterator = typename std::array<S, N>::iterator;
59  using ConstIterator = typename std::array<S, N>::const_iterator;
60 
61  public:
62  VectorN() : _arr{} { }
63  explicit VectorN(Uninit) { }
64  explicit VectorN(S s) { _arr.fill(s); }
65  explicit VectorN(const std::array<S, N>& arr) : _arr(arr) { }
66  explicit VectorN(const vector<S>& vec) { std::copy(vec.begin(), vec.end(), _arr.begin()); }
67  explicit VectorN(const S* begin, const S* end) { std::copy(begin, end, _arr.begin()); }
68 
69  /// @name Comparison Operators
70  /// @{
71 
72  /// Return true if the given vector is identical to this one.
73  bool operator==(const V& rhs) const { return _arr == rhs._arr; }
74 
75  /// Return true if the given vector differs from this one.
76  bool operator!=(const V& rhs) const { return _arr != rhs._arr; }
77 
78  /// Compare two vectors lexicographically.
79  bool operator<(const V& rhs) const
80  {
81  return _arr < rhs._arr;
82  }
83 
84  /// @}
85  /// @name Indexing Operators
86  /// @{
87 
88  /// Return the scalar value at the given index.
89  S& operator[](size_t i) { return _arr.at(i); }
90 
91  /// Return the const scalar value at the given index.
92  const S& operator[](size_t i) const { return _arr.at(i); }
93 
94  /// @}
95  /// @name Component-wise Operators
96  /// @{
97 
98  /// Component-wise addition of two vectors.
99  V operator+(const V& rhs) const
100  {
101  V res(Uninit{});
102  for (size_t i = 0; i < N; i++)
103  res[i] = _arr[i] + rhs[i];
104  return res;
105  }
106 
107  /// Component-wise addition of two vectors.
108  VectorN& operator+=(const V& rhs)
109  {
110  for (size_t i = 0; i < N; i++)
111  _arr[i] += rhs[i];
112  return *this;
113  }
114 
115  /// Component-wise subtraction of two vectors.
116  V operator-(const V& rhs) const
117  {
118  V res(Uninit{});
119  for (size_t i = 0; i < N; i++)
120  res[i] = _arr[i] - rhs[i];
121  return res;
122  }
123 
124  /// Component-wise subtraction of two vectors.
125  VectorN& operator-=(const V& rhs)
126  {
127  for (size_t i = 0; i < N; i++)
128  _arr[i] -= rhs[i];
129  return *this;
130  }
131 
132  /// Component-wise multiplication of two vectors.
133  V operator*(const V& rhs) const
134  {
135  V res(Uninit{});
136  for (size_t i = 0; i < N; i++)
137  res[i] = _arr[i] * rhs[i];
138  return res;
139  }
140 
141  /// Component-wise multiplication of two vectors.
142  VectorN& operator*=(const V& rhs)
143  {
144  for (size_t i = 0; i < N; i++)
145  _arr[i] *= rhs[i];
146  return *this;
147  }
148 
149  /// Component-wise division of two vectors.
150  V operator/(const V& rhs) const
151  {
152  V res(Uninit{});
153  for (size_t i = 0; i < N; i++)
154  res[i] = _arr[i] / rhs[i];
155  return res;
156  }
157 
158  /// Component-wise division of two vectors.
159  VectorN& operator/=(const V& rhs)
160  {
161  for (size_t i = 0; i < N; i++)
162  _arr[i] /= rhs[i];
163  return *this;
164  }
165 
166  /// Component-wise multiplication of a vector by a scalar.
167  V operator*(S s) const
168  {
169  V res(Uninit{});
170  for (size_t i = 0; i < N; i++)
171  res[i] = _arr[i] * s;
172  return res;
173  }
174 
175  /// Component-wise multiplication of a vector by a scalar.
177  {
178  for (size_t i = 0; i < N; i++)
179  _arr[i] *= s;
180  return *this;
181  }
182 
183  /// Component-wise division of a vector by a scalar.
184  V operator/(S s) const
185  {
186  V res(Uninit{});
187  for (size_t i = 0; i < N; i++)
188  res[i] = _arr[i] / s;
189  return res;
190  }
191 
192  /// Component-wise division of a vector by a scalar.
194  {
195  for (size_t i = 0; i < N; i++)
196  _arr[i] /= s;
197  return *this;
198  }
199 
200  /// Unary negation of a vector.
201  V operator-() const
202  {
203  V res(Uninit{});
204  for (size_t i = 0; i < N; i++)
205  res[i] = -_arr[i];
206  return res;
207  }
208 
209  /// @}
210  /// @name Geometric Methods
211  /// @{
212 
213  /// Return the magnitude of the vector.
214  S getMagnitude() const
215  {
216  S res{};
217  for (size_t i = 0; i < N; i++)
218  res += _arr[i] * _arr[i];
219  return std::sqrt(res);
220  }
221 
222  /// Return a normalized vector.
223  V getNormalized() const
224  {
225  return *this / getMagnitude();
226  }
227 
228  /// Return the dot product of two vectors.
229  S dot(const V& rhs) const
230  {
231  S res{};
232  for (size_t i = 0; i < N; i++)
233  res += _arr[i] * rhs[i];
234  return res;
235  }
236 
237  /// @}
238  /// @name Iterators
239  /// @{
240 
241  Iterator begin() { return _arr.begin(); }
242  ConstIterator begin() const { return _arr.begin(); }
243 
244  Iterator end() { return _arr.end(); }
245  ConstIterator end() const { return _arr.end(); }
246 
247  /// @}
248  /// @name Utility
249  /// @{
250 
251  /// Return a pointer to the underlying data array.
252  S* data() { return _arr.data(); }
253 
254  /// Return a const pointer to the underlying data array.
255  const S* data() const { return _arr.data(); }
256 
257  /// Function object for hashing vectors.
258  class Hash
259  {
260  public:
261  size_t operator()(const V& v) const noexcept
262  {
263  size_t h = 0;
264  for (size_t i = 0; i < N; i++)
265  hashCombine(h, v[i]);
266  return h;
267  }
268  };
269 
270  /// @}
271  /// @name Static Methods
272  /// @{
273 
274  /// Return the number of scalar elements for the vector.
275  static constexpr size_t numElements() { return N; }
276 
277  /// @}
278 
279  protected:
280  std::array<S, N> _arr;
281 };
282 
283 /// @class Vector2
284 /// A vector of two floating-point values
285 class MX_CORE_API Vector2 : public VectorN<Vector2, float, 2>
286 {
287  public:
289  Vector2() = default;
290  Vector2(float x, float y) :
291  VectorN(Uninit{})
292  {
293  _arr = { x, y };
294  }
295 
296  /// Return the cross product of two vectors.
297  float cross(const Vector2& rhs) const
298  {
299  return _arr[0] * rhs[1] - _arr[1] * rhs[0];
300  }
301 };
302 
303 /// @class Vector3
304 /// A vector of three floating-point values
305 class MX_CORE_API Vector3 : public VectorN<Vector3, float, 3>
306 {
307  public:
309  Vector3() = default;
310  Vector3(float x, float y, float z) :
311  VectorN(Uninit{})
312  {
313  _arr = { x, y, z };
314  }
315 
316  /// Return the cross product of two vectors.
317  Vector3 cross(const Vector3& rhs) const
318  {
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]);
322  }
323 };
324 
325 /// @class Vector4
326 /// A vector of four floating-point values
327 class MX_CORE_API Vector4 : public VectorN<Vector4, float, 4>
328 {
329  public:
331  Vector4() = default;
332  Vector4(float x, float y, float z, float w) :
333  VectorN(Uninit{})
334  {
335  _arr = { x, y, z, w };
336  }
337 };
338 
339 /// @class Color3
340 /// A three-component color value
341 class MX_CORE_API Color3 : public VectorN<Color3, float, 3>
342 {
343  public:
345  Color3() = default;
346  Color3(float r, float g, float b) :
347  VectorN(Uninit{})
348  {
349  _arr = { r, g, b };
350  }
351 
352  /// Transform the given color from linear RGB to the sRGB encoding,
353  /// returning the result as a new value.
354  Color3 linearToSrgb() const;
355 
356  /// Transform the given color from the sRGB encoding to linear RGB,
357  /// returning the result as a new value.
358  Color3 srgbToLinear() const;
359 };
360 
361 /// @class Color4
362 /// A four-component color value
363 class MX_CORE_API Color4 : public VectorN<Color4, float, 4>
364 {
365  public:
367  Color4() = default;
368  Color4(float r, float g, float b, float a) :
369  VectorN(Uninit{})
370  {
371  _arr = { r, g, b, a };
372  }
373 };
374 
375 /// The base class for square matrices of scalar values
376 class MatrixBase { };
377 
378 /// The class template for square matrices of scalar values. Inherited by
379 /// Matrix33 and Matrix44.
380 ///
381 /// The elements of a MatrixN are stored in row-major order, and may be
382 /// accessed using the syntax <c>matrix[row][column]</c>.
383 ///
384 /// Template parameter M is the matrix subclass, S is the scalar element type,
385 /// and N is the number of rows and columns in the matrix.
386 template <class M, class S, size_t N> class MatrixN : public MatrixBase
387 {
388  public:
389  using RowArray = typename std::array<S, N>;
390  using Iterator = typename std::array<RowArray, N>::iterator;
391  using ConstIterator = typename std::array<RowArray, N>::const_iterator;
392 
393  public:
394  MatrixN() : _arr{} { }
395  explicit MatrixN(Uninit) { }
396  explicit MatrixN(S s) { std::fill_n(&_arr[0][0], N * N, s); }
397  explicit MatrixN(const S* begin, const S* end) { std::copy(begin, end, &_arr[0][0]); }
398 
399  /// @name Comparison Operators
400  /// @{
401 
402  /// Return true if the given matrix is identical to this one.
403  bool operator==(const M& rhs) const { return _arr == rhs._arr; }
404 
405  /// Return true if the given matrix differs from this one.
406  bool operator!=(const M& rhs) const { return _arr != rhs._arr; }
407 
408  /// Return true if the given matrix is equivalent to this one
409  /// within a given floating-point tolerance.
410  bool isEquivalent(const M& rhs, S tolerance) const
411  {
412  for (size_t i = 0; i < N; i++)
413  {
414  for (size_t j = 0; j < N; j++)
415  {
416  if (std::abs(_arr[i][j] - rhs[i][j]) > tolerance)
417  {
418  return false;
419  }
420  }
421  }
422  return true;
423  }
424 
425  /// @}
426  /// @name Indexing Operators
427  /// @{
428 
429  /// Return the row array at the given index.
430  RowArray& operator[](size_t i) { return _arr.at(i); }
431 
432  /// Return the const row array at the given index.
433  const RowArray& operator[](size_t i) const { return _arr.at(i); }
434 
435  /// @}
436  /// @name Component-wise Operators
437  /// @{
438 
439  /// Component-wise addition of two matrices.
440  M operator+(const M& rhs) const
441  {
442  M res(Uninit{});
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];
446  return res;
447  }
448 
449  /// Component-wise addition of two matrices.
450  MatrixN& operator+=(const M& rhs)
451  {
452  *this = *this + rhs;
453  return *this;
454  }
455 
456  /// Component-wise subtraction of two matrices.
457  M operator-(const M& rhs) const
458  {
459  M res(Uninit{});
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];
463  return res;
464  }
465 
466  /// Component-wise subtraction of two matrices.
467  MatrixN& operator-=(const M& rhs)
468  {
469  *this = *this - rhs;
470  return *this;
471  }
472 
473  /// Component-wise multiplication of a matrix and a scalar.
474  M operator*(S s) const
475  {
476  M res(Uninit{});
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;
480  return res;
481  }
482 
483  /// Component-wise multiplication of a matrix and a scalar.
485  {
486  *this = *this * s;
487  return *this;
488  }
489 
490  /// Component-wise division of a matrix by a scalar.
491  M operator/(S s) const
492  {
493  M res(Uninit{});
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;
497  return res;
498  }
499 
500  /// Component-wise division of a matrix by a scalar.
502  {
503  *this = *this / s;
504  return *this;
505  }
506 
507  /// @}
508  /// @name Matrix Algebra
509  /// @{
510 
511  /// Compute the matrix product.
512  M operator*(const M& rhs) const
513  {
514  M res;
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];
519  return res;
520  }
521 
522  /// Compute the matrix product.
523  MatrixN& operator*=(const M& rhs)
524  {
525  *this = *this * rhs;
526  return *this;
527  }
528 
529  /// Divide the first matrix by the second (computed as the product of the
530  /// first matrix and the inverse of the second).
531  M operator/(const M& rhs) const
532  {
533  return *this * rhs.getInverse();
534  }
535 
536  /// Divide the first matrix by the second (computed as the product of the
537  /// first matrix and the inverse of the second).
538  MatrixN& operator/=(const M& rhs)
539  {
540  *this *= rhs.getInverse();
541  return *this;
542  }
543 
544  /// @}
545  /// @name Iterators
546  /// @{
547 
548  Iterator begin() { return _arr.begin(); }
549  ConstIterator begin() const { return _arr.begin(); }
550 
551  Iterator end() { return _arr.end(); }
552  ConstIterator end() const { return _arr.end(); }
553 
554  /// @}
555  /// @name Utility
556  /// @{
557 
558  /// Return a pointer to the underlying data array.
559  S* data() { return _arr.front().data(); }
560 
561  /// Return a const pointer to the underlying data array.
562  const S* data() const { return _arr.front().data(); }
563 
564  /// @}
565  /// @name Static Methods
566  /// @{
567 
568  /// Return the number of rows in this matrix.
569  static constexpr size_t numRows() { return N; }
570 
571  /// Return the number of columns in this matrix.
572  static constexpr size_t numColumns() { return N; }
573 
574  /// @}
575 
576  protected:
577  std::array<RowArray, N> _arr;
578 };
579 
580 /// @class Matrix33
581 /// A 3x3 matrix of floating-point values.
582 ///
583 /// Vector transformation methods follow the row-vector convention,
584 /// with matrix-vector multiplication computed as v' = vM.
585 class MX_CORE_API Matrix33 : public MatrixN<Matrix33, float, 3>
586 {
587  public:
589  Matrix33() = default;
590  Matrix33(float m00, float m01, float m02,
591  float m10, float m11, float m12,
592  float m20, float m21, float m22) :
593  MatrixN(Uninit{})
594  {
595  _arr = { RowArray{ m00, m01, m02 },
596  RowArray{ m10, m11, m12 },
597  RowArray{ m20, m21, m22 } };
598  }
599 
600  /// @name Matrix Operations
601  /// @{
602 
603  /// Return the transpose of the matrix.
604  Matrix33 getTranspose() const;
605 
606  /// Return the determinant of the matrix.
607  float getDeterminant() const;
608 
609  /// Return the adjugate of the matrix.
610  Matrix33 getAdjugate() const;
611 
612  /// Return the inverse of the matrix.
614  {
615  return getAdjugate() / getDeterminant();
616  }
617 
618  /// @}
619  /// @name Vector Transformations
620  /// @{
621 
622  /// Return the product of this matrix and a 3D vector.
623  Vector3 multiply(const Vector3& v) const;
624 
625  /// Transform the given 2D point.
626  Vector2 transformPoint(const Vector2& v) const;
627 
628  /// Transform the given 2D direction vector.
629  Vector2 transformVector(const Vector2& v) const;
630 
631  /// Transform the given 3D normal vector.
632  Vector3 transformNormal(const Vector3& v) const;
633 
634  /// Create a translation matrix.
635  static Matrix33 createTranslation(const Vector2& v);
636 
637  /// Create a scale matrix.
638  static Matrix33 createScale(const Vector2& v);
639 
640  /// Create a rotation matrix.
641  /// @param angle Angle in radians
642  static Matrix33 createRotation(float angle);
643 
644  /// @}
645 
646  public:
647  static const Matrix33 IDENTITY;
648 };
649 
650 /// @class Matrix44
651 /// A 4x4 matrix of floating-point values.
652 ///
653 /// Vector transformation methods follow the row-vector convention,
654 /// with matrix-vector multiplication computed as v' = vM.
655 class MX_CORE_API Matrix44 : public MatrixN<Matrix44, float, 4>
656 {
657  public:
659  Matrix44() = default;
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) :
664  MatrixN(Uninit{})
665  {
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 } };
670  }
671 
672  /// @name Matrix Operations
673  /// @{
674 
675  /// Return the transpose of the matrix.
676  Matrix44 getTranspose() const;
677 
678  /// Return the determinant of the matrix.
679  float getDeterminant() const;
680 
681  /// Return the adjugate of the matrix.
682  Matrix44 getAdjugate() const;
683 
684  /// Return the inverse of the matrix.
686  {
687  return getAdjugate() / getDeterminant();
688  }
689 
690  /// @}
691  /// @name Vector Transformations
692  /// @{
693 
694  /// Return the product of this matrix and a 4D vector.
695  Vector4 multiply(const Vector4& v) const;
696 
697  /// Transform the given 3D point.
698  Vector3 transformPoint(const Vector3& v) const;
699 
700  /// Transform the given 3D direction vector.
701  Vector3 transformVector(const Vector3& v) const;
702 
703  /// Transform the given 3D normal vector.
704  Vector3 transformNormal(const Vector3& v) const;
705 
706  /// Create a translation matrix.
707  static Matrix44 createTranslation(const Vector3& v);
708 
709  /// Create a scale matrix.
710  static Matrix44 createScale(const Vector3& v);
711 
712  /// Create a rotation matrix about the X-axis.
713  /// @param angle Angle in radians
714  static Matrix44 createRotationX(float angle);
715 
716  /// Create a rotation matrix about the Y-axis.
717  /// @param angle Angle in radians
718  static Matrix44 createRotationY(float angle);
719 
720  /// Create a rotation matrix about the Z-axis.
721  /// @param angle Angle in radians
722  static Matrix44 createRotationZ(float angle);
723 
724  /// @}
725 
726  public:
727  static const Matrix44 IDENTITY;
728 };
729 
731 
732 #endif
MatrixN & operator+=(const M &rhs)
Component-wise addition of two matrices.
Definition: Types.h:450
MX_CORE_API const string ARRAY_PREFERRED_SEPARATOR
V operator+(const V &rhs) const
Component-wise addition of two vectors.
Definition: Types.h:99
MX_CORE_API const string VALUE_STRING_TRUE
S getMagnitude() const
Return the magnitude of the vector.
Definition: Types.h:214
M operator+(const M &rhs) const
Component-wise addition of two matrices.
Definition: Types.h:440
MX_CORE_API const string NONE_TYPE_STRING
bool isEquivalent(const M &rhs, S tolerance) const
Definition: Types.h:410
MatrixN(const S *begin, const S *end)
Definition: Types.h:397
M operator/(S s) const
Component-wise division of a matrix by a scalar.
Definition: Types.h:491
M operator*(S s) const
Component-wise multiplication of a matrix and a scalar.
Definition: Types.h:474
std::array< S, N > _arr
Definition: Types.h:280
V getNormalized() const
Return a normalized vector.
Definition: Types.h:223
SIM_API const UT_StringHolder angle
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
MX_CORE_API const string VDF_TYPE_STRING
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
const GLdouble * v
Definition: glcorearb.h:837
MX_CORE_API const string LIGHT_SHADER_TYPE_STRING
MatrixN & operator/=(const M &rhs)
Definition: Types.h:538
typename std::array< float, N >::const_iterator ConstIterator
Definition: Types.h:59
VectorN & operator-=(const V &rhs)
Component-wise subtraction of two vectors.
Definition: Types.h:125
MX_CORE_API const string FILENAME_TYPE_STRING
VectorN & operator/=(const V &rhs)
Component-wise division of two vectors.
Definition: Types.h:159
M operator-(const M &rhs) const
Component-wise subtraction of two matrices.
Definition: Types.h:457
vfloat4 sqrt(const vfloat4 &a)
Definition: simd.h:7481
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:848
GLboolean GLboolean g
Definition: glcorearb.h:1222
Iterator begin()
Definition: Types.h:548
Iterator end()
Definition: Types.h:551
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
GLdouble s
Definition: glad.h:3009
MX_CORE_API const string VOLUME_SHADER_TYPE_STRING
GLint y
Definition: glcorearb.h:103
const S * data() const
Return a const pointer to the underlying data array.
Definition: Types.h:255
Color4(float r, float g, float b, float a)
Definition: Types.h:368
VectorN()
Definition: Types.h:62
MatrixN & operator*=(const M &rhs)
Compute the matrix product.
Definition: Types.h:523
ConstIterator end() const
Definition: Types.h:552
FMT_CONSTEXPR auto fill_n(OutputIt out, Size count, const T &value) -> OutputIt
Definition: format.h:408
#define MX_CORE_API
Definition: Export.h:18
bool operator==(const M &rhs) const
Return true if the given matrix is identical to this one.
Definition: Types.h:403
VectorN(const vector< S > &vec)
Definition: Types.h:66
Definition: Types.h:386
The base class for square matrices of scalar values.
Definition: Types.h:376
MX_CORE_API const string EDF_TYPE_STRING
const S & operator[](size_t i) const
Return the const scalar value at the given index.
Definition: Types.h:92
bool operator!=(const V &rhs) const
Return true if the given vector differs from this one.
Definition: Types.h:76
V operator*(S s) const
Component-wise multiplication of a vector by a scalar.
Definition: Types.h:167
static constexpr size_t numRows()
Return the number of rows in this matrix.
Definition: Types.h:569
bool operator<(const V &rhs) const
Compare two vectors lexicographically.
Definition: Types.h:79
MatrixN & operator/=(S s)
Component-wise division of a matrix by a scalar.
Definition: Types.h:501
A tag class for constructing vectors and matrices without initialization.
Definition: Types.h:48
MX_CORE_API const string VOLUME_MATERIAL_NODE_STRING
VectorN(const S *begin, const S *end)
Definition: Types.h:67
typename std::array< float, N >::iterator Iterator
Definition: Types.h:58
V operator-(const V &rhs) const
Component-wise subtraction of two vectors.
Definition: Types.h:116
ConstIterator begin() const
Definition: Types.h:549
Iterator end()
Definition: Types.h:244
static constexpr size_t numElements()
Return the number of scalar elements for the vector.
Definition: Types.h:275
The base class for vectors of scalar values.
Definition: Types.h:45
MX_CORE_API const string GEOMNAME_TYPE_STRING
Matrix44 getInverse() const
Return the inverse of the matrix.
Definition: Types.h:685
VectorN & operator*=(S s)
Component-wise multiplication of a vector by a scalar.
Definition: Types.h:176
GLuint GLuint end
Definition: glcorearb.h:475
MatrixN()
Definition: Types.h:394
bool operator!=(const M &rhs) const
Return true if the given matrix differs from this one.
Definition: Types.h:406
MX_CORE_API const string MULTI_OUTPUT_TYPE_STRING
Definition: Types.h:327
VectorN & operator/=(S s)
Component-wise division of a vector by a scalar.
Definition: Types.h:193
Vector3 cross(const Vector3 &rhs) const
Return the cross product of two vectors.
Definition: Types.h:317
void hashCombine(size_t &seed, const T &value)
Combine the hash of a value with an existing seed.
Definition: Util.h:58
MatrixN & operator*=(S s)
Component-wise multiplication of a matrix and a scalar.
Definition: Types.h:484
Definition: Types.h:285
MX_CORE_API const string NAME_PREFIX_SEPARATOR
S * data()
Return a pointer to the underlying data array.
Definition: Types.h:559
std::array< RowArray, N > _arr
Definition: Types.h:577
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)
Definition: Types.h:660
Vector3(float x, float y, float z)
Definition: Types.h:310
Definition: Types.h:55
ConstIterator begin() const
Definition: Types.h:242
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
VectorN & operator*=(const V &rhs)
Component-wise multiplication of two vectors.
Definition: Types.h:142
GLint GLenum GLint x
Definition: glcorearb.h:409
V operator/(S s) const
Component-wise division of a vector by a scalar.
Definition: Types.h:184
bool operator==(const V &rhs) const
Return true if the given vector is identical to this one.
Definition: Types.h:73
float cross(const Vector2 &rhs) const
Return the cross product of two vectors.
Definition: Types.h:297
static constexpr size_t numColumns()
Return the number of columns in this matrix.
Definition: Types.h:572
typename std::array< RowArray, N >::iterator Iterator
Definition: Types.h:390
MX_CORE_API const string MATERIAL_TYPE_STRING
MX_CORE_API const string BSDF_TYPE_STRING
VectorN(const std::array< S, N > &arr)
Definition: Types.h:65
MX_CORE_API const string STRING_TYPE_STRING
GLint j
Definition: glad.h:2733
RowArray & operator[](size_t i)
Return the row array at the given index.
Definition: Types.h:430
S & operator[](size_t i)
Return the scalar value at the given index.
Definition: Types.h:89
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
MATERIALX_NAMESPACE_BEGIN MX_CORE_API const string DEFAULT_TYPE_STRING
size_t operator()(const V &v) const noexcept
Definition: Types.h:261
S * data()
Return a pointer to the underlying data array.
Definition: Types.h:252
M operator/(const M &rhs) const
Definition: Types.h:531
MX_CORE_API const string SURFACE_SHADER_TYPE_STRING
Definition: Types.h:305
MX_CORE_API const string DISPLACEMENT_SHADER_TYPE_STRING
Vector2(float x, float y)
Definition: Types.h:290
VectorN & operator+=(const V &rhs)
Component-wise addition of two vectors.
Definition: Types.h:108
MatrixN & operator-=(const M &rhs)
Component-wise subtraction of two matrices.
Definition: Types.h:467
VectorN(S s)
Definition: Types.h:64
Vec3< T1 > transformNormal(const Mat4< T0 > &m, const Vec3< T1 > &n)
Definition: Mat4.h:1226
ConstIterator end() const
Definition: Types.h:245
S dot(const V &rhs) const
Return the dot product of two vectors.
Definition: Types.h:229
GA_API const UT_StringHolder N
Color3(float r, float g, float b)
Definition: Types.h:346
V operator-() const
Unary negation of a vector.
Definition: Types.h:201
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.
Definition: Types.h:133
const S * data() const
Return a const pointer to the underlying data array.
Definition: Types.h:562
static const Matrix33 IDENTITY
Definition: Types.h:647
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
MX_CORE_API const string ARRAY_VALID_SEPARATORS
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER IMATH_HOSTDEVICE constexpr T abs(T a) IMATH_NOEXCEPT
Definition: ImathFun.h:26
Vector4(float x, float y, float z, float w)
Definition: Types.h:332
#define MATERIALX_NAMESPACE_END
Definition: Generated.h:26
static const Matrix44 IDENTITY
Definition: Types.h:727
M operator*(const M &rhs) const
Compute the matrix product.
Definition: Types.h:512
GLboolean r
Definition: glcorearb.h:1222
VectorN(Uninit)
Definition: Types.h:63
MatrixN(S s)
Definition: Types.h:396
Matrix33(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
Definition: Types.h:590
typename std::array< RowArray, N >::const_iterator ConstIterator
Definition: Types.h:391
V operator/(const V &rhs) const
Component-wise division of two vectors.
Definition: Types.h:150
const RowArray & operator[](size_t i) const
Return the const row array at the given index.
Definition: Types.h:433
typename std::array< float, N > RowArray
Definition: Types.h:389
Matrix33 getInverse() const
Return the inverse of the matrix.
Definition: Types.h:613
uint64_t multiply(uint64_t lhs, uint64_t rhs)
Definition: format-inl.h:258
MX_CORE_API const string VALUE_STRING_FALSE
Iterator begin()
Definition: Types.h:241
Function object for hashing vectors.
Definition: Types.h:258
MatrixN(Uninit)
Definition: Types.h:395