Useful functions for game designers - Cosine Interpolation

Поділитися
Вставка
  • Опубліковано 25 лис 2024

КОМЕНТАРІ • 74

  • @jeffcummings3842
    @jeffcummings3842 2 роки тому +4

    Your teaching takes me into a mathematical world where the equations are as easy to manipulate as play doh! Thank you so much for sharing!

  • @GonzoGonschi
    @GonzoGonschi 8 місяців тому

    thanks a lot buddy, that you make this nerd wisdom accessible for all us mortals

  • @Haykke
    @Haykke 2 роки тому +2

    "but first lemme just take a sip of tea"
    *proceeds to grab a jug of tea*
    this man is truly built different

  • @roberth1687
    @roberth1687 2 роки тому +8

    Nice! The advantage of Cosine over Lagrange Interpolation is that new points can be added by only touching the last point and adding a cosine function to it.

    • @TheArtofCodeIsCool
      @TheArtofCodeIsCool  2 роки тому +3

      Yes with Lagrange each added point affects the entire curve.

  • @robotics_and_stuff
    @robotics_and_stuff 2 роки тому +3

    This was very helpful! I have used this to make smooth motions in the UI system I’m working on. Thanks a lot!

  • @daviddawkins
    @daviddawkins 2 роки тому +13

    Excellent. I like the way you derive these from scratch, very cleverly done. I'd prefer quieter music, it's quite distracting

  • @E1nherj
    @E1nherj 2 роки тому +17

    Great stuff! More interpolations, please, including Bezier.

    • @ollllj
      @ollllj 2 роки тому +1

      bezier interpolation is hopelessly outdated and replaced by any displacement-map that uses much simpler interpolations (even gaussian blur quickly out-poerforms bezier-patches since fast enough memory got cheap enough in 2000s to store larger displacement-maps), or simply by doing FastFourierTransform (which is (more commonly) getting dedicated hardware accelleration to do FFT for video-like-communication between 2 processors)
      I do still see some good use cases for a triangular-patch of 3-quadratic-beziers==parabolas at the triangle-border, because that patch can still be traced analytically and efficiently with pixel-perfect precision AND it allows for decent curvature (quadratic patch has never more than 2 ray-intersections==roots, BUT allows for many "curved polygons", which is getting dedicated DXR-RTX hardware support)

  • @hualee7548
    @hualee7548 2 роки тому

    Great stuff! More interpolations, please! Newton interpolation, piecewise linear interpolation, Hermite interpolation, and cubic spline interpolation

    • @TheArtofCodeIsCool
      @TheArtofCodeIsCool  2 роки тому

      Thanks! Piecewise linear you have here. Hermite I also have, check my video on smoothstep.

  • @CodAv123
    @CodAv123 2 роки тому +2

    That's actually a great interpolation for some kind of node editor, as in Blender, where you connect outputs to inputs on rectangular shapes (nodes). Looks best in such applications if lines end in a 90° angle to the box's border.

    • @TheArtofCodeIsCool
      @TheArtofCodeIsCool  2 роки тому +2

      Yes. I wouldn't be surprised if Blender uses exactly this

  • @gchinmayvarma9030
    @gchinmayvarma9030 2 роки тому +2

    Beautiful Beautiful!!!
    Bezier interpolation, using things like Lerp() is also another beautiful way for a value x to approach another value y! It makes it smooth and i use it almost everywhere in UI design ( for example a text appearing form bottom to the center of the screen) !
    Its great to see someone making such great vids! love ur vids

    • @TheArtofCodeIsCool
      @TheArtofCodeIsCool  2 роки тому +1

      Yes, beziers are great, I'll make a video about them. And for UI design, simple tweening functions are awesome as well.

    • @gchinmayvarma9030
      @gchinmayvarma9030 2 роки тому +1

      @@TheArtofCodeIsCool thank you! I shall look more into the essence of tweening functions!

  • @kolosso305
    @kolosso305 2 роки тому

    I love this series your doing, man! If I ever need a curvy line I'll know where to come back to

  • @undefined_cat
    @undefined_cat 2 роки тому +10

    Ambient music is too loud

  • @piranha1337
    @piranha1337 2 роки тому

    You would make such a great math teacher!

  • @zheckman89
    @zheckman89 2 роки тому +1

    Great work

  • @chengli-n3f
    @chengli-n3f 5 місяців тому

    Great Work,Thank you

  • @doomood
    @doomood 2 роки тому +1

    I love those videos!

  • @maixicek
    @maixicek Рік тому

    Awesome! Thank you for video

  • @gabitheancient7664
    @gabitheancient7664 2 роки тому

    that's very cool, didn't know about that

  • @DetectivePoofPoof
    @DetectivePoofPoof 2 роки тому +1

    Man I love these videos!

  • @Adeith
    @Adeith 2 роки тому +1

    I love these videos. Could you also look at the natural spline, where the second derivative is zero at the points. It has a really nice look to it.

  • @SayHelloToGrux
    @SayHelloToGrux 2 роки тому +8

    Hello, BigWIngs! Great video as usual, thank you so much! Can you please recommend any useful books on applied mathematics for programmers to continue exploring such a thing! Thank you!

    • @TheArtofCodeIsCool
      @TheArtofCodeIsCool  2 роки тому +2

      The only book on the topic I ever had was the first edition of this book: www.amazon.com/dp/1568817231/ref=cm_sw_r_awdo_navT_g_FCZ4C8G0NFYAWJVMH4VS

  • @Eylrid
    @Eylrid 2 роки тому

    Nice thing about cosine interpolation is that to compute a given point on the curve you only need the two neighboring points.

  • @SheepyPeka
    @SheepyPeka 2 роки тому

    learning about these small things is really cool and I get to learn more really cool techniques at a good pace from you .w.
    keep up the great work yo>

  • @bubu88134
    @bubu88134 Рік тому

    "let me take a sip of tea" takes out a 2 liter glass of tea 💀

  • @PhilippeGauthier
    @PhilippeGauthier 2 роки тому +1

    Thanks a lot again ! :)

  • @GrinyaPLAY
    @GrinyaPLAY 2 роки тому +1

    Thanks! Splines please and intersections with another curves and primitives!

  • @agustinpizarro
    @agustinpizarro 2 роки тому

    Great videos! Thank you!

  • @adrianshawuk
    @adrianshawuk 2 роки тому

    This is great but the music is very loud at the start.
    I'm enjoying your shader stuff too. Subscribed

  • @kafel4796
    @kafel4796 11 місяців тому

    I am still waiting for bezier curve interpolation video!!! In DESMOS

  • @idirbelaid1924
    @idirbelaid1924 2 роки тому

    do Bezier curves please !! great video as always !!

  • @realcygnus
    @realcygnus 2 роки тому

    Great stuff !

  • @Scy
    @Scy 2 роки тому +1

    Can you do a video on bezier curve as well? Not sure if it applies to 3d graphics a lot, but it is useful in some structural and graphic design at least.

  • @aayushparashar4143
    @aayushparashar4143 2 роки тому

    Yes!!

  • @AlexSmolyankin
    @AlexSmolyankin Рік тому

    Very nice. I'm wondering can this interpolation be implemented for surface in 3D?

  • @moodeex3766
    @moodeex3766 2 роки тому

    👌

  • @aleksszsj1605
    @aleksszsj1605 2 роки тому

    Can you do tutorial on quaternions and camera controls? :)

  • @Sean-gx1sf
    @Sean-gx1sf 2 роки тому

    Love this stuff, do you have any recommendations on books/channels/videos explaining how to model solids using math formulas? For example, if I had something like a bismuth crystal and knew its dimensions and I wanted to put together code that modeled that.

    • @TheArtofCodeIsCool
      @TheArtofCodeIsCool  2 роки тому +1

      I have many videos on how to make 3d effects. You could start with raymarching for dummies.

  • @seymourc64
    @seymourc64 2 роки тому

    can you explain cubic interpolation please?

  • @davidmurphy563
    @davidmurphy563 2 роки тому

    Ah, was about to request Bezier. Quadratic would be great too, it's often the nicest interpolation if you're moving objects or the camera.
    I'm still struggling with normalisation... I fully expected you to normalise the cosine to one by dividing by PI and yet the right answer was multiplication... I'm a bit tired now but I'll see if I can do this without referring to the video at some point. I'm pretty confident about the lerping, but the coserping - well maybe, let's see.

    • @milanstevic8424
      @milanstevic8424 2 роки тому +2

      yeah, well it was in radians, so x goes from 0 to 3.14 to complete a half-cycle (pi radians).
      if you want x to go slower, you want the radians to dial less frequently, so you want x to complete a half-cycle from 0 to 6.28, for example.
      this means you'd want a half of x, as this would stretch the curve by a factor of 2.
      if you want x to go faster, you want the radians to dial more frequently as well, so for example x goes from 0 to 1.57.
      this means you'd want a double of x, as this would squish the curve by a factor of 2.
      because he wanted x to complete the half-cycle at 1 instead of 3.14, he decided to multiply x by pi.

    • @davidmurphy563
      @davidmurphy563 2 роки тому +1

      @@milanstevic8424 Brilliant explanation, thank you so much. So when x is exactly 1, ordinarily this would be roughly a 6th of a complete cosine (as we saw) but if you multiply it by PI then 1 is precisely half a cosine wave.
      Obvious in hindsight. I just had it in my head that you divide by the scalar to normalise. Thank you once more, so helpful.

    • @milanstevic8424
      @milanstevic8424 2 роки тому +1

      @@davidmurphy563 yep it's a little weird and non-intuitive because of the context.
      the inside of cos is with regard to some fixed interval, therefore about the frequency.
      if you double the whole output you intuitively *stretch* the curve along Y (amplitude), but by doubling the inner parameters you *squish* the curve along X (frequency).
      this inversion is where that confusion comes from, yet if you think only about the words 'amplitude' and 'frequency', they are both really doubled as expected.

    • @milanstevic8424
      @milanstevic8424 2 роки тому

      @@davidmurphy563 btw, I forgot to mention this, but I would probably make this mistake myself, if that's any consolation. it's easy to think dividing by length would normalize it because this is normally the case with vectors.

    • @davidmurphy563
      @davidmurphy563 2 роки тому +1

      ​@@milanstevic8424 That's precisely where I went wrong; thinking you divide vectors by the mag, therefore you should divide everything. I've written enough shaders messing with the sin/cos amp and freq you'd think I'd know what it does by now but aligning your intuitions with cold logic isn't always a given.
      I also got in a muddle on the normalisation working through the lagrangian interpolation as well and the channel owner (I can never catch his name properly and I don't want to get it wrong) kindly wrote an explanation setting me straight. It's frustrating because it's so obvious once the penny drops. But, you know, we're here to learn so any step forward is a win.

  • @mzakyr342
    @mzakyr342 2 роки тому

    Why didn't we use beizere curve?

  • @ProGaming-kb9io
    @ProGaming-kb9io 2 роки тому

    Hey, what is your background? Are you mathematician?

    • @TheArtofCodeIsCool
      @TheArtofCodeIsCool  2 роки тому +1

      I have worked in video games for most of my life. I have an interest in maths but I'm not a trained mathematician.

  • @UTube2K6
    @UTube2K6 2 роки тому

    could be cool to show this in action with shader toy,

    • @TheArtofCodeIsCool
      @TheArtofCodeIsCool  2 роки тому +1

      I will do something like this in ShaderToy soon I promise.

  • @batnikelam-mavzer443
    @batnikelam-mavzer443 2 роки тому

    gj

  • @Lauli55
    @Lauli55 2 роки тому +2

    Hahaa is it just me or is that real big?? 9:12

    • @milanstevic8424
      @milanstevic8424 2 роки тому

      he was so slammed, he had to make a cut there xD

    • @Lauli55
      @Lauli55 2 роки тому

      @@milanstevic8424 Hahahaa, nice!

    • @TheArtofCodeIsCool
      @TheArtofCodeIsCool  2 роки тому +2

      What can I say, I like my tea. 😜

  • @syntax_error6882
    @syntax_error6882 2 роки тому +1

    too bad I'm not at the level yet ..

    • @davidmurphy563
      @davidmurphy563 2 роки тому +4

      We're all in that boat until we work through it. Open desmos. Can you add a point? Can you make a straight line? Can you move that line? Can you place it under the point. And on you go.
      One step at a time, do it until you get stuck, watch the video again, try again. When you finally do it. Leave it a day and check you can still do it. It's all slog buddy but we can all get there.

    • @syntax_error6882
      @syntax_error6882 2 роки тому +2

      @@davidmurphy563 wow it's heartwarming to read that !! thanks mat

    • @milanstevic8424
      @milanstevic8424 2 роки тому +2

      @@syntax_error6882 this isn't particularly hard math, it's actually dead simple, but probably just looks intimidating. if you have any specific question, I'll be glad to answer.

    • @syntax_error6882
      @syntax_error6882 2 роки тому +2

      @@milanstevic8424 my last answer was supress probably because i put a link on desmos..
      anyway i manage to understand this video thanks to david for is simple advice cut in small step.
      i struggle with some detail like x-p1.x, but the linear algebra was pretty straightforward.. .and with a course on sin(x) and cos(x) the second part became clear.
      never believe this but its true, yersteday to me its was impossible ..
      anyway thanks to all and to art of code ..