User Tag List

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

Thread: need help understanding atan2?

  1. #1
    Clicker Fusion 2.5 (Steam)

    Join Date
    Dec 2014
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    need help understanding atan2?

    Atan2(Y2-Y1,X1-X2)

    i read a tutorial on the net, it says the formula is instead=
    http://www.gamefromscratch.com/post/...e-a-point.aspx
    (Atan2(Y2-Y1, X2-X1)) * (180/Pi)

    lol?

    I am very confused. I also tried reading on it, but its beyond me my knowledge of math is basic. But if someone could try to explain to me the steps of what this does id appreciate it...

    Y2-Y1 retrieves the space of distance found between the two points... i know dis much...

    not sure about the rest

    also, how can I control my x and y movement in relation to my currecntly facing angle (like forward facing this angle? how do i add x and y in relation to this?)

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,155
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    (Atan2(Y2-Y1, X2-X1)) * (180/Pi)

    this would convert the angle degrees in radians, but you'll likely don't need it

    Atan2(Y2-Y1,X1-X2)
    calculates the angle of a vector joining XY1 and XY2
    so you can use it to determine which angle your object must face o "look at" a specific target position
    X,Y terms are inverted because in computers we have by default Y positions going downward,
    differently from pen-and-paper Cartesian plane where they go upward

    i.e.

    Atan2(Ytarget-Yplayer,Xplayer-Xtarget)

    you can use builtin OAngle("player",Xtarget,Ytarget) function for this as well,
    is very slightly faster, but will give you integer result - less precision.

    to move in direction of your angle,
    simply use sin and cos:

    >>> add cos(angle) * speed to Xpos
    >>> sub sin(angle) * speed to Ypos
    >>> set X position to Xpos
    >>> set Y position to Ypos

    use above additional step with "Xpos,Ypos" values because sin/cos will give floating point results
    and Fusion does not support this in raw X,Y positions (but support them in values)

  3. #3
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export Module
    Emerson3's Avatar
    Join Date
    Apr 2014
    Location
    Lafayette, Louisiana
    Posts
    715
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Schrodinger,

    Just saying, I would personally pay for this, but what about a Schrodinger Udemy Fusion Math Course for Dummies? Lol. A variety of different functions that do different stuff in Clickteam with a breakdown.

    I know your super busy altering 2d reality into 3d, , but I know this would help everyone so much get the most out of fusion and the event editor!

  4. #4
    Clicker Fusion 2.5 Developer
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    J3sseM's Avatar
    Join Date
    Feb 2013
    Location
    Finland
    Posts
    868
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I'm all in for "Schrodinger Udemy Fusion Math Course for Dummies"!
    Seriously speaking, I'm still in.

  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export Module

    Join Date
    Dec 2008
    Location
    Italy
    Posts
    404
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    I'm 100% in, too.
    A Schrodinger Udemy course for math/trigonometry would definitely be beneficial to the whole community

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,155
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    Aahahaha
    no guys I'm not that good actually,
    just learnt what I needed over the time by studying around.
    Internet is full of much more brilliant and extensive resources on the subject than myself.

    For games (2D games ) you'll mostly need just a bit of trigonometry actually.

    Of course I'm available for any question I'm able to answer!

    I was thinking dedicating a page in my website
    (once I got some time to actually make it look like a website..)
    to most useful expressions for gaming
    so that could be used as a quick reference when needed.

    But would be just a repository for most useful/frequently used expressions.

  7. #7
    Clicker Fusion 2.5 (Steam)

    Join Date
    Dec 2014
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what does cosine do? and sine? does it return the difference of the current angle or something?

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,155
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    you can see sin (blue) and cos (red) in this picture:




    will give you the horizontal and vertical component of the vector
    going from origin (i.e. your player position)
    to radius length (i.e. your target point)
    basing on its angle

  9. #9
    Clicker Fusion 2.5 (Steam)

    Join Date
    Dec 2014
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmmm, I almost understand now a bit.
    very interesting.

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    UltimateWalrus's Avatar
    Join Date
    Jul 2006
    Posts
    823
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If schrodinger isn't interested, I could consider teaching a Udemy course in simple Fusion concepts if enough people were interested to make it worth the while (somehow I doubt it though as it's all stuff you can learn on your own). As far as math goes, schrodinger is right --- for 2D games, you'll generally just need an understanding of high-school trigonometry. Look up SOHCAHTOA for an easy way to understand how sin, cos, and tan relate to the sides of a right triangle.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Atan2 et direction (haut & bas)
    By ptiseigneur in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 27th April 2013, 05:17 PM
  2. Angle Atan2
    By ptiseigneur in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 14th April 2013, 12:40 PM
  3. Limiting atan2 to 180 degrees
    By infinitum3d in forum The Games Factory 2 - Technical Support
    Replies: 6
    Last Post: 2nd April 2012, 11:31 PM
  4. Atan2 & INI
    By Kisguri in forum iOS Export Module Version 2.0
    Replies: 3
    Last Post: 5th January 2011, 02:18 PM
  5. Atan2
    By Julian in forum Vitalize
    Replies: 1
    Last Post: 13th January 2009, 06:50 AM

Posting Permissions

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