16#include <Eigen/Eigenvalues>
30 __m128
A0 = _mm_load_ps(a[0]);
31 __m128
A1 = _mm_load_ps(a[1]);
32 __m128
A2 = _mm_load_ps(a[2]);
33 __m128 A3 = _mm_load_ps(a[3]);
35 for (
int i = 0; i < 4; i++) {
36 __m128 B0 = _mm_set1_ps(
b[i][0]);
37 __m128 B1 = _mm_set1_ps(
b[i][1]);
38 __m128 B2 = _mm_set1_ps(
b[i][2]);
39 __m128 B3 = _mm_set1_ps(
b[i][3]);
41 __m128
sum = _mm_add_ps(_mm_add_ps(_mm_mul_ps(B0,
A0), _mm_mul_ps(B1,
A1)),
42 _mm_add_ps(_mm_mul_ps(B2,
A2), _mm_mul_ps(B3, A3)));
44 _mm_store_ps(result[i],
sum);
47 result[0][0] =
b[0][0] * a[0][0] +
b[0][1] * a[1][0] +
b[0][2] * a[2][0] +
b[0][3] * a[3][0];
48 result[0][1] =
b[0][0] * a[0][1] +
b[0][1] * a[1][1] +
b[0][2] * a[2][1] +
b[0][3] * a[3][1];
49 result[0][2] =
b[0][0] * a[0][2] +
b[0][1] * a[1][2] +
b[0][2] * a[2][2] +
b[0][3] * a[3][2];
50 result[0][3] =
b[0][0] * a[0][3] +
b[0][1] * a[1][3] +
b[0][2] * a[2][3] +
b[0][3] * a[3][3];
52 result[1][0] =
b[1][0] * a[0][0] +
b[1][1] * a[1][0] +
b[1][2] * a[2][0] +
b[1][3] * a[3][0];
53 result[1][1] =
b[1][0] * a[0][1] +
b[1][1] * a[1][1] +
b[1][2] * a[2][1] +
b[1][3] * a[3][1];
54 result[1][2] =
b[1][0] * a[0][2] +
b[1][1] * a[1][2] +
b[1][2] * a[2][2] +
b[1][3] * a[3][2];
55 result[1][3] =
b[1][0] * a[0][3] +
b[1][1] * a[1][3] +
b[1][2] * a[2][3] +
b[1][3] * a[3][3];
57 result[2][0] =
b[2][0] * a[0][0] +
b[2][1] * a[1][0] +
b[2][2] * a[2][0] +
b[2][3] * a[3][0];
58 result[2][1] =
b[2][0] * a[0][1] +
b[2][1] * a[1][1] +
b[2][2] * a[2][1] +
b[2][3] * a[3][1];
59 result[2][2] =
b[2][0] * a[0][2] +
b[2][1] * a[1][2] +
b[2][2] * a[2][2] +
b[2][3] * a[3][2];
60 result[2][3] =
b[2][0] * a[0][3] +
b[2][1] * a[1][3] +
b[2][2] * a[2][3] +
b[2][3] * a[3][3];
62 result[3][0] =
b[3][0] * a[0][0] +
b[3][1] * a[1][0] +
b[3][2] * a[2][0] +
b[3][3] * a[3][0];
63 result[3][1] =
b[3][0] * a[0][1] +
b[3][1] * a[1][1] +
b[3][2] * a[2][1] +
b[3][3] * a[3][1];
64 result[3][2] =
b[3][0] * a[0][2] +
b[3][1] * a[1][2] +
b[3][2] * a[2][2] +
b[3][3] * a[3][2];
65 result[3][3] =
b[3][0] * a[0][3] +
b[3][1] * a[1][3] +
b[3][2] * a[2][3] +
b[3][3] * a[3][3];
77 __m128
A0 = _mm_set_ps(0, a[0][2], a[0][1], a[0][0]);
78 __m128
A1 = _mm_set_ps(0, a[1][2], a[1][1], a[1][0]);
79 __m128
A2 = _mm_set_ps(0, a[2][2], a[2][1], a[2][0]);
81 for (
int i = 0; i < 2; i++) {
82 __m128 B0 = _mm_set1_ps(
b[i][0]);
83 __m128 B1 = _mm_set1_ps(
b[i][1]);
84 __m128 B2 = _mm_set1_ps(
b[i][2]);
85 __m128
sum = _mm_add_ps(_mm_add_ps(_mm_mul_ps(B0,
A0), _mm_mul_ps(B1,
A1)),
87 _mm_storeu_ps(result[i],
sum);
90 _mm_storeu_ps(result[1],
sum[1]);
92 _mm_store_ss(&result[2][0],
sum[2]);
93 sum[2] = _mm_shuffle_ps(
sum[2],
sum[2], _MM_SHUFFLE(3, 2, 1, 1));
94 _mm_store_ss(&result[2][1],
sum[2]);
95 sum[2] = _mm_shuffle_ps(
sum[2],
sum[2], _MM_SHUFFLE(3, 2, 1, 2));
96 _mm_store_ss(&result[2][2],
sum[2]);
100 result[0][0] =
b[0][0] * a[0][0] +
b[0][1] * a[1][0] +
b[0][2] * a[2][0];
101 result[0][1] =
b[0][0] * a[0][1] +
b[0][1] * a[1][1] +
b[0][2] * a[2][1];
102 result[0][2] =
b[0][0] * a[0][2] +
b[0][1] * a[1][2] +
b[0][2] * a[2][2];
104 result[1][0] =
b[1][0] * a[0][0] +
b[1][1] * a[1][0] +
b[1][2] * a[2][0];
105 result[1][1] =
b[1][0] * a[0][1] +
b[1][1] * a[1][1] +
b[1][2] * a[2][1];
106 result[1][2] =
b[1][0] * a[0][2] +
b[1][1] * a[1][2] +
b[1][2] * a[2][2];
108 result[2][0] =
b[2][0] * a[0][0] +
b[2][1] * a[1][0] +
b[2][2] * a[2][0];
109 result[2][1] =
b[2][0] * a[0][1] +
b[2][1] * a[1][1] +
b[2][2] * a[2][1];
110 result[2][2] =
b[2][0] * a[0][2] +
b[2][1] * a[1][2] +
b[2][2] * a[2][2];
144 return Eigen::Map<const Eigen::Matrix<T, 3, 3>, 0, Eigen::Stride<4, 1>>(mat.
base_ptr())
160 unroll<Size>([&](
auto c) {
161 unroll<Size>([&](
auto r) {
164 unroll<Size>([&](
auto m_c) {
165 unroll<Size>([&](
auto m_r) {
166 if (m_c != c && m_r != r) {
167 int d_c = (m_c < c) ? m_c : (m_c - 1);
168 int d_r = (m_r < r) ? m_r : (m_r - 1);
169 tmp[d_c][d_r] = mat[m_c][m_r];
175 adj[r][c] = ((c + r) & 1) ? -minor : minor;
194template<
typename T,
int Size>
198 Eigen::Map<const Eigen::Matrix<T, Size, Size>>
M(mat.
base_ptr());
199 Eigen::Map<Eigen::Matrix<T, Size, Size>>
R(result.base_ptr());
200 M.computeInverseWithCheck(
R, r_success, 0.0f);
214template<
typename T,
int Size>
235 using namespace Eigen;
236 using MatrixT = Eigen::Matrix<T, Size, Size>;
237 using VectorT = Eigen::Matrix<T, Size, 1>;
245 using MatrixDynamicT = Eigen::Matrix<T, Dynamic, Dynamic>;
246 JacobiSVD<MatrixDynamicT, NoQRPreconditioner> svd(
247 Eigen::Map<const MatrixDynamicT>(mat.
base_ptr(), Size, Size), ComputeThinU | ComputeThinV);
249 Eigen::Map<MatrixT>(
U.base_ptr()) = svd.matrixU();
250 (Eigen::Map<VectorT>(S_val)) = svd.singularValues();
251 Eigen::Map<MatrixT>(
V.base_ptr()) = svd.matrixV();
255 unroll<Size>([&](
auto i) { S_val[i] = (S_val[i] < epsilon) ?
T(0) : (
T(1) / S_val[i]); });
257 W = from_scale<MatBase<T, Size, Size>>(S_val);
296 using namespace Eigen;
297 using MatrixT = Eigen::Matrix<T, 3, 3>;
298 using VectorT = Eigen::Matrix<T, 3, 1>;
305 using MatrixDynamicT = Eigen::Matrix<T, Dynamic, Dynamic>;
306 JacobiSVD<MatrixDynamicT, NoQRPreconditioner> svd(
307 Eigen::Map<const MatrixDynamicT>(mat3.
base_ptr(), 3, 3), ComputeThinU | ComputeThinV);
309 Eigen::Map<MatrixT>(
W.base_ptr()) = svd.matrixU();
310 (Eigen::Map<VectorT>(S_val)) = svd.singularValues();
349 if (is_negative(U_A)) {
353 if (is_negative(U_B)) {
361 Mat3T
U = from_rotation<Mat3T>(quat);
380 result.location() = interpolate(loc_a, loc_b, t);
394 Vec3T a_scale, b_scale;
395 QuaternionT a_quat, b_quat;
396 to_rot_scale<true>(a, a_quat, a_scale);
397 to_rot_scale<true>(
b, b_quat, b_scale);
399 const Vec3T scale = interpolate(a_scale, b_scale, t);
400 const QuaternionT rotation = interpolate(a_quat, b_quat, t);
401 return from_rot_scale<MatBase<T, 3, 3>>(rotation, scale);
414 Vec3T a_scale, b_scale;
415 QuaternionT a_quat, b_quat;
416 to_loc_rot_scale<true>(a, a_loc, a_quat, a_scale);
417 to_loc_rot_scale<true>(
b, b_loc, b_quat, b_scale);
419 const Vec3T location = interpolate(a_loc, b_loc, t);
420 const Vec3T scale = interpolate(a_scale, b_scale, t);
421 const QuaternionT rotation = interpolate(a_quat, b_quat, t);
422 return from_loc_rot_scale<MatBase<T, 4, 4>>(location, rotation, scale);
451 float ha2 = 0.5f *
math::atan2(x_axis.y, x_axis.x);
465template void normalized_to_eul2(
const float3x3 &mat,
466 Euler3Base<float> &eul1,
467 Euler3Base<float> &eul2);
468template void normalized_to_eul2(
const float3x3 &mat,
469 EulerXYZBase<float> &eul1,
470 EulerXYZBase<float> &eul2);
471template void normalized_to_eul2(
const double3x3 &mat,
472 EulerXYZBase<double> &eul1,
473 EulerXYZBase<double> &eul2);
475template QuaternionBase<float> normalized_to_quat_with_checks(
const float3x3 &mat);
476template QuaternionBase<double> normalized_to_quat_with_checks(
const double3x3 &mat);
497template float3 project_point(
const float4x4 &mat,
const float3 &point);
498template float2 project_point(
const float3x3 &mat,
const float2 &point);
500namespace projection {
502template float4x4 orthographic(
503 float left,
float right,
float bottom,
float top,
float near_clip,
float far_clip);
504template float4x4 perspective(
505 float left,
float right,
float bottom,
float top,
float near_clip,
float far_clip);
507 float left,
float right,
float bottom,
float top,
float near_clip);
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Map
btMatrix3x3 adjoint() const
Return the adjoint of the matrix.
btMatrix3x3 transpose() const
Return the transpose of the matrix.
btScalar determinant() const
Return the determinant of the matrix.
static T sum(const btAlignedObjectArray< T > &items)
SIMD_FORCE_INLINE btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
local_group_size(16, 16) .push_constant(Type b
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
MatBase< T, 4, 4 > perspective_infinite(T left, T right, T bottom, T top, T near_clip)
Create a perspective projection matrix using OpenGL coordinate convention: Maps each axis range to [-...
QuaternionBase< T > conjugate(const QuaternionBase< T > &a)
T cos(const AngleRadianBase< T > &a)
QuaternionBase< T > to_quaternion(const AxisAngleBase< T, AngleT > &axis_angle)
Quaternion to_quaternion_legacy(const float3x3 &mat)
MatBase< T, Size, Size > pseudo_invert(const MatBase< T, Size, Size > &mat, T epsilon=1e-8)
T interpolate(const T &a, const T &b, const FactorT &t)
T atan2(const T &y, const T &x)
MatBase< T, 3, 3 > interpolate_fast(const MatBase< T, 3, 3 > &a, const MatBase< T, 3, 3 > &b, T t)
static void polar_decompose(const MatBase< T, 3, 3 > &mat3, MatBase< T, 3, 3 > &r_U, MatBase< T, 3, 3 > &r_P)
T sin(const AngleRadianBase< T > &a)
MatBase< T, NumCol, NumRow > interpolate_linear(const MatBase< T, NumCol, NumRow > &a, const MatBase< T, NumCol, NumRow > &b, T t)
MatBase< float, 2, 2 > float2x2
MatBase< double, 3, 3 > double3x3
MatBase< double, 2, 2 > double2x2
MatBase< T, B_NumCol, A_NumRow > operator*(const MatBase< T, A_NumCol, A_NumRow > &a, const MatBase< T, B_NumCol, B_NumRow > &b)
MatBase< double, 4, 4 > double4x4
Frequency::GEOMETRY nor[]
const T * base_ptr() const
CCL_NAMESPACE_BEGIN struct Window V