mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
[wpimath] Quaternion::Log(): Remove duplicate calls to norm() (#6358)
This commit is contained in:
@@ -285,11 +285,12 @@ public class Quaternion implements ProtobufSerializable, StructSerializable {
|
||||
* @return The logarithm of this quaternion.
|
||||
*/
|
||||
public Quaternion log() {
|
||||
var scalar = Math.log(norm());
|
||||
var norm = norm();
|
||||
var scalar = Math.log(norm);
|
||||
|
||||
var v_norm = Math.sqrt(getX() * getX() + getY() * getY() + getZ() * getZ());
|
||||
|
||||
var s_norm = getW() / norm();
|
||||
var s_norm = getW() / norm;
|
||||
|
||||
if (Math.abs(s_norm + 1) < 1e-9) {
|
||||
return new Quaternion(scalar, -Math.PI, 0, 0);
|
||||
|
||||
@@ -136,11 +136,12 @@ Quaternion Quaternion::Log(const Quaternion& other) const {
|
||||
}
|
||||
|
||||
Quaternion Quaternion::Log() const {
|
||||
double scalar = std::log(Norm());
|
||||
double norm = Norm();
|
||||
double scalar = std::log(norm);
|
||||
|
||||
double v_norm = m_v.norm();
|
||||
|
||||
double s_norm = W() / Norm();
|
||||
double s_norm = W() / norm;
|
||||
|
||||
if (std::abs(s_norm + 1) < 1e-9) {
|
||||
return Quaternion{scalar, -std::numbers::pi, 0, 0};
|
||||
|
||||
Reference in New Issue
Block a user