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