Can C actually do Perfect Bézier Curves?

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 พ.ค. 2024
  • Streamed Live on Twitch: / tsoding
    Enable Subtitles for Twitch Chat
    Panim Playlist: • Panim
    References:
    - en.wikipedia.org/wiki/B%C3%A9...
    Support:
    - BTC: bc1qj820dmeazpeq5pjn89mlh9lhws7ghs9v34x9v9
    - Pay for my VPS: zap-hosting.com/en/shop/donat...
  • วิทยาศาสตร์และเทคโนโลยี

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

  • @blackhaze3856
    @blackhaze3856 16 วันที่ผ่านมา +54

    Can your Adobe Illustrator do that?

    • @user-fj3gl8wc7s
      @user-fj3gl8wc7s 16 วันที่ผ่านมา +2

      (he is on linux) xdddd

    • @OneMilian
      @OneMilian 14 วันที่ผ่านมา

      Honestly I want a drawing Pad because of him. I always draw my ideas and write stuff and ideas about it. Mypaint and gimp could be alot of fun for me. I am a nerd because i love writing my own manuals

    • @OneMilian
      @OneMilian 14 วันที่ผ่านมา

      Man honestly all you commenters are so cool who know tsoding!!
      Im pretty depressed because i have nobody in real life to talk. I cant life like this no more, i need to find an exit. I will never give up

  • @jgfjfgjfhjf
    @jgfjfgjfhjf 16 วันที่ผ่านมา +62

    honestly, you've successfully indoctrinated me into wanting to use C

    • @multicoloredwiz
      @multicoloredwiz 16 วันที่ผ่านมา

      He's very u happy he's done so though. I think

    • @MrMultiDesigner
      @MrMultiDesigner 15 วันที่ผ่านมา

      he have a pinned tweet that says if u going to learn C because of him, you're wrong

    • @jgfjfgjfhjf
      @jgfjfgjfhjf 15 วันที่ผ่านมา

      @@MrMultiDesigner usually, people who have twitter don't know they're wrong. Turns out it can be the other way round too

    • @OneMilian
      @OneMilian 14 วันที่ผ่านมา +1

      I use C since 4 Years nonstop, i always love over analyzing different binary object dumps. It literally keeps me my whole free time occupied!!!

    • @saogregl
      @saogregl 13 วันที่ผ่านมา +2

      He successfully convinced me C is the simplest language there is

  • @RickeyBowers
    @RickeyBowers 16 วันที่ผ่านมา +9

    There is are many good topics along this trajectory of development, well done.

  • @dkaaakd
    @dkaaakd 16 วันที่ผ่านมา +13

    This implementation has a flaw: editor displays curve (x(t), y(t)), but animation engine uses it as (t, y(t)).
    Essentially, during "animation" we assume that dx/dt = 1, but it is not the case for bezier curve we're drawing (one can note that projections of dots onto horizontal axis have different density).

    • @TsodingDaily
      @TsodingDaily  16 วันที่ผ่านมา +8

      Yes, I know that. These are just minor details that can be figure out later. What I needed is an editor.

    • @starup4960
      @starup4960 16 วันที่ผ่านมา +3

      Damn I wanted to comment that but didn't wanna look stupid in case I was wrong, so I spend the last couple hours programming a little animation to convince myself first 😭

    • @TsodingDaily
      @TsodingDaily  16 วันที่ผ่านมา +10

      Didn't you have fun programming tho? ;)

    • @Czeckie
      @Czeckie 15 วันที่ผ่านมา

      i dont see how to fix that without solving a cubic equation each frame

    • @starup4960
      @starup4960 15 วันที่ผ่านมา

      @@Czeckie I did this:
      while (Math.abs(p_next.x - target_x) > threshold) {
      while ((p_next.x - target_x) > threshold) {
      t -= step
      p_next = c_bezier(t, p1, p2, p3, p4)
      }
      while ((p_next.x - target_x) < -threshold) {
      t += step
      p_next = c_bezier(t, p1, p2, p3, p4)
      }
      step *= 0.1
      }
      Pretty sure that's neither "technically correct" nor fast, but it sure looks convincing enough!
      Assumes the x coordinates of the points are increasing though.

  • @ramilefu
    @ramilefu 11 วันที่ผ่านมา +1

    Takes 20 minutes to make sure we all have the appropriate pre-req knowledge before diving in. What an absolute Chad.

  • @Daniikk1012
    @Daniikk1012 16 วันที่ผ่านมา +5

    For Tsoding (If he still didn't find the answer himself) and others:
    About Inkscape being light: the setting is per document. Every time you open a new document, it creates a copy of the "default document", so to change the default background, edit the default document.
    About the const local variables being able to be used in static variables, apparently (Just learned this) it is because static variables that are LOCAL to the function, even though static, are initialized the first time the function is called (I have no idea how that's implemented, does it generate a flag and initializes when the value is not set or something?). You also should be able to do that at global level, but it didn't work because Tsoding trying to create an array of dynamic size, not dynamic initialization. Dynamically sized arrays are not allowed in statics, even local.

    • @hwstar9416
      @hwstar9416 16 วันที่ผ่านมา

      I think it's a gcc extension. tried it with msvc and tcc and didn't work. I think static is initialized at startup not when function called for the first time.

    • @Daniikk1012
      @Daniikk1012 15 วันที่ผ่านมา

      ​@@hwstar9416my bad, the standard does specify that statics are initalized at startup, before main (I was confused because in C++, they are guaranteed to be initialized the first time the function is called), so it seems to be an extension. What's weird is that it works even with -ansi -Wall -Wextra -pedantic, which SHOULD turn all extensions off.

  • @charlieking7600
    @charlieking7600 16 วันที่ผ่านมา +3

    Theoretically telling, C is Turing Complete, so it can do.
    Practically telling, it's made in Quake 3 source code. Most of curved surfaces in game are based on Bezier curves (they're called "Patches"). These are used in many other games, including Doom 3 and Xonotic.

  • @sadiewopen
    @sadiewopen 15 วันที่ผ่านมา +1

    For moving the head you should try making your curve go below y=0 before going up. That way it would look like it has some momentum

  • @yehoslavrudenco4549
    @yehoslavrudenco4549 15 วันที่ผ่านมา +1

    I don't just get the difference between и and ы, these are two completely different sounds I cannot really confuse, I'd rather confuse t and d, or p and b. And it was surprising for me when a Russian speaker said that my и is actually an ы.

  • @user-pg9xo2ts5v
    @user-pg9xo2ts5v 16 วันที่ผ่านมา +6

    Wait is the subtitle actually the twitch comments?

    • @phantomforcesisdumbgame6964
      @phantomforcesisdumbgame6964 16 วันที่ผ่านมา

      bro i just realized that lmao its so smart

    • @gutoguto0873
      @gutoguto0873 16 วันที่ผ่านมา

      what switch comments

    • @isaklovas
      @isaklovas 15 วันที่ผ่านมา

      @@gutoguto0873 he meant to say twitch

    • @user-pg9xo2ts5v
      @user-pg9xo2ts5v 15 วันที่ผ่านมา

      @@isaklovas yes, I edited it

    • @gutoguto0873
      @gutoguto0873 15 วันที่ผ่านมา

      oh ok

  • @mattshu
    @mattshu 16 วันที่ผ่านมา +5

    Thank youuuu

  • @phantomforcesisdumbgame6964
    @phantomforcesisdumbgame6964 16 วันที่ผ่านมา +1

    I just realized the subtitles are chat wtf thats so smart

  • @SaidMetiche-qy9hb
    @SaidMetiche-qy9hb 15 วันที่ผ่านมา

    I think it would be cool to data drive panim, and have an editor for the "setting" file for it which can allow to configure the interpolators and tasks

  • @ovi1326
    @ovi1326 16 วันที่ผ่านมา +5

    you can cast a function pointer to void* just fine in iso c (c99 onwards at least) but you have to do the cast explicitly like `(void*)func`
    as for static arrays requiering comptime initialization I have no idea why that doesn't work for array sizes (maybe the compiler is interpreting it as a variable size array based on passing an ident associated with a variable even tho it's comptime known?)
    also c23 introduces constexpr which should just work as expected

    • @ovi1326
      @ovi1326 16 วันที่ผ่านมา

      Also it's defined behaviour to take a typed pointer convert it into a void* and cast it back to the same type, vtables in wasm work the same way they do in x86. Now taking a function pointer casting it to void* and then casting it to char* to read the assembly is undefined behaviour.

    • @thebatchicle3429
      @thebatchicle3429 16 วันที่ผ่านมา

      @@ovi1326I don’t think it’s portable to cast a function pointer to void* because they may have different sizes

    • @ovi1326
      @ovi1326 16 วันที่ผ่านมา

      @@thebatchicle3429That could be the case but usually the function pointers are either the same size or smaller than data pointers (like in the early days of wasm64, I did a quick search and wasn't able to find any other platform that did thay). And it's defined behaviour to cast UINT32_MAX to size_t and then back to uint32_t, there is no way overflow would happen.

  • @afterschool2594
    @afterschool2594 16 วันที่ผ่านมา +2

    Man your explanation for bezier curve is the real how knowledge should be explained by a real intellectual not a gate keeper.

  • @bukitoo8302
    @bukitoo8302 16 วันที่ผ่านมา

    the thing is that int N=2; char array|[N] defines a memory allocation, and not allowed.
    but int N=2; and const char N2 = {N}; is used as an initializer... and this is valid

    • @hwstar9416
      @hwstar9416 15 วันที่ผ่านมา +2

      its actually not standard C. it's a gcc extension

  • @bbq1423
    @bbq1423 15 วันที่ผ่านมา

    42:47 Can't do it at compile time since N is not static. Compiler can't know if someone somewhere casts away the const and modifies it.

  • @jonathanriessner4389
    @jonathanriessner4389 16 วันที่ผ่านมา +2

    Wikipedia is actually gatekeeping the hell outa their information.
    for me its one of the most important sources, but thats because I have professors that explaining the shit whats on there.
    without the privilege of my education I wouldn't have a chance to understand shit on this "platform "

    • @zerocase1092
      @zerocase1092 15 วันที่ผ่านมา

      It's really not, it's the mathematicians. Someone can probably add this explanation since Wikipedia is community driven.

  • @RealCatDev
    @RealCatDev 16 วันที่ผ่านมา +2

    what have we learned today? Being polish is cheating therefore I am a cheater.

  • @esepecesito
    @esepecesito 12 วันที่ผ่านมา +1

    My 2 cents:
    1) ABSOLUTELY there is mathematical gate-keeping BS everywhere. The goods ideas are (a) not so many (b) very simple
    2) I cannot recommend enough the video about Bezier Curves of Freya Holmer

  • @anon_y_mousse
    @anon_y_mousse 5 วันที่ผ่านมา

    You know, just reading the chat comments can be hilarious sometimes. Like the people arguing over compiler implementations and pushing to answer a question that's answered in the standard document by looking at implementations which may not be relevant to their own usage anyway. Compiler Explorer and speed up certain testing, but no compiler should be used as a replacement for reading what it says in the actual standard.
    I still don't get why so many people have problems with accidental assignments in conditionals because the majority of the time you're not testing for flat equality, but then I also don't make such mistakes when writing code even when using flat equality tests. Although, towards that end in my own language, I did make it so that simple assignment in a conditional isn't possible with just = and you'd need to use := to force an assignment.
    I definitely agree that mathematicians using complex formulae with "unreadable" symbols is gatekeeping. I haven't used much complex math in my career, but what I have used was much easier to understand when written as code than as a squiggly formula.
    One final thought I had regarding hot reloading and v-tables is that the method that most implementations aim for is an optimization technique and given when C++ was first developed it makes sense because even at millions of function calls on the older hardware that it would've been run on, it's possibly too much to ask of the hardware. However, in the current day, they probably should use the indexing method because even at billions of calls it's still relatively speedy and allows for hot reloading.

  • @chexi
    @chexi 16 วันที่ผ่านมา

    полный кайф, классическое программирование. жаль понимаю 0.1% от всего)))

  • @diegorocha2186
    @diegorocha2186 16 วันที่ผ่านมา

    Blululululululululu indeed!!! 38:00

  • @SadShiry
    @SadShiry 6 วันที่ผ่านมา

    SUPRAAAAAAA

  • @mokopa
    @mokopa 6 วันที่ผ่านมา

    What you call "gatekeeping" is actually just "rigor"

    • @TsodingDaily
      @TsodingDaily  6 วันที่ผ่านมา +2

      Does not change anything. The worst communicators always sacrifice clarity in the name of "rigor". Because for them it's just a gatekeeping tool. We are humans at the end of day. Leave your rigor to computers and automatic proof assistants. We already automated this shit long time ago.

  • @magnum21th.c
    @magnum21th.c 15 วันที่ผ่านมา

    😂gatekeeping❤

  • @salim444
    @salim444 16 วันที่ผ่านมา

    10:21 bro haven't seen topology

    • @Err-G
      @Err-G 16 วันที่ผ่านมา

      Damn, topology is an entire universe

  • @blastygamez
    @blastygamez 16 วันที่ผ่านมา

    Nice

  • @puncherinokripperino2500
    @puncherinokripperino2500 9 วันที่ผ่านมา

    do NURBS

  • @DrSpooglemon
    @DrSpooglemon 5 วันที่ผ่านมา

    How much Adderall does this guy get through?

  • @GuerreroMisterioso95
    @GuerreroMisterioso95 16 วันที่ผ่านมา

    No, but Fortran can

  • @timeover6175
    @timeover6175 16 วันที่ผ่านมา +4

    Русский акцент 😂

    • @aciddev_
      @aciddev_ 16 วันที่ผ่านมา +3

      ну так он буквально из новосиба

    • @timeover6175
      @timeover6175 16 วันที่ผ่านมา +1

      @@aciddev_ жаль что не ведет уроки на русском)

    • @0x2a2f
      @0x2a2f 16 วันที่ผ่านมา +4

      @@timeover6175 иди уроки учи

    • @timeover6175
      @timeover6175 16 วันที่ผ่านมา

      @@0x2a2f в будку шарик

    • @ProtossOP
      @ProtossOP 16 วันที่ผ่านมา

      @@0x2a2fчёт ты на ровном месте заагрился, не надо таким быть

  • @Simple_OG
    @Simple_OG 16 วันที่ผ่านมา +1

    Bro do some rust

    • @AndiPandi-yj7rc
      @AndiPandi-yj7rc 16 วันที่ผ่านมา +8

      Nah c do be godlike

    • @Simple_OG
      @Simple_OG 16 วันที่ผ่านมา

      @AndiPandi-yj7rc, I know C is a very good language, but I am currently learning Rust. Therefore, a tutorial on Rust would be helpful.

    • @SaidMetiche-qy9hb
      @SaidMetiche-qy9hb 15 วันที่ผ่านมา

      haa gayyyy