Coding Challenge 125: Fourier Series

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

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

  • @vigneshwarm
    @vigneshwarm 5 лет назад +1017

    3blue1brown recommended this video for his Fourier transform video

    • @akremhadji7326
      @akremhadji7326 5 лет назад +12

      I've just watched it, it was amazing !!!

    • @FilthyManatee
      @FilthyManatee 5 лет назад +14

      I just watched his video, then I tried coding my own Fourier series. Figured I would come on here and see what I did wrong.

    • @akremhadji7326
      @akremhadji7326 5 лет назад +5

      ​@@FilthyManatee In this video the Fourier series is developed in JavaScript language to be run on a normal web browser. If you want more advanced tools to work with such series you can use mathematical software (Matlab, Maple, Octave ..) they have many dedicated methods to be implemented easily. If you want to do things the hard way ;) you can download the code of the presented script in this video and try to modify the coefficients or change other parameters.

    • @FilthyManatee
      @FilthyManatee 5 лет назад +4

      @@akremhadji7326 I wrote mine in the hard/fun way (javascript/canvas) already. I did it very differently than what was shown here, but was still able to learn a thing or two watching this video. It gave me a few things to think about and change in my code. I went right into the chain of alternating spinning vectors and drawing from the last point on the chain.

    • @ejejej9200
      @ejejej9200 5 лет назад +3

      I came here from 3 Blue 1 Brown. And, I am so happy I did! This is a great channel! :)

  • @sharphurt8753
    @sharphurt8753 6 лет назад +122

    I'm Russian student and I want to express my huge thanks to The Coding Train channel! Thanks to you I have top marks in my school! The whole world loves you!!!

  • @jonnylinford
    @jonnylinford 6 лет назад +205

    So happy to see you and Destin interact. This is the intersection of all the best content on RUclips

  • @ibuucoksiregar9024
    @ibuucoksiregar9024 4 года назад +15

    90% of my coding skill is from Coding Train.
    Everytime my friends ask me where i learned something, I always show them this channel.
    I love this channel so much❤️❤️

  • @oscard4801
    @oscard4801 6 лет назад +206

    I'm 11 and I'm from Mexico, and have been programming for 3 years and Coding Train is my source of inspiration and learning.

    • @TheCodingTrain
      @TheCodingTrain  6 лет назад +31

      So nice to hear! Please feel free to share anything you make 🙂

    • @GodofChookie
      @GodofChookie 6 лет назад +18

      it's awesome to have such a productive hobby you get enjoyment from and willingly invest your free time. especially at such a young age. keep it up

    • @philippg6023
      @philippg6023 6 лет назад +3

      Awesome keep it up

    • @LongLe-nt8bv
      @LongLe-nt8bv 6 лет назад +1

      b0ss thats great for his age and its called a "comment", plus he just want to say thanks to Daniel

    • @oscard4801
      @oscard4801 6 лет назад +5

      ​@@don1041 I learned Javascript, p5.js, HTML and CSS

  • @PatrickAnimator
    @PatrickAnimator 6 лет назад +16

    dude...I am obsessed. you are literally one of the best teachers Ive ever experienced.

  • @sirecartier7881
    @sirecartier7881 6 лет назад +5

    I am a high-school student from France and I am really happy to see how great and efficient code can be with people like you!!!

  • @USAwizeguy
    @USAwizeguy 6 лет назад +20

    As an EET major looking back at studying how to code, I love this! We look at wave forms all day. I am going to recreate this and show my fellow electrical engineers at work.

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

      Did you do it? Were they impressed, or at least mildly entertained?..

    • @alexandermcclure6185
      @alexandermcclure6185 7 месяцев назад

      please we need an update

  • @ianprado1488
    @ianprado1488 6 лет назад +4

    I need to more consciously appreciate the amazing, high quality content on RUclips. We are living in a beautiful time in history

  • @RoGeorgeRoGeorge
    @RoGeorgeRoGeorge 6 лет назад +186

    @3:30 What you are calling "Amplitude" is in fact the "Peak to Peak" value. The "Amplitude" will be only half of that.

    • @TheCodingTrain
      @TheCodingTrain  6 лет назад +42

      Indeed, thank you for the correction!

    • @CJBurkey
      @CJBurkey 6 лет назад

      But the coefficient (often called amplitude) is the vertical peak to peak distance of the wave.

    • @NoorquackerInd
      @NoorquackerInd 5 лет назад +5

      @@CJBurkey Peak-to-Peak value isn't the coefficient or the amplitude. Peak is the absolute distance from the average of a function to either the min or max and peak-to-peak is the absolute distance from min to max. The amplitude is the peak value, and on sinusoidal functions, the peak-to-peak value is double the amplitude or peak value.
      This is more of the electrical engineer view of it, though

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

      What are you calling "peak to peak value" is in fact sometimes called "peak to peak amplitude", and what you calling "amplitude" is sometimes called "semi-amplitude".
      It's kinda similar situation as with "Natural numbers" - the name is ambiguous and it's better to refer to it either as "Positive integers" or "Non-negative integers" depending on what exactly you mean.

  • @carlosmorasalguero
    @carlosmorasalguero 6 лет назад +299

    Wow, smarter every day in the coding train... Avengers is no longer the most ambitious crossover in the history of the world

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

    After visualising this in the full complex form, it becomes pretty clear how higher frequencies enhance the "precision" of the wave position. I love how the whip rolls up into a tight ball with each rotation and each addition of epicycles.

  • @Abhishek-hy8xe
    @Abhishek-hy8xe 4 года назад +3

    I love this channel and this guy and all the videos. Thank you .

  • @x-lightsfs5681
    @x-lightsfs5681 6 лет назад +698

    That took me -1/12 lines of code

    • @sujals7108
      @sujals7108 6 лет назад +26

      Infinite lines is impossible.

    • @x-lightsfs5681
      @x-lightsfs5681 6 лет назад +37

      @@sujals7108 But what if i made a code that adds a line to the js file every frame?

    • @sujals7108
      @sujals7108 6 лет назад +29

      @@x-lightsfs5681 Then to make infinite lines, you would need an infinite number of frames, hence infinite time.

    • @poopmaster9984
      @poopmaster9984 6 лет назад +10

      @@sujals7108 how bout making more line each frame? Then you'll get to infinity in no time :v

    • @PhoenixD
      @PhoenixD 6 лет назад +16

      @@x-lightsfs5681 cant go to infinity since memory is always limited :)

  • @POPO-od8jb
    @POPO-od8jb 5 лет назад +1

    Isn't it so satisfying to witness that sine waves are making rectangular wave , that ending of this video made my whole 2019 yr , and a good start of 2020 , thanks for this awesome video 🌷

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

    I love the way the best and the brightest youtube channels are inspired and motivated by each other...that is a really positive environment.... Siraj,you,smarterEveryday,3 blue 1 brown.....
    You guys really help me and many others as well .
    Thank you.

  • @iVideo1011
    @iVideo1011 6 лет назад +3

    Just stumbled across your channel. This is the best RUclips channel I've ever seen. So many high quality videos and such great teaching and enthusiasm. I'm just speechless!

  • @shashik962
    @shashik962 6 лет назад +25

    My favourite channel... This is really great...

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

    Fantabulous! This needs to be taught in every DSP course!

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

    this is so freaking fantastic! I could do this all day

  • @maxteer2800
    @maxteer2800 5 лет назад +6

    I really appreciate the goofs and slight logic mistakes on this one, it was almost more enlightening than if he had just done the thing

  • @FM-kl7oc
    @FM-kl7oc 11 месяцев назад

    27:18 Kinda cool illustration of aliasing that happens when the sampling rate is not a perfect multiple of the signal frequency being sampled. After increasing it to 100, sometimes you get a big spike at the corners on the square wave, sometimes not -- this is the aliasing. Sometimes you're "lucky" to sample (draw) when the tip of the pendulums are at the very top or bottom of the corner, and you get a spike. Sometimes you're "unlucky" to sample (draw) when the tip of the pendulums are not near the top or bottom, and you get a more traditional "90 degrees corner" without the spike.

  • @shannonadamj
    @shannonadamj 6 лет назад +16

    Yoooo nice plugging smartereveryday. I love that channel.

  • @snacksy7754
    @snacksy7754 4 года назад +23

    28:28 I love that ending. *Has a good moral:* If you stumble over your words instead of trying to solve the confusion just give up, blow your flute, and say goodbye :D

  • @sobanudlz
    @sobanudlz 6 лет назад +149

    *Procrastinating intensifies*

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

      Underrated comment lol

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

      hah, yeah

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

      hell, there are worst ways to distract yourself. programming fourier transformations is a decent way to waste your time (though time spent learning isn't wasted, I'm told)

  • @izzy31337
    @izzy31337 6 лет назад +34

    you always release coding challenges just when im studying a specific topic

    • @marcinkienast1134
      @marcinkienast1134 6 лет назад +2

      Yeah, I'm supposed to study algorithms and time complexity proving. So... I guess I will fail the test, but I will know a bit more about FS. Totally worth it xD

    • @marcus_w0
      @marcus_w0 6 лет назад +1

      Right? I was recently looking into graph plotting and stumbled upon this, too. And within a week there this video. Hee's tracking my browser history.... I have to go.

  • @jerryplayz101
    @jerryplayz101 6 лет назад

    4:12 - To play a musical note, the sine wave is made of multiple sine waves. You have the note you want, but you also have some overtones.

  • @sonik382
    @sonik382 6 лет назад +3

    Awesome, interesting and instructing. Thank you for all the effort you put in the channel!

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

    This is a good example of coding Fourier series, thanks.

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

    the slider part at the end is even more interesting as it gives even chaotic curve which when condensed give non continuous sine waves of different frequencies......*wow*

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

    An interesting thing that was done i think in 3blue1brown was to assign random or non-regular growing or shriking radius to the circles. Theses Fourrier series create really unique and interesting patterns, some of them event ressembing famous man made paintings.

  • @deez_gainz
    @deez_gainz 6 лет назад +7

    That refactoring song though ahah! We need 10 hour version for productive coding work!

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

    27:38 - 27:40 there is a time where the line is near horizontal facing right! pause and use the , (comma) and . (period/full stop) to go back/forward by 1 frame
    edit: press 27:38 then wait for it to go right
    edit 2: 27:55 also
    edit 3: also at 27:54 it's at a very high point (right side)

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

      hehe yeah even I noticed that, when all the circles are extended to the right, it essentially cuts the wave!!!

  • @dianewilliams5830
    @dianewilliams5830 6 лет назад

    Thank you. As always, you make learning so much fun. I've never been able to visualize how Fourier creates a square wave or any wave until now.

  • @BonsayCow
    @BonsayCow 6 лет назад +1

    Fun fact at 27:20 you can see spikes on the corners of the function and this is called the Gibbs phenomenon and you can never get rid of it, due to the discontinuity of the function that you are trying to approximate.

  • @eda-un8zr
    @eda-un8zr 3 года назад +1

    I'm native Turkish and i like how you pronounce the name of the website :D and great video, thank you

  • @Wolf-gt3kd
    @Wolf-gt3kd 5 лет назад +2

    This was really fun to watch that i didn't notice the video's lengh was 30min.
    Nice work really :D

  • @zackd41
    @zackd41 6 лет назад

    LOVE The Crossover with Smarter everyday, Been getting into coding because of you, thanks!

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

    awesome !!! The movement of all those circles radii looks so "biologic", fascinating !

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

    Thanks!

  • @Apocalypsee07
    @Apocalypsee07 6 лет назад +2

    I like these Coding Challange videos :) trying to replicate these in python makes learning so much fun and also easier. Thank yyou!

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

      What do you use to draw in python? Turtle?

  • @jonathangodar4239
    @jonathangodar4239 6 лет назад

    I searched on how to get the x and y values on something that had been rotated for hours. I knew that it would be something having to do with the angle and the hypotenuse, but I never found what I was looking for. I finally got the answer by some guy on Reddit this morning. Why couldn’t I have watched this video when I really needed it?

  • @jonathanwalther
    @jonathanwalther 6 лет назад

    Best analogy ever. Very smooth.

  • @HardusHavenga
    @HardusHavenga 6 лет назад

    Dude, you are my new hero.

  • @sidim.aourid9958
    @sidim.aourid9958 6 лет назад

    The amplitude is from axis x to max or to min. Example if, s(t) = a sin(t), a is the amplitude. Thank you for all your videos, they are instructive and well done.

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

    Primer video que veo. Adoro!

  • @joecamroberon9322
    @joecamroberon9322 6 лет назад

    You deserve so much more attention.

  • @xnick_uy
    @xnick_uy 6 лет назад +6

    The end result looks like a fantastic whip. WT-TSH!!

  • @AliParlakci
    @AliParlakci 5 лет назад +25

    1:21 Website's name actually means "science is so beautiful"

  • @MACHINEBUILDER
    @MACHINEBUILDER 6 лет назад +3

    Wow awesome job it's super satisfying! :)

  • @myetis1990
    @myetis1990 5 лет назад +43

    You can translate
    Bilimneguzellan= Bilim+ne+ guzel +lan = Science+ what+ beautiful +guy = hey guy Science is what a beautiful thing !
    for pronounciation,
    go to google translate, select turkish , type the "Bilim ne güzel lan" and tap the voice button :)

    • @muhtesemtavasap6411
      @muhtesemtavasap6411 5 лет назад +3

      Oh be gördüm rahatladım. Yoksa ben yazacaktım.

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

      Iyi yetiştin

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

      Adamsın, adam sitenin ismini okurken bunaldım...

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

      djfsdfsjdfjdfljdfg çok iyi okumadı mı dfghjkdfghjdfghjhjdfgkdfg

  • @AmirAdzim
    @AmirAdzim 6 лет назад +7

    Just to correct you there on the definition of amplitude at about 3:45 the amplitude is the height difference between the very top and the middle part of the wave (position of equilibrium) :) overall very nice video!

    • @TheCodingTrain
      @TheCodingTrain  6 лет назад +1

      Yes indeed, thank you for pointing this out!

    • @AmirAdzim
      @AmirAdzim 6 лет назад

      @@TheCodingTrain thank you as well for providing very educational (and interesting) content!

    • @rahulbansode1537
      @rahulbansode1537 6 лет назад

      What do you mean the middle part or position of equilibrium Sorry I don't understand

    • @AmirAdzim
      @AmirAdzim 6 лет назад +2

      @@rahulbansode1537 the point that is right in between the highest peak and the lowest peak of the sine wave is called the equilibrium position. Say you have a child on a swing. The equilibrium position is the position of the child when the swing is at rest. When the child starts swinging, the highest peak (and this is relative) is when the child is on the highest position in front (positive) of the equilibrium position and the lowest peak is when the child is on the highest position behind (negative) the equilibrium position. So the amplitude (or in this case the maximum height at which the child is swinging at) is the height difference from the position of equilibrium (not swinging) to any of the maximums (either behind or in front of the swing). Sorry if this analogy is too complicated im not really good at explaining stuff.

    • @rahulbansode1537
      @rahulbansode1537 6 лет назад

      @@AmirAdzim that was a great explanation thank you!

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

    Theres a bug though. Look at 28:11 . The spike switches positions from the top to the bottom. Also there should be two spikes (smaller than they are here) and on both the bottom and the top. So theres a mistake somewhere.

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

    Something interesting at 27:46 when those circles come around they almost *slap* the square wave and it changes the spikes at the corner of the square wave lol

  • @JenishJain6
    @JenishJain6 6 лет назад +1

    What a coincidence the video was suggested to me just when I was about to start Fourier series for my exam prep.👻

  • @anandprakash4995
    @anandprakash4995 6 лет назад

    This video inspired me to learn p5.js .Will be my new resolution to learn p5.js !!!

  • @xnick_uy
    @xnick_uy 6 лет назад

    In case you are wondering, although a Fourier Series and a Fourier Transform are not the same, it is possible to devise a framework in which you can formally treat them on equal footing if you want to (you might need to look into Dirac combs and intervals of ever-increasing length).
    And more importantly: within the realm of numeric computation you are pretty much forced to use the *Discrete* Fourier Transform instead of the "bare" (continuous) Fourier Transform, which turns out to be essentially the same as the Fourier Series.
    (I'm assuming you don't make a distinction about using either trigonometric functions or complex exponential).

    • @TheCodingTrain
      @TheCodingTrain  6 лет назад

      Thanks for this clarification! I'm hoping to do a video on DFT next!

  • @askquestionstrythings
    @askquestionstrythings 6 лет назад

    I was anticipating your video since you mentioned doing this in the smarter everyday video comments.

  • @matthewvicendese1896
    @matthewvicendese1896 6 лет назад +2

    You can make
    y = negative radius sin(time) ..... because y is upside in computer land.

  • @kindpotato
    @kindpotato 6 лет назад

    I'm glad after a couple years of thinking about the fourier transform, I made something like what he talked about with the homer simpson being drawn,

  • @mefuri_k
    @mefuri_k 6 лет назад +1

    You have a great taste on youtube channels you watch

  • @alajlan2012
    @alajlan2012 6 лет назад +2

    this is EPIC , would you please continue uploading like this content? especially on fourier drwaing visuals?

  • @michael-gary-scott
    @michael-gary-scott 6 лет назад

    I’m actually so excited for this video

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

    Amazing. Thank you for sharing your awesome skills.

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

    Interesting to see the fractal tree branches being produced here by the circles radiuses 23:50

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

    This guy is the smartest guy in the neighborhood - the Mr Rogers of code.

  • @AlGhifari7
    @AlGhifari7 5 лет назад +20

    Hey, go to 3Blue1Browns Channel for a new video about Fourier Series!!

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

    Brother, dude, friend Daniel, thank you!

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

    Very nicely done! You could also add some p5.sound and explain vibrato, tremolo and other sound effects.....

  • @bamkparto
    @bamkparto 6 лет назад

    4:56 - Fourier Serier is like a smothie, like a video in premiere, like a song in FL, like a 3d scenerey in Blender,like a lego model,
    7:53 - 10:09 - VS autocomplete feature
    3:45 - Amplitude is the height difference between the very top and the middle part of the wave (position of equilibrium) :) overall very nice video!
    ​​@irAdzimm
    by @K
    When you went to 100 iterations for the square wave, the overshoot spike would jump from the top of the wave to the bottom after it was already drawn. Look around @ and pay close attention to the top and bottom of the wave after they're drawn, as they move across the screen.
    *Related* *Projects*
    ruclips.net/video/CjFR4p1Mwpg/видео.html
    @t

  • @yusufberkaygirgin9694
    @yusufberkaygirgin9694 6 лет назад +7

    page's name is "bilim ne guzel lan" and it means in english "science is what a sweet thing buddy" :D

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

    What I see is "The Professor" is teaching us the Fourier

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

    very nice code, ofcourse would be nice other slider for time this is the function that I made for this timeslider = createSlider(0.001, 0.05,0.001,0.001); and then where it is time u put timeslider, the variables for this are (min,max,default,setpbystep)

  • @shamilcarela1699
    @shamilcarela1699 6 лет назад +1

    Great video, loved it.

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

    Could someone please explain to me that doing the command "unshift" is the only thing I did not understand. Thank you
    15:19

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

    3:25 - but it's _double amplitude,_ the amplitude describes radius, not diameter.

  • @김유황오리-n7n
    @김유황오리-n7n 5 лет назад

    Very very useful. Thank you so much Dan

  • @HisMajesty99
    @HisMajesty99 6 лет назад +2

    This was amazing, thanks for doing a video on this

  • @The.Jaynish
    @The.Jaynish 4 года назад

    You are the best man

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

    Does anyone know what the html document looks like?

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

    I like your approach to explanation - really interesting - cool video

  • @Forced2
    @Forced2 5 лет назад +2

    Is it just me or is this pattern of circles rotating around eachother looking like a whip when it reaches a hundred.
    Maybe this is how a whip delivers such a fatal blow.

  • @Tek-ns
    @Tek-ns 5 дней назад

    Look like project for ultimate synthesizer this is the vco stage but the ADSR can be used in more basic and fast transformation

  • @stuartyellow1679
    @stuartyellow1679 6 лет назад +1

    Do you know about the Gibbs phenomenon? It dosent matter how hard you (your computer) try you will have those "peaks" at discontinuities. Only if you add up infint waves it is theroretically converging to the rectangular function.
    I hope my explantion makes sense :)

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

    Hey man! Found your channel today And I really love it!
    I do want to just correct a little error. There’s a difference between the Fourier TRANSFORM and the Fourier SERIES. The transform is indeed unsmoothying a smoothie so to say, but that has to do with infinity integrals in the complex plane (don’t ask). The series on the other hand takes a periodic function and approximates it with an infinite series of simple sines and cosines. Kinda like a Taylor series for periodic waves.
    There may be a connection between the two, I don’t deal with them a lot in my life, but just wanted to let ya know 😊
    Edit: ah I see u addressed it. Thank you!

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

      Thanks for the feedback!

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

      The Coding Train my pleasure! I really enjoy the channel! Will be staying glued to ur work for a good long while
      As a coding challenge, why not try Runge Kutta approximations of differential systems? Something very similar to what you did with Lorenz System, but much more accurate. Just maybe something to tickle your fancy

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

    Brother me Bangladeshi your good tips my head very easy work thank you so much brother

  • @vladimirshitov2160
    @vladimirshitov2160 6 лет назад

    Damn, I love Python and wanna use it for work. But I don't know yet how to do all these cool stuffs in Python so I learn JS because of this channel :D Thank you, that is great!

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

    this guy is so funny i love it

  • @matthewvicendese1896
    @matthewvicendese1896 6 лет назад

    I am so excited !!

  • @Zzznmop
    @Zzznmop 6 лет назад +1

    at 9:50, would it make more sense to reverse the roles of x, y to make it rotate counterclockwise instead of decrementing time?

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

    Amazing 😄

  • @nevokrien95
    @nevokrien95 6 лет назад

    frouier seiries can represent any function because all functions contain frequencies even if they are at infinity

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

    i come from 3b1b and i barely know coding, but i just subscribed...

  • @aeswere
    @aeswere 6 лет назад +1

    I took a small hiatus from this channel but came back as I was bored, decided to follow this video (I usually watch). I changed the slider into an input box so you could input whatever number you'd like, and the circles would be added.
    I'm not sure if this is the best way to use an input box in this scenario but it does work.
    function setup() {
    createCanvas(960, 350);
    input = createInput();
    input.position(5, 325);
    }
    function draw() {
    frameRate(30)
    background(0);
    translate(200, 200);
    let x = 0;
    let y = 0;
    let circles = 0;
    if (input.value() == 0) {
    circles = 1;
    } else {
    circles = input.value();
    }
    for (let i = 0; i < circles; i++) {
    let prevx = x;
    let prevy = y;
    let n = i * 2 + 1;
    let radius = 50 * (4 / (n * PI));
    x += radius * cos(n * time);
    y += radius * sin(n * time);
    stroke(255, 100);
    noFill();
    ellipse(prevx, prevy, radius * 2);
    //fill(255);
    stroke(255);
    line(prevx, prevy, x, y);
    //ellipse(x, y, 8);
    }

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

      How did you make the html document or how did you see the code in Chrome?

  • @djtygre
    @djtygre 6 лет назад

    my most favorite to date

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

    28:20 Eyyy that would be based on quaternions. Fun.

  • @clementlebeau484
    @clementlebeau484 6 лет назад

    I’d love to see a part 2!

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

    What is up with all this spaghetti code? Especially with needing to futz with your loop to change the cycles you use; imagine trying to do something that doesn’t fit into a simple formula with this. This looks like the very definition of a place to use object-oriented coding. Make a class called Epicycle, which contains a radius, center, current angle, rotation speed, and a nextCycle. There is also a class function (or whatever you call it) called Advance, with one point as a parameter; it increments that circle’s angle by the speed, draws its circle and line based on the center given as a parameter and other data, then if there is a nextCircle it Advance()s that with the new endpoint as parameter, but if not it unshifts the new endpoint to the list of points to draw the curve and draws it. That way, you can just generate a bunch of Epicycles, set their parameters and set each as the nextCycle of the previous a la a linked list, and just call firstCycle.Advance(0, 0) to recursively draw everything.

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

    0:00 Intro
    7:00 Part 1 - Laying the groundwork
    16:19 Part 2 - Making it modular and making the series
    27:39 Outtro

  • @engineero4945
    @engineero4945 6 лет назад

    Geniuss😭. Please teach us more !