Linear Interpolation (Lerp) - Math and JavaScript Applications

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

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

  • @Radu
    @Radu  2 года назад +29

    Please like this video so I know if I should make more content like this :-)

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

      Keep it please

    • @Radu
      @Radu  2 года назад +3

      :-)

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

      Yes sir.

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

      Please do more! You really inspire me to up my math and JS knowledge with your content! I only wish I was able to take your class from the US!

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

      @@philipreynolds5088 Thanks for watching. Might be possible to take remote classes in the future, let's see :-)

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

    I've worked through this video twice and love it. It took me a bit to get my head wrapped up around lerp concept. Thank you, Radu! Great video and excellent tutorial as always.

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

      I'm really happy to hear you got something out of it! Thanks for watching :-)

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

    best programming channel in the world , explained it like a charm

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

      Glad it helped :-)

  • @chriswinslow
    @chriswinslow Месяц назад +2

    This is pretty cool. I will try and learn from this and apply it to your "Animating a Plane on a Path with JavaScript | Live Coding on a Plane!" tutorial, to fill in large gaps if the mouse is moved quickly so that the point moves smoothly.

    • @Radu
      @Radu  Месяц назад +1

      Cool!! But... I might have done that already. Check that plane on the path tutorial again, in the part where I smooth the path... I don't remember 100%, though :-)

    • @chriswinslow
      @chriswinslow Месяц назад +1

      @@Radu Hi, you have but I want to try and implement it myself by learning LERP. Thanks

    • @Radu
      @Radu  Месяц назад +1

      Sure :-) -

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

    for anyone confused on why we are subtracting a frm b, its to get the length from b to a, this is bcos our lines(a and b) both start from the same point so we don't know the length or distance btw a and b so to do so we subtract a frm b and then we can effectively get any position in between my scaling that length down using multiplication(scales down bcos we are using a fraction)

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

      Thanks for the explanation! :-)

  • @Accrt.
    @Accrt. 11 месяцев назад +2

    Please continue teaching math using such examples. I'd love to see more of these.

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

      Probably I will someday :-) thanks for watching!

  • @apidas
    @apidas 2 года назад +13

    I love you teaching math Radu. keep it up!

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

      Happy to hear :-)

  • @simpingsyndrome
    @simpingsyndrome 2 года назад +3

    I've done my Linear Interpolation Project using NextJS and it's improve my skill significantly

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

      Wow, cool :-)

  • @henrmota
    @henrmota Год назад +2

    Lerp is awesome... One of my favorite utils!

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

      Same here :-)

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

      Btw, you commented something on one of my other videos, but youtube removed it... Sometimes it does that :-(

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

    Gr8 as always!
    I am glad to find your channel in my 3rd year of college

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

      Thanks :-) hope it helps with your studies.

  • @charminarchaupal
    @charminarchaupal 3 месяца назад +2

    Really really underrated

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

      Thanks :-)

  • @KlinovAS
    @KlinovAS 2 года назад +3

    Wow. Sound in web. This is Nice bonus!

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

      Glad you like it :-) Actually... something I forgot to mention is that the web audio API has built-in functions for doing interpolation, like the linearRampToValueAtTime(val, time). Might be useful to know if you plan to play around with things like this.

  • @___d3p1
    @___d3p1 2 года назад +5

    Great content again!!! I love how you use programming techniques and math togethers!

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

      Thanks for watching :-)

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

    UNDERATED. THE GOAT.

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

      :-) thank you

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

    this video is awesome, want more videos on mathematical functions

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

      Ok. I'll try to make more.

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

    Sir
    Your explanation is very good and crystal clear 👍

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

      Thank you!

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

    you can press "alt z" in vscode to enable word wrap so you dont have to worry about code fitting in the screen

    • @Radu
      @Radu  2 года назад +5

      But then it goes on the next line in an ugly way :-))

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

    Hi Radu! I learned of the linear interpolation formula from your car tutorial. It really helped me with a project I'm currently working on!

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

      Great to hear!
      It's not a hard formula, but my students often implement it hundreds of times in their code bases... instead of implementing it once and using it where needed. This often leads to bugs and hard to read code.

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

      @@Radu Where can we see how this happens?

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

      @@KrumSavov hi, not sure what your question is.

  • @cryptocoinkiwi8272
    @cryptocoinkiwi8272 Год назад +2

    I've actually caught myself humming the "Coding with Radu" theme song at times.

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

      Glad you like it :-) It's funny how mixed feelings I get about it from people :-D

  • @vikneshwaranseetharaman5881
    @vikneshwaranseetharaman5881 8 месяцев назад +2

    Hi Radu, Could you please explain how third of the way required dividing it 3 times. Why do we need to add the distance to A 3 times.The part where in you dervied with the formula wasn't clear to me.

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

      Can you be more specific and give a timestamp, so I know exactly where you have trouble understanding? The way I like to think of it is the difference between b and a is the thing that is scaled, so, if we take a third of that and add it to a, we move one third away from a... Maybe this helps.

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

      @@Raduthank you, that made it clear. Now i understood

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

    Why so less views, please start teaching on udemy too and other platforms, you are amazing.

    • @Radu
      @Radu  10 месяцев назад +4

      Too much trouble :-) and... when I made my self-driving car course, I did it with Udemy in mind as well. I made some assignments and special segments for those. Then, few days before I was ready they limited the duration of free content to something (maybe 2 hours, or so). My course was longer so, I had to give up on it :-/
      Less views are a good thing too :-) like, I can find the time to answer to your comment!

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

    best intro song in the universe :D

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

      Haha :-) You know there's an extended version on my channel?

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

    nice video man.i enjoyed it a lot.

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

      Cool!

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

    You should make more content like this ;-) Absolute fav coding content maker. Stay C#

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

      I'll try :-) Thanks for watching!

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

    great teacher

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

      Thank you :-)

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

    Great video. Thoughts on inheritance vs composition and factory functions?

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

      Use the style that matches the existing code-base... Otherwise, if starting a new project, pick the one that you prefer / are the most comfortable with.

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

    bro, after this sick intro I gotta subscribe!

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

      It's like there are two groups:
      A: man, I would subscribe but that intro... sorry
      B: That intro is great! Subscribed
      Guess you're in group B :-D

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

    Hi ,sir how are you ,Iam from india. Iam your big fan.❤❤💖💖💝💝

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

      Cool :-) Welcome to the channel!

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

    This is amazing. Thank you

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

      You're welcome!

  • @cryptocoinkiwi8272
    @cryptocoinkiwi8272 Год назад +3

    My cat was asleep in front of my laptop. As soon as the sound started interpolating he turned his and looked at the screen with a WTF is that look on his face!

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

      Haha :-D would have liked to see that!

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

    I finally worked on my homework again and got as far as interpolating color last night; I'll get sound tonight

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

      Awesome!

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

      @@Radu I just did sound and figured out how to 'turn it off', as in I changed the 'volume' to zero when I clicked again and then returned the value to 0.05 (instead of 0.1) when I clicked again

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

      Cool

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

    Kiitos!! Great vid!

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

      Glad you liked it :-)

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

    Great video! Thanks for the simple explanation of the concept!
    14:54: shouldn't it be like 33% because you divide the distance between A and B into nine parts?

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

      You're right :-) Guess I counted wrong. Thanks for pointing out!

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

    U r the best

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

    Can you explain how myCanvas variable works even you are not getting it from the DOM please?
    thanks for the content very informative

    • @Radu
      @Radu  2 года назад +3

      Yes. By default, the IDs of all items in the DOM become global variables accessible in JavaScript. I don't really recommend this practice, because sometimes they can get overwritten by mistake, but for small projects it is ok (especially if you're the only one working on it).

    • @sudoCss
      @sudoCss 2 года назад +3

      @@Radu Oh that's very cool, thank you for taking time to reply

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

      @@sudoCss No problem :-)

    • @shahrukhtramboo6781
      @shahrukhtramboo6781 10 месяцев назад +2

      That was new to me too, nice question

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

    Oh, you can maybe build on this and do cubic interpolation. That's always fun. Especially when you join lines.

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

      I might, but the video I point to somewhere in the middle (Beauty of Bezier Curves) does a fantastic job explaining them. After seeing it, I don't see the point in making anything remotely similar...

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

      @@Radu Fair enough, it can be tricky making videos when there are some outstanding ones out there already.

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

      @@davidmurphy563 Well, I think doing the same thing again is just a waste of time. But I would have something small to add to that video: It didn't demonstrate a way of getting equally spaced points along the curve (just mentioned it). A few months ago I coded a simple 'train simulation' while on a train :-) and I had a solution to that problem. I will do a quick video about it one of these days.

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

      @@Radu Oh, that sounds really interesting. Do you ever feel a little disheartened when you hear a fantastic explanation but it's about something you already know? Maybe it's just me but there's nothing like learning something new.

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

      @@davidmurphy563 People often add their 'personal touch' to whatever it is they teach. I often watch things I already know to see their approach. I pay attention to the presentation, the choice of words, visuals etc. I feel I get a better understanding of the topic like that, even if I am quite comfortable with it already.

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

    excellent

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

      Thanks!

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

      @@Radu u put alot of work ,I really appreciate it

  • @toskr-r4t
    @toskr-r4t Год назад

    How are you able to target the canvas element by its id without 'getElementById' or other DOM method? I meen, how long has this been possible? Is it a browser feature or part of the javascript standard now?

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

      IDs in HTML automatically become global variables in JavaScript...
      I use it sometimes to 'get to the point' and keep the tutorial short, but it's not something I recommend... It's easy to overwrite such variables by mistake and crazy things can happen :-P

    • @toskr-r4t
      @toskr-r4t Год назад

      Awesome, thanks Radu :)@@Radu

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

    How you configuring your image to be like a reproduction?. A video about it?. Great topics in your channel, congrats

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

      I don't understand your question. You mean how I do the filming?

  • @howl2339
    @howl2339 2 года назад +3

    Why in your tutorials you never use some GUI like tweakpane to make more visual the explaination. Just get that as an idea pls

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

      I guess it's because I don't polish the things I do so much. Maybe I should... But I feel making proof of concepts is enough, and you guys can use the ideas in other things. Let's see... I am planning to build some larger software projects in the future and I might use some existing GUI or even make my own.

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

      @@Radu +1

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

    thanks, can we get more of those videos? there is a need for good math videos for cs

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

      I will try :-)

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

    1:08 I understood that reference

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

      (`○ д○´)✧

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

    Nice hair cut!

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

      Haha, thanks :-) but it will grow back.

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

    Explanation for adding anything in middle or any point between of 2 co-ordinate is superb (const C) in p5.js we have a translate() function to solve this scenario.

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

      I tried p5.js once :-) I think I encountered it that time.
      HTML Canvas also has a translate method, but I only use it if I need to rotate as well (and am lazy to do the math).

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

    Thanks!

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

      Thank you!

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

      You asked something about lastPath in another comment. Did you remove it or did RUclips delete it?

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

      I had a senior moment and didn't realise that lastPath was grabbing a reference to the actual array. Once I figured it out I removed my comment to avoid potential confusion.

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

      @@nickeax I thought so :-) But sometimes RUclips works in mysterious ways... like I can still see your deleted comment in the notifications.

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

    Good job! Thanks for teach this. I create videos too. If you care for opinions, I think the experience would be a little bit better if you were to shorten the intro a bit by cutting down from 2 comedic clips and only using one. I had a moment there where I was enjoying it and then had to hit the skip button about 4 times. All the best, Adrien.

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

      Thanks for the tips! You mean choose between the joke before the intro song and the intro song itself? I also think the intro takes too much time. I wanted to add chapters, but I guess I forgot. I'll do it today.

  • @AMith-lv2cv
    @AMith-lv2cv 2 года назад +1

    🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥

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

      🧯🧯🧯🧯🧯🧯🧯🧯🧯🧯🧯🧯🧯🧯🧯

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

    I love your stuff, but n-1 is an error and it's driving me crazy!!! 8-P

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

      n-1?

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

      Goes from .0 to .9 instead of 1.0

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

      @@vincentcleaver1925Ah yes, you're right! I think someone else pointed out the mistake a while ago but I forgot it was there :-)

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

      @@Radu I 'had' to, sorry to criticize, but it gets on my OCD! 8-P
      Gonna code this in my blog, dirty all in html copy and paste into the blog

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

      In my lazy way I've been slowly working on the basics-
      vincesalienzoo.blogspot.com/2023/11/lerp.html?m=0

  • @FreeFIyedea
    @FreeFIyedea 5 месяцев назад +1

    Night crwom

    • @Radu
      @Radu  5 месяцев назад

      :-)

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

    Am I the only one who is seeing lag in audio?

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

      Argggg, is it noticeable? Using different equipment and audio and video are not in sync. I did try to fix it, but the difference is not the same everywhere :-| I recorded 5 videos in the same day so, hope they are not going to be too pissing off :-))