Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Strange AngleParam value

Explorer ,
Aug 25, 2016 Aug 25, 2016

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.

TOPICS
SDK
458
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Aug 26, 2016 Aug 26, 2016

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

Translate
Enthusiast ,
Aug 26, 2016 Aug 26, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 26, 2016 Aug 26, 2016

Ah, I thought I was missing a step. I was multiplying by PF_RAD_PER_DEGREE, but that obviously didn't work.

Thanks again!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 26, 2016 Aug 26, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 26, 2016 Aug 26, 2016
LATEST

Thanks Christian. I'll check that out too.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines