6 #ifndef MATERIALX_RENDER_TYPES_H
7 #define MATERIALX_RENDER_TYPES_H
28 _arr = {
x,
y,
z,
w };
34 _arr[0] * q.
_arr[3] + _arr[3] * q.
_arr[0] + _arr[1] * q.
_arr[2] - _arr[2] * q.
_arr[1],
35 _arr[1] * q.
_arr[3] + _arr[3] * q.
_arr[1] + _arr[2] * q.
_arr[0] - _arr[0] * q.
_arr[2],
36 _arr[2] * q.
_arr[3] + _arr[3] * q.
_arr[2] + _arr[0] * q.
_arr[1] - _arr[1] * q.
_arr[0],
37 _arr[3] * q.
_arr[3] - _arr[0] * q.
_arr[0] - _arr[1] * q.
_arr[1] - _arr[2] * q.
_arr[2]
43 float l = 1.f /
getMagnitude() * (_arr[3] < 0 ? -1.f : 1.f);
44 return { _arr[0] * l, _arr[1] * l, _arr[2] * l, _arr[3] * l };
81 _arr = {
x,
y,
z,
w };
104 explicit Half(
float value) : _data(toFloat16(value)) { }
105 operator float()
const {
return toFloat32(_data); }
134 static constexpr
int const shift = 13;
135 static constexpr
int const shiftSign = 16;
137 static constexpr int32_t
const infN = 0x7F800000;
138 static constexpr int32_t
const maxN = 0x477FE000;
139 static constexpr int32_t
const minN = 0x38800000;
140 static constexpr int32_t
const signN = (int32_t) 0x80000000;
142 static constexpr int32_t
const infC = infN >> shift;
143 static constexpr int32_t
const nanN = (infC + 1) << shift;
144 static constexpr int32_t
const maxC = maxN >> shift;
145 static constexpr int32_t
const minC = minN >> shift;
146 static constexpr int32_t
const signC = (int32_t) 0x00008000;
148 static constexpr int32_t
const mulN = 0x52000000;
149 static constexpr int32_t
const mulC = 0x33800000;
151 static constexpr int32_t
const subC = 0x003FF;
152 static constexpr int32_t
const norC = 0x00400;
154 static constexpr int32_t
const maxD = infC - maxC - 1;
155 static constexpr int32_t
const minD = minC - subC - 1;
157 static constexpr int32_t
const maxF = 0x7FFFFFBF;
159 static uint16_t toFloat16(
float value)
163 uint32_t
sign = (uint32_t) (v.si & signN);
167 int32_t subN = (int32_t)
std::min(s.f * v.f, (
float) maxF);
168 v.si ^= (subN ^ v.si) & -(minN > v.si);
169 v.si ^= (infN ^ v.si) & -((infN > v.si) & (v.si > maxN));
170 v.si ^= (nanN ^ v.si) & -((nanN > v.si) & (v.si > infN));
172 v.si ^= ((v.si - maxD) ^ v.si) & -(v.si > maxC);
173 v.si ^= ((v.si - minD) ^ v.si) & -(v.si > subC);
174 return (uint16_t) (v.ui |
sign);
177 static float toFloat32(uint16_t value)
181 int32_t sign = v.si & signC;
184 v.si ^= ((v.si + minD) ^ v.si) & -(v.si > subC);
185 v.si ^= ((v.si + maxD) ^ v.si) & -(v.si > maxC);
189 int32_t
mask = (norC > v.si) ? -1 : 1;
191 v.si ^= (s.si ^ v.si) & mask;
SYS_API double cos(double x)
bool operator!=(Half rhs) const
S getMagnitude() const
Return the magnitude of the vector.
bool operator>(Half rhs) const
#define MATERIALX_NAMESPACE_BEGIN
GLsizei const GLfloat * value
Color3d(double r, double g, double b)
GLdouble GLdouble GLdouble z
GLboolean GLboolean GLboolean GLboolean a
Half & operator/=(Half rhs)
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
bool operator<(Half rhs) const
Half operator*(Half rhs) const
static Quaternion createFromAxisAngle(const Vector3 &v, float a)
GLdouble GLdouble GLdouble q
Quaternion operator*(const Quaternion &q) const
bool operator<=(Half rhs) const
A tag class for constructing vectors and matrices without initialization.
IMATH_NAMESPACE::V2f float
Half & operator-=(Half rhs)
Half operator-(Half rhs) const
Quaternion(float x, float y, float z, float w)
Half operator+(Half rhs) const
static const Quaternion IDENTITY
bool operator>=(Half rhs) const
Vector3d(double x, double y, double z)
IMATH_HOSTDEVICE constexpr int sign(T a) IMATH_NOEXCEPT
GLboolean GLboolean GLboolean b
Quaternion getNormalized() const
Vector4d(double x, double y, double z, double w)
LeafData & operator=(const LeafData &)=delete
bool operator==(Half rhs) const
Half operator/(Half rhs) const
GLubyte GLubyte GLubyte GLubyte w
#define MATERIALX_NAMESPACE_END
Half & operator+=(Half rhs)
SYS_API double sin(double x)
Half & operator*=(Half rhs)