https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:scenegraph_for_dummies
In case it interests someone:
If I add those boxes in the initialize method of the appState, then they are incorrectly set at the origin of the vehicleNode.
Also, I need to wait for a tpf value of 2 before adding the boxes, in the update method of the appState, or they will be set at the origin.
Not saying itās a bug, because Iām oblivious to most of whatās going under the hood.
I thought that cos2 was the equivalent of cos apart from the fact it uses radians instead of degrees?
[java]
float x, z;
float angle = FastMath.PI / 8;
x = FastMath.cos2(angle);
System.out.println(āradians cos2ā);
System.out.println("x: " + x);
float angle2 = (float)Math.toDegrees(angle);
x = FastMath.cos(angle2);
System.out.println(ādegrees cosā);
System.out.println("x: " + x);
[/java]
Outputs:
radians cos2
x: 0.9238795
degrees cos
x: -0.87330467
Aām I being an idiot?
From looking at the code I donāt know why the sin/cos2 does what they do and the javadoc isnāt helping. I think it tries to optimize something by keeping the values in a certain quadrant but thatās just guessing.
It eventually ends up in Math.sin or Math.cos anyway. All methods are in radians so thatās not it either.
Both methods take radians. If you ever see a serious trig function that takes raw degrees then you should be shocked. Itās always radians.
I donāt see a good reason to use the cos2/sin2/etc. versions. The math looks really dodgy to me and most game code will be keeping the angles within reasonable limits anyway.
Thx jmaasing and pspeed⦠I guess my low math skillz show here :D.