main sync #3

Merged
Patrick Busch merged 318 commits from blender/blender:main into main 2023-03-17 15:52:21 +01:00
4 changed files with 9 additions and 4 deletions
Showing only changes of commit 3982aa922e - Show all commits

View File

@ -30,8 +30,8 @@ AxisAngle<T, AngleT>::AxisAngle(const VecBase<T, 3> &axis, const AngleT &angle)
template<typename T, typename AngleT> template<typename T, typename AngleT>
AxisAngle<T, AngleT>::AxisAngle(const AxisSigned axis, const AngleT &angle) AxisAngle<T, AngleT>::AxisAngle(const AxisSigned axis, const AngleT &angle)
{ {
this->axis_ = VecBase<T, 3>(axis); axis_ = to_vector<VecBase<T, 3>>(axis);
this->angle_ = angle; angle_ = angle;
} }
template<typename T, typename AngleT> template<typename T, typename AngleT>

View File

@ -455,8 +455,8 @@ struct CartesianBasis {
const AxisSigned b_forward) const AxisSigned b_forward)
{ {
/* Pick predictable next axis. */ /* Pick predictable next axis. */
AxisSigned a_up = AxisSigned(abs(a_forward.next_after())); AxisSigned a_up = abs(a_forward.next_after());
AxisSigned b_up = AxisSigned(abs(b_forward.next_after())); AxisSigned b_up = abs(b_forward.next_after());
if (sign(a_forward) != sign(b_forward)) { if (sign(a_forward) != sign(b_forward)) {
/* Flip both axis (up and right) so resulting rotation matrix sign remains positive. */ /* Flip both axis (up and right) so resulting rotation matrix sign remains positive. */

View File

@ -316,6 +316,10 @@ TEST(math_rotation, AxisAngleConstructors)
EXPECT_NEAR(b.angle().sin(), 1.0f, 1e-4); EXPECT_NEAR(b.angle().sin(), 1.0f, 1e-4);
EXPECT_NEAR(b.angle().cos(), 0.0f, 1e-4); EXPECT_NEAR(b.angle().cos(), 0.0f, 1e-4);
AxisAngle axis_angle_basis = AxisAngle(AxisSigned::Y_NEG, M_PI);
EXPECT_EQ(axis_angle_basis.axis(), float3(0.0f, -1.0f, 0.0f));
EXPECT_EQ(axis_angle_basis.angle(), M_PI);
AxisAngle c({1.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}); AxisAngle c({1.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f});
EXPECT_V3_NEAR(c.axis(), float3(0, 0, 1), 1e-4); EXPECT_V3_NEAR(c.axis(), float3(0, 0, 1), 1e-4);
EXPECT_NEAR(float(c.angle()), M_PI_2, 1e-4); EXPECT_NEAR(float(c.angle()), M_PI_2, 1e-4);

View File

@ -308,6 +308,7 @@ TEST(math_rotation_types, AngleFraction)
EXPECT_EQ(AngleCartesian(-pi * 1 / 4).sin(), T(-M_SQRT1_2)); EXPECT_EQ(AngleCartesian(-pi * 1 / 4).sin(), T(-M_SQRT1_2));
EXPECT_EQ(AngleCartesian(-pi * 3 / 4).sin(), T(-M_SQRT1_2)); EXPECT_EQ(AngleCartesian(-pi * 3 / 4).sin(), T(-M_SQRT1_2));
} }
TEST(math_rotation_types, TypeConversion) TEST(math_rotation_types, TypeConversion)
{ {
/* All the same rotation. */ /* All the same rotation. */