[wpimath] Quaternion::Log(): Remove duplicate calls to norm() (#6358)

This commit is contained in:
Thad House
2024-02-10 10:41:19 -08:00
committed by GitHub
parent 300419c151
commit e9c744c456
2 changed files with 6 additions and 4 deletions

View File

@@ -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);