+ Post New Thread
Results 1 to 5 of 5
  1. #1
    Full Member level 4
    Points: 2,304, Level: 11
    Achievements:
    7 years registered

    Join Date
    Aug 2011
    Posts
    193
    Helped
    0 / 0
    Points
    2,304
    Level
    11

    Dealing with Q15 for arc Tan function

    Hi

    I am using dspic libq library to experiment with Q15 functions. The difficulty I am facing is that _Q15sinPI() and _Q15cosPI return in range -32768 to +32767 corresponding to -pi to +pi. But _Q15atanYByXByPI() deals only on -45 to +45 degrees and returns-8192 to +8192. This gives me only solutions to first and 4th quadrant. How do derive the arc tan for 2nd and 3rd quadrant?

    •   AltAdvertisement

        
       

  2. #2
    Super Moderator
    Points: 260,228, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,443
    Helped
    13827 / 13827
    Points
    260,228
    Level
    100

    Re: Dealing with Q15 for arc Tan function

    The restriction is necessary due to Q15 number range. You get +/- 45..90 degree range by flipping x and y. Other two quadrants by manipulating x and y sign.



    •   AltAdvertisement

        
       

  3. #3
    Full Member level 4
    Points: 2,304, Level: 11
    Achievements:
    7 years registered

    Join Date
    Aug 2011
    Posts
    193
    Helped
    0 / 0
    Points
    2,304
    Level
    11

    Re: Dealing with Q15 for arc Tan function

    Hi

    _Q15 y = Q15(0.866);
    _Q15 x = Q15(0.5);

    _Q15 check = _Q15atanYByXByPI(x,y);

    returns 8192 ( 45 degrees) and not 60 degrees. Even if I flip , results are same
    Last edited by garimella; 30th March 2019 at 14:20. Reason: adding additional information



    •   AltAdvertisement

        
       

  4. #4
    Super Moderator
    Points: 260,228, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,443
    Helped
    13827 / 13827
    Points
    260,228
    Level
    100

    Re: Dealing with Q15 for arc Tan function

    returns 8192 ( 45 degrees) and not 60 degrees.
    Can't return higher number by design.

    Even if I flip , results are same
    Don't know why, may be the library is faulty.



  5. #5
    Full Member level 4
    Points: 2,304, Level: 11
    Achievements:
    7 years registered

    Join Date
    Aug 2011
    Posts
    193
    Helped
    0 / 0
    Points
    2,304
    Level
    11

    Re: Dealing with Q15 for arc Tan function

    Can you share the link or lib file that works



--[[ ]]--