12#include <Eigen/Geometry>
29static inline double Clamp(
const double x,
const double min,
const double max)
57static inline Eigen::Matrix3d
RotationMatrix(
double sine,
double cosine,
int axis)
60 return CreateMatrix(1.0, 0.0, 0.0, 0.0, cosine, -sine, 0.0, sine, cosine);
63 return CreateMatrix(cosine, 0.0, sine, 0.0, 1.0, 0.0, -sine, 0.0, cosine);
66 return CreateMatrix(cosine, -sine, 0.0, sine, cosine, 0.0, 0.0, 0.0, 1.0);
77 double t =
sqrt(
R(0, 0) *
R(0, 0) +
R(0, 1) *
R(0, 1));
81 return -atan2(
R(1, 2),
R(2, 2));
84 return atan2(-
R(0, 2), t);
87 return -atan2(
R(0, 1),
R(0, 0));
92 return -atan2(-
R(2, 1),
R(1, 1));
95 return atan2(-
R(0, 2), t);
117static inline Eigen::Vector3d
normalize(
const Eigen::Vector3d &
v)
121 double len =
v.norm();
122 return FuzzyZero(
len) ? Eigen::Vector3d(0, 0, 0) : Eigen::Vector3d(
v /
len);
125static inline double angle(
const Eigen::Vector3d &v1,
const Eigen::Vector3d &
v2)
133 double qy =
R(0, 2) -
R(2, 0);
134 double qw =
R(0, 0) +
R(1, 1) +
R(2, 2) + 1;
136 double tau = 2.0 * atan2(qy, qw);
155 R =
R * T.transpose();
164 double num = 2.0 * (1.0 +
R(1, 1));
171 return Eigen::Vector3d(0.0, tau, 1.0);
174 num = 1.0 /
sqrt(num);
175 double ax = -
R(2, 1) * num;
176 double az =
R(0, 1) * num;
178 return Eigen::Vector3d(ax, tau, az);
184 double sine2 = ax * ax + az * az;
185 double cosine2 =
sqrt((sine2 >= 1.0) ? 0.0 : 1.0 - sine2);
188 Eigen::Matrix3d S(Eigen::Quaterniond(-cosine2, ax, 0.0, az));
195 Eigen::Vector3d delta = Eigen::Vector3d(
R(2, 1) -
R(1, 2),
R(0, 2) -
R(2, 0),
R(1, 0) -
R(0, 1));
197 double c =
safe_acos((
R(0, 0) +
R(1, 1) +
R(2, 2) - 1) / 2);
198 double l = delta.norm();
207static inline bool EllipseClamp(
double &ax,
double &az,
double *amin,
double *amax)
209 double xlim, zlim,
x,
z;
230 if (x <= xlim &&
z <= zlim) {
242 double invx = 1.0 / (xlim * xlim);
243 double invz = 1.0 / (zlim * zlim);
245 if ((x * x * invx +
z *
z * invz) <= 1.0) {
256 x =
sqrt(1.0 / (invx + invz * rico * rico));
264 ax = (ax < 0.0) ? -x :
x;
265 az = (az < 0.0) ? -
z :
z;
static double EulerAngleFromMatrix(const Eigen::Matrix3d &R, int axis)
static void RemoveTwist(Eigen::Matrix3d &R)
static bool EllipseClamp(double &ax, double &az, double *amin, double *amax)
static Eigen::Matrix3d CreateMatrix(double xx, double xy, double xz, double yx, double yy, double yz, double zx, double zy, double zz)
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
static Eigen::Vector3d MatrixToAxisAngle(const Eigen::Matrix3d &R)
static const double IK_EPSILON
static double ComputeTwist(const Eigen::Matrix3d &R)
static double safe_acos(double f)
static Eigen::Matrix3d RotationMatrix(double sine, double cosine, int axis)
static Eigen::Matrix3d ComputeTwistMatrix(double tau)
static Eigen::Vector3d SphericalRangeParameters(const Eigen::Matrix3d &R)
static Eigen::Matrix3d ComputeSwingMatrix(double ax, double az)
static bool FuzzyZero(double x)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
SIMD_FORCE_INLINE btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
ccl_device_inline float2 fabs(const float2 a)
ccl_device_inline float3 cos(float3 v)