@Test public void testMultiply() { Quaternion quaternion = Quaternion.fromAxisAngle(Vector3.zAxis(), Math.PI / 2); Quaternion inverse = quaternion.invert(); Quaternion rotated = quaternion.multiply(inverse); assertEquals(1, rotated.getW(), 1e-9); }
public Quaternion multiply(Quaternion other) { return new Quaternion(w * other.x + x * other.w + y * other.z - z * other.y, w * other.y + y * other.w + z * other.x - x * other.z, w * other.z + z * other.w + x * other.y - y * other.x, w * other.w - x * other.x - y * other.y - z * other.z); }
Quaternion { public Quaternion multiply(Quaternion other) { return new Quaternion(w * other.x + x * other.w + y * other.z - z * other.y, w * other.y + y * other.w + z * other.x - x * other.z, w * other.z + z * other.w + x * other.y - y * other.x, w * other.w - x * other.x - y * other.y - z * other.z); } }
Quaternion { public Quaternion multiply(Quaternion other) { return new Quaternion(w * other.x + x * other.w + y * other.z - z * other.y, w * other.y + y * other.w + z * other.x - x * other.z, w * other.z + z * other.w + x * other.y - y * other.x, w * other.w - x * other.x - y * other.y - z * other.z); } Quaternion(double x, double y, double z, double w); }
Quaternion { public Quaternion multiply(Quaternion other) { return new Quaternion(w * other.x + x * other.w + y * other.z - z * other.y, w * other.y + y * other.w + z * other.x - x * other.z, w * other.z + z * other.w + x * other.y - y * other.x, w * other.w - x * other.x - y * other.y - z * other.z); } Quaternion(double x, double y, double z, double w); static Quaternion fromAxisAngle(Vector3 axis, double angle); static Quaternion fromQuaternionMessage(geometry_msgs.Quaternion message); static Quaternion rotationBetweenVectors(Vector3 vector1, Vector3 vector2); static Quaternion identity(); Quaternion scale(double factor); Quaternion conjugate(); Quaternion invert(); Quaternion normalize(); Quaternion multiply(Quaternion other); Vector3 rotateAndScaleVector(Vector3 vector); double getX(); double getY(); double getZ(); double getW(); double getMagnitudeSquared(); double getMagnitude(); boolean isAlmostNeutral(double epsilon); geometry_msgs.Quaternion toQuaternionMessage(geometry_msgs.Quaternion result); boolean almostEquals(Quaternion other, double epsilon); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }
Quaternion { public Quaternion multiply(Quaternion other) { return new Quaternion(w * other.x + x * other.w + y * other.z - z * other.y, w * other.y + y * other.w + z * other.x - x * other.z, w * other.z + z * other.w + x * other.y - y * other.x, w * other.w - x * other.x - y * other.y - z * other.z); } Quaternion(double x, double y, double z, double w); static Quaternion fromAxisAngle(Vector3 axis, double angle); static Quaternion fromQuaternionMessage(geometry_msgs.Quaternion message); static Quaternion rotationBetweenVectors(Vector3 vector1, Vector3 vector2); static Quaternion identity(); Quaternion scale(double factor); Quaternion conjugate(); Quaternion invert(); Quaternion normalize(); Quaternion multiply(Quaternion other); Vector3 rotateAndScaleVector(Vector3 vector); double getX(); double getY(); double getZ(); double getW(); double getMagnitudeSquared(); double getMagnitude(); boolean isAlmostNeutral(double epsilon); geometry_msgs.Quaternion toQuaternionMessage(geometry_msgs.Quaternion result); boolean almostEquals(Quaternion other, double epsilon); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }