| 454 | } |
| 455 | |
| 456 | void Quaternion::FindBetween(const Float3& from, const Float3& to, Quaternion& result) |
| 457 | { |
| 458 | // http://lolengine.net/blog/2014/02/24/quaternion-from-two-vectors-final |
| 459 | const float normFromNormTo = Math::Sqrt(from.LengthSquared() * to.LengthSquared()); |
| 460 | if (normFromNormTo < ZeroTolerance) |
| 461 | { |
| 462 | result = Identity; |
| 463 | return; |
| 464 | } |
| 465 | const float w = normFromNormTo + Float3::Dot(from, to); |
| 466 | if (w < 1.e-6f * normFromNormTo) |
| 467 | { |
| 468 | result = Math::Abs(from.X) > Math::Abs(from.Z) |
| 469 | ? Quaternion(-from.Y, from.X, 0.0f, 0.0f) |
| 470 | : Quaternion(0.0f, -from.Z, from.Y, 0.0f); |
| 471 | } |
| 472 | else |
| 473 | { |
| 474 | const Float3 cross = Float3::Cross(from, to); |
| 475 | result = Quaternion(cross.X, cross.Y, cross.Z, w); |
| 476 | } |
| 477 | result.Normalize(); |
| 478 | } |
| 479 | |
| 480 | void Quaternion::Slerp(const Quaternion& start, const Quaternion& end, float amount, Quaternion& result) |
| 481 | { |
nothing calls this directly
no test coverage detected