User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11

Thread: finding the angle of an analog joystick

  1. #1
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,310
    Mentioned
    28 Post(s)
    Tagged
    0 Thread(s)

    finding the angle of an analog joystick

    Hey Guys,

    So, I am trying to manualy calculate the angle of an xbox360 analog stick. The gamepad returns values between -100 and 100 for the horizontal and vertical position. I was trying to apply arctan2 to make it work, but am not able to get it to return values between 0 and 360.

    Can anyone offer a method to approach this?

    Thanks in advance,

    Mobichan

  2. #2
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Re: finding the angle of an analog joystick

    It returns a value between -180 and 180, not 0 and 360. Maybe that was your problem?
    Working as fast as I can on Fusion 3

  3. #3
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,310
    Mentioned
    28 Post(s)
    Tagged
    0 Thread(s)

    Re: finding the angle of an analog joystick

    I am actually trying to figure out how to deal with working with a vetical and horizontal range, instead of having a start x/y and end x/y. But I am so used to using atan2, that I don't know where to start.

    My initial thought was to use atan2(stickYPos, StickXPos) but that is yielding values between 0 and 3.14.

  4. #4
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Re: finding the angle of an analog joystick

    Well, think of the start (X,Y) as (0,0) and the end (X,Y) as the joystick position values.
    Working as fast as I can on Fusion 3

  5. #5
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,310
    Mentioned
    28 Post(s)
    Tagged
    0 Thread(s)

    Re: finding the angle of an analog joystick

    I thought that was what the formula I wrote would do, but it didn't return values between -180 and 180. I had also tried atan2(stickYPos - 0, StickXPos - 0) but no luck.

  6. #6
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Re: finding the angle of an analog joystick

    That's because the formula in computers is:
    ATan2(0-StickYPos, StickXPos-0)
    Working as fast as I can on Fusion 3

  7. #7
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,310
    Mentioned
    28 Post(s)
    Tagged
    0 Thread(s)

    Re: finding the angle of an analog joystick

    ATan2(0-StickYPos, StickXPos-0) is returning the same range of 0 to 3.14. Any idea why it returns the same values as using ATan2(StickYPos, StickXPos)?

  8. #8
    Clicker Multimedia Fusion 2SWF Export Module
    Jacob's Avatar
    Join Date
    Jul 2007
    Location
    Second pixel to the right
    Posts
    3,208
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: finding the angle of an analog joystick

    Are you using an extension? MMF2 operates in degrees, not radians. use aTan2(0-Y,*57.2957795

    EDIT: That ^^ will give you a value between 0 to 180.

  9. #9
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,310
    Mentioned
    28 Post(s)
    Tagged
    0 Thread(s)

    Re: finding the angle of an analog joystick

    Thanks Jacob. I guess I was getting the result in radians after all. I just needed to convert them to degrees.

  10. #10
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Re: finding the angle of an analog joystick

    Does this MFA work for you? It seems weird that MMF2 would give you a value in radians instead of degrees.
    http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=236571#Post2365 71
    Working as fast as I can on Fusion 3

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Right Analog Stick
    By dsilvers in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 25th November 2013, 03:55 AM
  2. Finding the Opposite Angle 360 degrees
    By DaveC in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 30th April 2013, 10:43 PM
  3. analog joystick for aiming
    By theninjablooper in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 29th September 2010, 11:10 PM
  4. Using analog joystick for 360 shooting?
    By mobichan in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 26th October 2009, 06:17 AM
  5. [Request/Idea] Analog joystick with support rumble
    By fernandolt in forum Extension Development
    Replies: 1
    Last Post: 26th July 2007, 08:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •