Coding Challenge #19: Superellipse

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ม.ค. 2025

ความคิดเห็น • 105

  • @NStripleseven
    @NStripleseven 4 ปีที่แล้ว +21

    6:40 "I could try to derive it, but I'm just going to look it up."
    The life of a coder

  • @RhoTrepaan
    @RhoTrepaan 5 ปีที่แล้ว +8

    "Superpowers of clumsiness"
    Add to that; superpowers of "putting the fun in explanations"
    and/or "superpowers in "gettings things done" :D

  • @TrebleWing
    @TrebleWing 2 ปีที่แล้ว +1

    For the sgn function, it is a fun candidate for branchless implementations. (C syntax here)
    int sgn(int val) {
    return (val > 0) * 1 + (val < 0) * -1;
    }

  • @arturkarlov3000
    @arturkarlov3000 8 ปีที่แล้ว +3

    awesome video, you have talent for taking complex concepts and translating them into simpler terms. I want to encourage you to go over the undelying math/maths because I think understanding that stuff can be useful. and you will do a good job with it. can't wait for the next superformula vids!

  • @PeterKwanvt80
    @PeterKwanvt80 8 ปีที่แล้ว +2

    I first saw this at SIGGRAPH in 1986. It was called superquadric in those days. Some years later I taught it to a colleague who was struggling to model a cone blended onto a rounded rectangular prism. She went on to do special effects CGI in the Harry Potter movies.

  • @franksonjohnson
    @franksonjohnson 8 ปีที่แล้ว +2

    Fantastic tutorials! It appears to me that you get more comfortable with that really complex (and powerful) presentation setup with every video.

  • @PMuis
    @PMuis 8 ปีที่แล้ว +16

    Man I would love to have you as a teacher irl

  • @chibibobo
    @chibibobo 8 ปีที่แล้ว +33

    1:14 That's almost a perfect circle..

    • @TheCodingTrain
      @TheCodingTrain  8 ปีที่แล้ว +7

      indeed!

    • @daanbreur
      @daanbreur 6 ปีที่แล้ว +4

      Beter than my math profecor on school

  • @FunBy15
    @FunBy15 8 ปีที่แล้ว +11

    thanks² + thanks² dan!!

  • @liangdongzhu3082
    @liangdongzhu3082 7 ปีที่แล้ว

    这教程真是太酷了,谢谢你朋友,期待你的更多教程

  • @endofmysteries
    @endofmysteries 8 ปีที่แล้ว

    this is awesome Daniel!! so easy to follow along and code with you!

  • @SimonTiger
    @SimonTiger 5 ปีที่แล้ว +5

    12:44 and 13:02 the 2 formulas are actually just different form of the same thing.

  • @kotoriitsuka1097
    @kotoriitsuka1097 8 ปีที่แล้ว +1

    seems to have new sub ;) your videos are amazing as well as your attitude and behavior :D keep it up and you'll have tons of subs :D

  • @yuvalgat4163
    @yuvalgat4163 8 ปีที่แล้ว +1

    Great video! :)
    The sgn(a) function can be shortened to (a / abs(a)), but doesn't work when a = 0 :)

    • @yuvalgat4163
      @yuvalgat4163 8 ปีที่แล้ว

      Or:
      (val > 0 ? 1 : val < 0 ? -1 : 0);

    • @yuvalgat4163
      @yuvalgat4163 8 ปีที่แล้ว

      Apparently.. Math.sign() exists... :/

    • @TheCodingTrain
      @TheCodingTrain  8 ปีที่แล้ว +1

      thanks for these tips!

  • @goxr3plus_studio
    @goxr3plus_studio 8 ปีที่แล้ว

    Run it Daniel RUN IT!! 🌾 Show us the beautiness.

  • @yovliporat8608
    @yovliporat8608 8 ปีที่แล้ว +20

    For the sgn() function you could have just wrote:
    return val / abs(val);

    • @ZonkoKongo
      @ZonkoKongo 8 ปีที่แล้ว +9

      0/0 = 0?

    • @yovliporat8608
      @yovliporat8608 8 ปีที่แล้ว +1

      Add a try catch then? Still more compact than 3 if statements...
      Try{
      return val / abs(val);
      }catch(DivByZeroException e){
      return 0;
      }

    • @Nameci-wo1ht
      @Nameci-wo1ht 8 ปีที่แล้ว +4

      Or just add a case for val equals 0.

    • @yovliporat8608
      @yovliporat8608 8 ปีที่แล้ว +7

      Nameci2718 Yes, but that's a simple solution so I can't think of it :P

    • @louis1001
      @louis1001 8 ปีที่แล้ว +1

      Ternary operand?
      Don't know in javascript, but in pythln you could do:
      return val / (abs(val) if not val == 0 else 1)

  • @bsizzbs
    @bsizzbs 8 ปีที่แล้ว

    Awesome videos, Daniel! I'm having fun coding along. Would you consider doing maybe a more advanced series/video for those with a bit of Java experience already under their belts?

    • @TheCodingTrain
      @TheCodingTrain  8 ปีที่แล้ว

      sure thing! I might check out the nature of code videos which serve this purpose somewhat.

  • @kamoroso94
    @kamoroso94 8 ปีที่แล้ว

    I was getting excited to see you work out the math, but I forgot it's just a coding channel haha! Thank goodness for Wikipedia though.

    • @TheCodingTrain
      @TheCodingTrain  8 ปีที่แล้ว +2

      heh, I would like to do that in a video actually.

  • @mintyplays4682
    @mintyplays4682 8 ปีที่แล้ว

    This video taught me more Math than school ever will...

  • @nadkine6601
    @nadkine6601 3 ปีที่แล้ว +12

    Who got here from Stand-up Maths? :-)

    • @BenjaminAster
      @BenjaminAster 3 ปีที่แล้ว

      me!

    • @TheCodingTrain
      @TheCodingTrain  3 ปีที่แล้ว +1

      welcome!

    • @BenjaminAster
      @BenjaminAster 3 ปีที่แล้ว +1

      @@TheCodingTrain PS: instead of the "sgn" Function you made, you could just use the Math.sign function that is built-in in JavaScript and does exactly that.

  • @jonathank.1421
    @jonathank.1421 8 ปีที่แล้ว +6

    I never heard of the sgn function before... Why not use:
    f(x) = x / |x|
    instead? That would give the same result. examples:
    x=20
    f(x) = 20/|20| = 1
    x = -15
    f(x) = -15/|-15| = -15/15 = -1

    • @adlaneladjal3856
      @adlaneladjal3856 8 ปีที่แล้ว

      And if x = 0 ?

    • @jonathank.1421
      @jonathank.1421 8 ปีที่แล้ว

      Good point. What would the other function return in that case? 0?

    • @sadhlife
      @sadhlife 7 ปีที่แล้ว

      johnny Gamer it does. sgn (signum) returns zero for zero.
      that formula is true.

  • @amo6139
    @amo6139 7 ปีที่แล้ว

    you could have done the bresenham method with (1-|n|^n)^(1/n), because that is the formula for the height at x on an n unit superelipse

  • @AnneONym
    @AnneONym 8 ปีที่แล้ว

    I love this channel. I discovered it yesterday. Is there any others channels in this style that I would be happy to go check ?

    • @TheCodingTrain
      @TheCodingTrain  8 ปีที่แล้ว +1

      check out coding math th-cam.com/users/codingmath

  • @zuggrr
    @zuggrr 7 ปีที่แล้ว

    great video

  • @AKASHSOVIS
    @AKASHSOVIS 4 ปีที่แล้ว +2

    if (val > 0) {
    return 1;
    } else if (val < 0) {
    return -1;
    } else {
    return 0;
    }
    // Instead of this, you can write...
    if (val == 0) {
    return 0;
    } else {
    return (val / abs(val));
    }

  • @TienPhan-rm1jy
    @TienPhan-rm1jy 8 ปีที่แล้ว

    Thank you Daniel, I enjoyed your video very very much. side question which mac configuration do you have? just curious :)

  • @Shockszzbyyous
    @Shockszzbyyous 8 ปีที่แล้ว

    that bit at 13:08 your pointing at, I understand that r1() takes a angle as argument , but R2() and cos() what is their argument? what is that symbol ?

  • @marcasrealaccount
    @marcasrealaccount 7 ปีที่แล้ว

    Guys make the minimum value on the slider negative, it looks so cool :D

  • @lolerskates876
    @lolerskates876 5 ปีที่แล้ว

    Would be cool with space colonization

  • @jackthake7209
    @jackthake7209 8 ปีที่แล้ว

    What libraries r u using? - your videos are so cool

  • @rashmysajin4520
    @rashmysajin4520 3 ปีที่แล้ว

    Your the Bob Ross of Bob Ross

  • @andrewjardine8558
    @andrewjardine8558 5 ปีที่แล้ว

    My head exploded

  • @grainfrizz
    @grainfrizz 7 ปีที่แล้ว

    Dan, your voice here is suuuuuuuper different from today.

  • @eotikurac
    @eotikurac 8 ปีที่แล้ว

    is there any graphics software that is perfectly precise? i mean, whenever you make a shape in adobe flash, illustrator or corel draw it only makes an approximation of it. it's usually good enough but not exactly as you intended.

    • @Dong_Harvey
      @Dong_Harvey 8 ปีที่แล้ว +1

      if the issue is the use of rasterization to render said shapes in the graphics software, then you should consider using a Vector graphics editor like Inkscape..
      at least then the graphics are saved as a series of mathematical inputs and not just a plot graph..

  • @AndersWOlsen-we3nw
    @AndersWOlsen-we3nw 8 ปีที่แล้ว

    Why don't you use switch cases rather than all these if-statements? Switch cases are much cleaner to read.

  • @sahiljoshi2150
    @sahiljoshi2150 7 ปีที่แล้ว

    sgn is also called the signum function, right?

    • @sadhlife
      @sadhlife 7 ปีที่แล้ว

      sgn stands for signum, yes.

  • @Mrfaytom
    @Mrfaytom 8 ปีที่แล้ว

    nice hair cut dan

  • @JasimGamer
    @JasimGamer 4 ปีที่แล้ว

    what if 4D super shape

  • @kasturimamatha3663
    @kasturimamatha3663 4 ปีที่แล้ว

    Hello
    Sir
    I am Abhi.
    I am just learning coding
    Sir. i dont have idea how you run the program in wedsite
    Can you plzzzz tell us how you make a wedsite and run it live

    • @sanderbos4243
      @sanderbos4243 3 ปีที่แล้ว

      Look for "1.1: Introduction - p5.js Tutorial" on TH-cam and you'll find his tutorial on how to do exactly that! :-)

  • @JamesCubes-ne2iq
    @JamesCubes-ne2iq 8 ปีที่แล้ว

    i get it but it it doesn't work on processng

  • @charbelsarkis3567
    @charbelsarkis3567 7 ปีที่แล้ว

    return (value > 0)? 1 : (value < 0)? -1 : 0;

  • @ryderpham5464
    @ryderpham5464 8 ปีที่แล้ว +1

    Can you please do tutorials for vanillaJS ?

    • @ricardo.mazeto
      @ricardo.mazeto 8 ปีที่แล้ว

      Check out the channel CodingMath.

    • @purpleice2343
      @purpleice2343 7 ปีที่แล้ว

      Almost (because I didn't finish watching/writing yet) everything he's ever done in p5.js and processing I've written in pure javascript and had no problems with it.
      Your problem is not knowing JavaScript, not not knowing how to solve those problems. Once you understand what he explained, you can do it in any language, assuming that you know one.

  • @advaykumar9726
    @advaykumar9726 3 ปีที่แล้ว

    First

  • @julianm4674
    @julianm4674 8 ปีที่แล้ว

    1 second missing

  • @tobybrewin6240
    @tobybrewin6240 8 ปีที่แล้ว

    first

  • @glhf8756
    @glhf8756 8 ปีที่แล้ว

    7th

  • @pascalhesselink7515
    @pascalhesselink7515 8 ปีที่แล้ว +3

    Daniel, I'm really sorry for this bad news :(:(
    But the current project isnt in the project folder (challenges)
    rabascm.nl/LNSSU3 for photo :):) (#19)

  • @darkdemon1338
    @darkdemon1338 7 ปีที่แล้ว

    make moomoo.io challenge

  • @jelletje8
    @jelletje8 8 ปีที่แล้ว

    MATH PLOX

  • @erggish
    @erggish 7 ปีที่แล้ว

    It's so annoying hearing the circle being called a superellipse, although it's a special case... -_- dah....