Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/intern/math_rotation.cc
- This file was added.
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | |||||
| /** \file | |||||
| * \ingroup bli | |||||
| */ | |||||
| #include "BLI_math_vector.hh" | |||||
JacquesLucke: Wrong header, I get a warning below because of that. | |||||
| namespace blender::math { | |||||
| float3 rotate_direction_around_axis(const float3 &direction, const float3 &axis, const float angle) | |||||
| { | |||||
| BLI_assert(math::distance(math::length_squared(direction), 1.0f) < BLI_ASSERT_UNIT_EPSILON); | |||||
JacquesLuckeUnsubmitted Not Done Inline ActionsHow about using something like BLI_ASSERT_UNIT_V3? JacquesLucke: How about using something like `BLI_ASSERT_UNIT_V3`?
If inputs are expected to be normalized… | |||||
| BLI_assert(math::distance(math::length_squared(axis), 1.0f) < BLI_ASSERT_UNIT_EPSILON); | |||||
| const float3 axis_scaled = axis * math::dot(direction, axis); | |||||
| const float3 diff = direction - axis_scaled; | |||||
| const float3 cross = math::cross(axis, diff); | |||||
| return axis_scaled + diff * std::cos(angle) + cross * std::sin(angle); | |||||
| } | |||||
| } // namespace blender::math | |||||
Wrong header, I get a warning below because of that.