# (SOLVED)Should these methods be VOID? (jme3.Math)

I found some methods are void (in jme3.Math):

Quaternions - slerp(Quaternion q2, float changeAmnt)

Transrom - interpolateTransforms(Transform t1, Transform t2, float delta)

So I cannot make such operations in simpleUpdate() because of VOID:

quatA.slerp(quatB, tpf);

Transform transC = new Transform().interpolateTransforms(transA, transB, tpf);

These method are vital!!! Especially for Transform. I think these methods should be with return value (Quaternion/Transform)!

But some methods with interpolation (which work in the same way as methods above) are not void and have a result:

slerp(Quaternion q1, Quaternion q2, float t) - returns a Quaternion

interpolate(Vector3f finalVec, float changeAmnt) - returns Vector3f

interpolate(Vector3f beginVec, Vector3f finalVec, float changeAmnt) - returns Vector3f

Core Devs, I’m a newbie in programming, possibly I’m wrong. Just give me feedback, please,

Guys, please give me feedback about JME Math! These methods does not work in my case because they are VOID. But I think they should return Quaternion/Trasform.

Quaternion class: slerp(Quaternion q2, float changeAmnt)

Transform class: interpolateTransforms(Transform t1, Transform t2, float delta)

These methods are VOID. But they should return Quaternion/Transform.

Ok, now I will make some examples with SimpleUpdate() method:

Quaternions. In this case it works:

[java]@Override

public void simpleUpdate(float tpf)

{

float move = tpf;

Quaternion quatA = new Quaternion().fromAngles(0, 0.1f, 0);

Quaternion quatB = new Quaternion().fromAngles(0, 0.5f, 0);

Quaternion quatC = new Quaternion().slerp(quatA, quatB, move);

}[/java]

Quaternions. In this case it does not compile because of slerp VOID method. But it should return Quaternion. :

[java]@Override

public void simpleUpdate(float tpf)

{

float move = tpf;

Quaternion quatA = new Quaternion().fromAngles(0, 0.1f, 0);

Quaternion quatB = new Quaternion().fromAngles(0, 0.5f, 0);

Quaternion quatC = quatA.slerp(quatB, move);

// Quaternion quatC = new Quaternion().slerp(quatA, quatB, move);

}[/java]

Note, that SLERP is in both examples.

It writes: Incompatible type. Found: void.

Ok, now about Transform. As I understand, interpolateTransforms() (Transform class) method should work like interpolate() (Vector3f class) method. Interpolate() method returns Vector3f.

Example with interpolate() method. Works ok! :

[java]@Override

public void simpleUpdate(float tpf)

{

float move = tpf;

Vector3f vecA = new Vector3f(0, 1, 0);

Vector3f vecB = new Vector3f(0, 2, 0);

Vector3f vecC = vecA.interpolate(vecB, move);

}[/java]

So, that example is ok.

Example with interpolateTransforms() method. It does not work because of VOID. :

[java]@Override

public void simpleUpdate(float tpf)

{

float move = tpf;

Vector3f vecA = new Vector3f(0, 1, 0);

Vector3f vecB = new Vector3f(0, 2, 0);

//Vector3f vecC = vecA.interpolate(vecB, move);

Transform transA = new Transform().setTranslation(vecA);

Transform transB = new Transform().setTranslation(vecB);

Transform transC = new Transform().interpolateTransforms(transA, transB, move);

}[/java]

It writes: Incompatible type. Found: void.

CoreDevs, please give me feedback. Is that bug or not?

[java] Quaternion quatC = quatA.slerp(quatB, move);[/java]

use:

[java]Quaternion quatC = quatA.clone();

quatC.slerp(quatB, move);[/java]

That will do the trick.

1 Like

It’s the same for Transforms.

[java]

Transform a = new Transform(Vector3f.ZERO);

Transform b = new Transform(Vector3f.ZERO);

Transform c = new Transform();

c.interpolateTransforms(a, b, 5);

[/java]

THANK YOU GUYS!!! I LOVE JME!!