Out of date: Example - Use Slerp to Rotate Between two Quaternions

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math#slerp

//the rotation half-way between these two
Quaternion q3 = q1.slerp(q2, 0.5f);//Failed because of Quaternion required instead of void

In 3.0 MUST be like that:

    /*
     You can interpolate rotations between two quaternions using spherical linear
     interpolation (slerp).
     */
    Quaternion Xroll45 = new Quaternion();
    Xroll45.fromAngleAxis(45 * FastMath.DEG_TO_RAD, Vector3f.UNIT_X);

//
Quaternion Yroll45 = new Quaternion();
Yroll45.fromAngleAxis(45 * FastMath.DEG_TO_RAD, Vector3f.UNIT_Y);
/*
the rotation half - way between these two
*/
Quaternion halfBetweenXroll45Yroll45 = new Quaternion();
halfBetweenXroll45Yroll45.slerp(Yroll45, Yroll45, 0.5f);
geom2.setLocalRotation(halfBetweenXroll45Yroll45);

Sorry for mistake

halfBetweenXroll45Yroll45.slerp(Xroll45, Yroll45, 0.5f);

instead of:

halfBetweenXroll45Yroll45.slerp(Yroll45, Yroll45, 0.5f);

ofc

1 Like
@normen said:

Example in documentation
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math#slerp
is incorrect must be updated to something like that:

halfBetweenXroll45Yroll45.slerp(Xroll45, Yroll45, 0.5f);

Because it’s impossible to write:

Quaternion q3 = q1.slerp(q2, 0.5f);

It will cause:

java.lang.RuntimeException: Uncompilable source code - incompatible types
required: com.jme3.math.Quaternion
found: void

Ah, you can actually fix such errors yourself by pressing the little “edit” button at the bottom of each paragraph.

@normen said: Ah, you can actually fix such errors yourself by pressing the little "edit" button at the bottom of each paragraph.

Ok Normen, it’s done.

2 Likes