Copy link to clipboard
Copied
Anyone know if there's some special way to handle an AngleParam?
Currently I'm having to divide the value by some ridiculous number (about 3753600) to make it usable as degrees.
Here's the function I'm feeding it into (as "rot"):
static PF_PixelFloat rotateY(PF_FpLong rot, PF_PixelFloat inVec){
PF_FpLong tmpX = inVec.red;
PF_FpLong tmpZ = inVec.blue;
inVec.red = tmpX*cosf(rot) + tmpZ*sinf(rot);
inVec.blue = tmpZ*cosf(rot) - tmpX*sinf(rot);
return inVec;
}
I figured it would just be a matter of converting degrees to radians, but apparently not.
1 Correct answer
Hi,
angle params return a 'Fixed' value.
So if you want to convert it to float, you do have to divide it or just use the FIX_2_FLOAT macro like this.
myAngleInDegrees = FIX_2_FLOAT(params[myAngle]->u.ad.value);
And if you need it in radians (your function using cos and sin probably need it), multiply it by PF_RAD_PER_DEGREE
Cheers,
François
Copy link to clipboard
Copied
Hi,
angle params return a 'Fixed' value.
So if you want to convert it to float, you do have to divide it or just use the FIX_2_FLOAT macro like this.
myAngleInDegrees = FIX_2_FLOAT(params[myAngle]->u.ad.value);
And if you need it in radians (your function using cos and sin probably need it), multiply it by PF_RAD_PER_DEGREE
Cheers,
François
Copy link to clipboard
Copied
Ah, I thought I was missing a step. I was multiplying by PF_RAD_PER_DEGREE, but that obviously didn't work.
Thanks again!
Copy link to clipboard
Copied
Don't forget PF_AngleParamSuite1, which will return your angle param value as a floating point number. This result is still in radians so you'll still need to multiply by PF_RAD_PER_DEGREE, but it bypasses the horrible fixed-point maths.
Page 108 of the SDK guide.
Copy link to clipboard
Copied
Thanks Christian. I'll check that out too.

