The atan2 Function - Friday Minis 260

Поделиться
HTML-код
  • Опубликовано: 28 янв 2025

Комментарии • 119

  • @davidkim617
    @davidkim617 2 года назад +17

    I almost lost my mind to figure out WTF is Atan2, and you just saves my day!! Thank you so much!!!!

    • @NERDfirst
      @NERDfirst  2 года назад +2

      You're welcome! Very happy to be of help =)

  • @mentionethan
    @mentionethan 4 года назад +56

    this is extremelye helpful, especially when your teacher doesnt understand code himself so you gotta figure things out to pass

    • @NERDfirst
      @NERDfirst  4 года назад +5

      Hello and thank you for your comment! Very happy to be of help =)

  • @zekumoru
    @zekumoru 3 года назад +15

    It's very concise and easy to grasp. I was googling atan2 but I was bombarded with lots of technical jargon. Great job!!

    • @NERDfirst
      @NERDfirst  3 года назад +3

      Hello and thank you very much for your comment! Very happy to be of help =)

  • @NarpytheCrimeDog
    @NarpytheCrimeDog 11 часов назад

    God, thank you for explaining this in a rational way for people who don't have years of mathematics education to make this intuitive.

    • @NERDfirst
      @NERDfirst  2 часа назад

      Hello and thank you very much for your comment! Glad my approach worked out for you! It's always a tough problem when it comes to how much context to include to make this beneficial for the most amount of people (while also of course, not boring them out!)
      I did gloss over a lot of the math behind trigonometry though, focusing only on the bare minimum required to understand atan2(). For other applications, there's always more to learn!

  • @JonesCrimson
    @JonesCrimson 3 года назад +13

    Most of the early years of programming is just discovering some guy or gal in the 80s or 90s figured out the solution to the problem you're working on and game development is no exception.

    • @NERDfirst
      @NERDfirst  3 года назад +3

      Hello and thank you for your comment! Most certainly! Even the super trendy things today like deep learning were developed in the 60s and 70s.
      But that's a happy problem. When there are well-established solutions to common problems, it means that you can devote your time towards _not_ reinventing the wheel!

  • @AdmMusicc
    @AdmMusicc 6 месяцев назад +1

    Perfect explanation thank you!

    • @NERDfirst
      @NERDfirst  6 месяцев назад

      You're welcome! Very happy to be of help :)

  • @rich1051414
    @rich1051414 5 лет назад +8

    atan2 is probably the most used function from the standard math library in 3d games :P

    • @NERDfirst
      @NERDfirst  5 лет назад +1

      Hello and thank you for your comment! I'm not surprised! There's so much Trigonometry going on in 3D.

  • @VideomasterPDB
    @VideomasterPDB 2 года назад +1

    This was brilliant. short, simple. to the point. giving basic understanding of Atan originally and then comparing and the use of diagrams

    • @NERDfirst
      @NERDfirst  2 года назад

      Hello and thank you very much for your comment! Glad you liked the video =)

  • @mattschemmer3091
    @mattschemmer3091 2 года назад +2

    Been using it, but never quite understood why. Great vid!

    • @NERDfirst
      @NERDfirst  2 года назад +1

      Hello and thank you very much for your comment! Very happy to be of help =)

  • @scoobydoobies
    @scoobydoobies Год назад

    Bruh thank you. Finding the angle between two points is super useful,

    • @NERDfirst
      @NERDfirst  Год назад

      You're welcome! Very happy to be of help :)

  • @JC-xh8xe
    @JC-xh8xe 10 месяцев назад

    Thank you. Was trying to understand this, in surveying I use Arctan x/y, because of 0 degrees being north, then we go clockwise instead of counter clockwise.
    I was using Arctan in excel with if statements to choose the quadrant given the signs.
    Now I can use =ATAN2(deltaN, deltaE) and I will get the same result. I have set up an IF statement if the angle is less than 360 to add 360, otherwise it is the correct angle. Works well.
    Thank you for helping me visualise the unit circle and relate it to the compass bearings we are used to after using them for so long.

    • @NERDfirst
      @NERDfirst  10 месяцев назад +1

      Hello and thank you very much for your comment! Yes, this really needs to be visualized for it to make sense, so I'm glad I could do that for you!

  • @happy_moth
    @happy_moth 3 года назад

    commenting to feed the algorithm because this helped me understand the function a lot better :)

    • @NERDfirst
      @NERDfirst  3 года назад

      Hello and thank you very much for your comment! Glad to be of help :)

  • @theman7050
    @theman7050 Год назад

    Thanks man. I keep coming back to refer this video 😊

    • @NERDfirst
      @NERDfirst  Год назад +1

      You're welcome! Glad to be of help =)

    • @theman7050
      @theman7050 11 месяцев назад

      ​@@NERDfirstone question. When you apply atan to the UVs in fragment shader code, why does one half of the surface is totally black and out of the remaining 2 quadrants, one is bright white and only the last quadrant appears to show the blend between black and white colors?

    • @NERDfirst
      @NERDfirst  11 месяцев назад +1

      @@theman7050 Without knowing what your code is doing or what your texture looks like, it'd be hard to say. Usually when textures don't look right, it's because your UVs are off, but without digging further into exactly how the UVs are off, it wouldn't be easy to debug.

  • @victormbebe3797
    @victormbebe3797 3 года назад

    simple and clear. Thank you. mozambican from Brazil.

    • @NERDfirst
      @NERDfirst  3 года назад +1

      You're welcome! Glad to be of help :)

  • @ivantishchenko4686
    @ivantishchenko4686 4 года назад +2

    Great video. Thank you!

    • @NERDfirst
      @NERDfirst  4 года назад

      You're welcome! Glad you liked the video =)

  • @gabrijelagavric6247
    @gabrijelagavric6247 3 года назад

    lol sitting in a coffee shop called Well and Good (a phrase you said in the video). Glad you made this, helped.

    • @NERDfirst
      @NERDfirst  3 года назад +1

      Ha, nice coincidence :) Very happy to be of help!

  • @Jacine0520
    @Jacine0520 8 месяцев назад

    thank you so much I've looking in how to do it for so much time!!!

    • @NERDfirst
      @NERDfirst  8 месяцев назад

      You're welcome! Very happy to be of help :)

  • @dasupaking
    @dasupaking Год назад

    Simple but Profound! Thank you! :)

    • @NERDfirst
      @NERDfirst  Год назад

      You're welcome! Very happy to be of help =)

  • @alexv_web_dev
    @alexv_web_dev Год назад

    Great explanation, keep up the good work!

    • @NERDfirst
      @NERDfirst  Год назад

      Hello and thank you very much for your comment! Very happy to be of help :)

  • @qqqquito
    @qqqquito 5 лет назад

    The sad thing is that many people have extensively used functions asin, acos and atan but are still unaware of the existence of atan2.

    • @NERDfirst
      @NERDfirst  5 лет назад

      Hello and thank you for your comment! Well to be fair, coming from a math perspective, people may not even be aware that this could be a problem!

    • @qqqquito
      @qqqquito 5 лет назад

      @@NERDfirst While pure mathematicians might only be concerned whether something is theoretically resolvable, engineers are concerned whether a solution is more efficient than the other.

  • @kipchickensout
    @kipchickensout 2 года назад

    I didn't quite get the wikipedia explanation but this was easypeasy to understand thanks!

    • @NERDfirst
      @NERDfirst  2 года назад +1

      You're welcome! Very happy to be of help :)

  • @sidneysherrill4870
    @sidneysherrill4870 3 года назад

    Fantastic video. So well done. Thank you!

    • @NERDfirst
      @NERDfirst  3 года назад

      You're welcome! Very happy to be of help =)

  • @theman7050
    @theman7050 Год назад

    Thank you. It finally makes sense :)

    • @NERDfirst
      @NERDfirst  Год назад +1

      You're welcome! Glad to be of help :)

  • @furankoga
    @furankoga 10 месяцев назад

    thank you so much! very helpful!

    • @NERDfirst
      @NERDfirst  10 месяцев назад +1

      You're welcome! Very happy to be of help :)

  • @RoboClonk
    @RoboClonk 4 года назад +1

    Perfect explanation, thanks!

    • @NERDfirst
      @NERDfirst  4 года назад +1

      You're welcome! Happy to be of help =)

  • @asarachar7956
    @asarachar7956 3 года назад

    It helps me to find out more what iam doing now. Thanks

    • @NERDfirst
      @NERDfirst  3 года назад

      You're welcome! Very happy to be of help =)

  • @dcpowered
    @dcpowered 5 лет назад +1

    Thank you for this nice video!

    • @NERDfirst
      @NERDfirst  5 лет назад

      You're welcome! Glad to be of help =)

  • @qqqquito
    @qqqquito 5 лет назад

    I just noticed that there are a number of webpages devoted to the question: Why aren't there *asin2()* and *acos2()* functions? After thinking a bit about it, I realized that this is because atan2 relies on the value of atan(y/x) along with the signs of x and y. But this task can also be accomplished by using asin(y/sqrt(x^2+y^2)) or acos(x/sqrt(x^2+y^2)) along with the signs of x and y. So the function could have been called something like angle_finder().

    • @NERDfirst
      @NERDfirst  5 лет назад +1

      Hello and thank you for your comment! I suppose it's associated with the mathematical atan function just because it works similarly enough! By naming it that way, if you understand atan, you already know what the function does.

  • @hullyoung
    @hullyoung 2 года назад

    Very very well explained! Thanks!

    • @NERDfirst
      @NERDfirst  2 года назад

      You're welcome! Glad you liked the video =)

  • @3d_blunders
    @3d_blunders 3 года назад

    Thanks man i really needed this

    • @NERDfirst
      @NERDfirst  3 года назад

      You're welcome! Glad to be of help =)

  • @qzorn4440
    @qzorn4440 Год назад

    great information. 😎 Thanks.

    • @NERDfirst
      @NERDfirst  Год назад +1

      You're welcome! Very happy to be of help :)

  • @l_a__z_y
    @l_a__z_y 2 года назад

    Thank you, man!!!!!!!!!

    • @NERDfirst
      @NERDfirst  2 года назад

      You're welcome! Glad to be of help =)

  • @makss3139
    @makss3139 2 месяца назад

    Is there a way to solve for ArcTan2 without a script, for instance on paper? Great video

    • @NERDfirst
      @NERDfirst  2 месяца назад

      Hello and thank you for your comment! This isn't generally something that can be easily done. I wouldn't be surprised if even calculators use approximations or look-up tables.
      But if you wanted to do it anyway, the method is described in detail here: math.stackexchange.com/questions/4680996/find-arctan-without-calculator

  • @RoaaAlmadi98
    @RoaaAlmadi98 Год назад

    Thank you great video very helpful. I was wondering if I were to use a calculator to find the answer what would I insert? because as you know the simple tan-1(y/x) wouldn't give the right answer for quadrants 2 and 3

    • @NERDfirst
      @NERDfirst  Год назад +1

      Hello and thank you for your comment! Unfortunately if you have, say, a scientific calculator, you don't have access to something like atan2().
      This means you'll have to eyeball it yourself based on the quadrant to decide what the angles will be.

    • @RoaaAlmadi98
      @RoaaAlmadi98 Год назад

      @@NERDfirst thank you vary mush . I had a test and this video helped me a lot. You explained it way better than my professor

    • @NERDfirst
      @NERDfirst  Год назад

      You're welcome! Hope the test went well.

  • @harrytraskos5964
    @harrytraskos5964 3 года назад

    Thank you, for really nice explanation :D

    • @NERDfirst
      @NERDfirst  3 года назад

      You're welcome! Glad to be of help :)

  • @VoxaFPS
    @VoxaFPS 3 года назад

    brother in my game after get value from atan2() i need to get negative of atan2() like angle = - atan2(y,x) why that happen ?

    • @NERDfirst
      @NERDfirst  3 года назад

      Hello and thank you for your comment! This depends on the conventions used by your game engine / programming framework. Sometimes, angles are represented as -180 to 180 degrees, rather than 0 to 360 degrees.
      For example, I have seen conventions in which +X (ie. East), is taken to be 0°. Angles going counterclockwise from there are positive, so +Y (North) is 90°. Angles going clockwise are negative, so -Y (South) is -90°. Ultimately, it's just a matter of conventions - different ways to point out the same directions.

    • @VoxaFPS
      @VoxaFPS 3 года назад

      @@NERDfirst thank you i got what you mean , i hope your channel be bigger

  • @aboodnasr73
    @aboodnasr73 Год назад

    It's helpful. Thanks a lot

    • @NERDfirst
      @NERDfirst  Год назад

      You're welcome! Very happy to be of help =)

  • @ClutchGen
    @ClutchGen 3 года назад

    Great explanation!! Thank you!

    • @NERDfirst
      @NERDfirst  3 года назад +1

      You're welcome! Glad to be of help =)

  • @BEExPyro
    @BEExPyro 3 года назад

    This was exactly what I wanted to find when I searched mathf.atan2

    • @NERDfirst
      @NERDfirst  3 года назад

      Hello and thank you for your comment! Glad to be of help =)

  • @nirmithrjain6265
    @nirmithrjain6265 3 года назад

    Thanks man, it was very helpful 👍

    • @NERDfirst
      @NERDfirst  3 года назад

      You're welcome! Happy to be of help =)

  • @Retrofire-47
    @Retrofire-47 Год назад

    Legend.

    • @NERDfirst
      @NERDfirst  Год назад

      Hello and thank you for your comment! Glad to be of help =)

  • @John_Macaroni
    @John_Macaroni 2 года назад

    Very helpful video!! small question: Why don't we just use atan2 all the time since it's so much better than atan?

    • @NERDfirst
      @NERDfirst  2 года назад +1

      Hello and thank you for your comment! I personally don't really see a need to use atan() ever - I always find myself using atan2(). I'm not aware of any advantages to using atan(), and honestly it probably only exists to more closely mirror the function you'd find on a calculator.

  • @rasimakifzade
    @rasimakifzade Год назад

    great job!

    • @NERDfirst
      @NERDfirst  Год назад

      Hello and thank you very much for your comment! Glad you liked the video :)

  • @antoniopugliese3004
    @antoniopugliese3004 3 года назад

    Thank you soooo much,
    my robotics teacher didn't make me understand!

    • @NERDfirst
      @NERDfirst  3 года назад

      You're welcome!Glad to be of help =)

  • @MegaWv3
    @MegaWv3 2 года назад

    thank you sir!

    • @NERDfirst
      @NERDfirst  2 года назад +1

      You're welcome! Glad you liked the video =)

  • @ssyedyaseens
    @ssyedyaseens 4 месяца назад

    Is your white charging cable okay?

    • @NERDfirst
      @NERDfirst  4 месяца назад +1

      Hello and thank you for your comment! Are you talking about the tallest cable in the middle? If so, that's the power cord for the Ikea lamp I'm using to light up the set, and it's meant to flex like that! There's a strain relief structure on the plug and the lamp's still going strong today.

  • @ian.ambrose
    @ian.ambrose Год назад

    Thank you. Such a Chad.

    • @NERDfirst
      @NERDfirst  Год назад

      You're welcome! Happy to be of help :)

  • @lksxxtodin5292
    @lksxxtodin5292 Год назад

    I confuse atan with atan2 haha. Thanks for the vídeo

    • @NERDfirst
      @NERDfirst  Год назад

      You're welcome! Glad to be of help =)

  • @teflonpan115
    @teflonpan115 3 года назад +1

    a concrete example would have been nice

    • @NERDfirst
      @NERDfirst  3 года назад

      Hello and thank you for your comment! Could you elaborate more?
      The examples given in the video are given in the context of finding the heading of one point relative to another, which is a fairly common use case in graphics and games.

  • @jonsnow3513
    @jonsnow3513 3 месяца назад

    thank you sir

    • @NERDfirst
      @NERDfirst  3 месяца назад

      You're welcome! Glad to be of help =)

  • @zerosum535
    @zerosum535 2 года назад

    Thanks man

    • @NERDfirst
      @NERDfirst  2 года назад +1

      You're welcome! Glad to be of help =)

  • @Jonnio
    @Jonnio Год назад

    Wish I knew this few years ago lol

    • @NERDfirst
      @NERDfirst  Год назад +1

      Hello and thank you for your comment! It's never too late! I too never went out of my way to understand this for a while, and continued using regular old atan() supported by a bunch of if-statements for a very long time.

  • @GamingAlgen
    @GamingAlgen 4 года назад +1

    Roses are red
    violets are blue
    There's always a Asian better then you
    wait , I'm also Asian 0_0

    • @NERDfirst
      @NERDfirst  4 года назад +1

      I live in a country full of Asians =P So, nothing special here!

    • @Retrofire-47
      @Retrofire-47 Год назад

      @@NERDfirst y'all got superpowers, of the intellectual variety, so i heard

    • @NERDfirst
      @NERDfirst  Год назад

      @@Retrofire-47 Hah, I wouldn't know, everyone around me is Asian too!

  • @33_sorin
    @33_sorin 3 года назад

    at times you sound just a little bit like rayner teo

    • @NERDfirst
      @NERDfirst  3 года назад +1

      Hello and thank you for your comment! Not surprising since he and I are from the same country =)

  • @kimtanatfree8220
    @kimtanatfree8220 4 года назад

    like