Programming & Using Splines - Part#2

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 พ.ย. 2024

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

  • @-andymel
    @-andymel 3 ปีที่แล้ว +2

    I really can only join the praise. It's simply amazing how you manage to add so much info while still being that intelligible

  • @CarstenMeyer
    @CarstenMeyer 7 ปีที่แล้ว +15

    Very nice! I once implemented the length calculation with the same idea but my code was very ugly and unreadable. Your videos are awesome because your explanations are very clear and straight foreward. Timeless tutorial videos!

    • @javidx9
      @javidx9  7 ปีที่แล้ว +3

      Hey Thanks Carsten!

  • @bobdero9883
    @bobdero9883 7 ปีที่แล้ว +3

    There it is, excellent video.
    I've been neglecting catmull-rom splines for a long time, even though I'm very familiar with bezier curves and parametric surfaces implementantions.
    I must say you've saved me a lot of effort with these two spline videos.

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

      Glad I could help Kareshi. Cheers!

  •  4 ปีที่แล้ว

    Huge thanks for these two videos. I always find using graphs, diagrams etc to be crucial for me to understanding abstract things like this and you've certainly helped immensely in doing this - cheers. Really enjoy your videos, gives the old grey matter some needed exercise.

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

    of all the times i tried diving into splines, this (series of two) made me "get" it. Thanks :D

    • @javidx9
      @javidx9  6 ปีที่แล้ว

      Nice one Rho, Splines can be a bit difficult, but as soon as you realise just how simple they are, you never stop using them!

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

    You are one of the best teachers i have ever had since i started college
    Thanks!

  • @1st_ProCactus
    @1st_ProCactus 7 ปีที่แล้ว +1

    Awesome, I have been looking for something like this for years, I will be using some of your code and concepts in your videos for my 'too big' project.
    Thanks for doing this, I hope your channel gets the magic youtube boost.

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

      Thank ProCactus, as long as people find it useful, and you have, then I'm happy!

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

    I love watching that wireframe space ship wind and wend its way around the spline path.

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

    Also, you might want to use binary search to find the node & offset from a point on the spline's perimeter. Of course, this means that the nodes would have to store not only their length, but also their distance from 0.

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

    I implemented a spline class in my game engine and I noticed that it was very difficult to try and get true velocity independence when sampling from the spline using the normalized percentage value t. I think this is due to samples being more concentrated around the end points of each segment and thus the velocity would fluctuate a little between each point. To solve this, I created a function in my spline class that computes a t value from a distance along the spline in world units using a binary search to find the t that is closest to the desired distance along the spline. Then to move along the spline at an independent velocity, I declare a distance variable that is incremented each frame by a velocity value which I then use to sample from the spline data using the previously mentioned function to compute the transform of whatever is traversing the spline.

    • @javidx9
      @javidx9  6 ปีที่แล้ว

      Hi Ruxify, that's quite an interesting approach. Does it handle the spline changing in real time too?

    • @Ruxify
      @Ruxify 6 ปีที่แล้ว

      Yes! It calculates it based on the spline's state when you call the function... though since it uses a binary search function it may be more efficient to pre-compute a linear path from the spline whenever the spline changes rather than every frame.

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

      Found the same problem and then saw your comment. You are right! There is non-linearity in "t" regarding to the distances, so the divide operation in "GetNormalisedOffset" which intended to result the fractional "t" will be inaccurate. Binary search is good idea!

  • @nightwintertooth9502
    @nightwintertooth9502 2 ปีที่แล้ว

    I have to correct you. Although you can use linear rectification to estimate the length of a curve, you can do so while avoiding iteration with elliptic integrals. The lack of sustainable arc length for the ellipsis required the need for the elliptic integral. My research gathered quite a few matlab projects that solve for incomplete arclength in three different orders, or by using Jacobi / Jacobi Zeta in four different ways. Hunt around for moiseevigor's repository and find the computer answer to the arclength for nonclosed incomplete arcs like the hematite curve.

  • @kks2105
    @kks2105 4 ปีที่แล้ว +1

    Thanks for the excellent tutorial.
    Are there any plans to make video on B-Spline and Bezier curve ?

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

    I really enjoy your series. Thank you for this.

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

      Hi and no problem Mike!

  • @CykPykMyk
    @CykPykMyk 7 ปีที่แล้ว +1

    man that was awesome, very simple and clear explanation and everything done in windows console! Do you plan to make any series in OpenGL / DirectX?

    • @javidx9
      @javidx9  7 ปีที่แล้ว +1

      Hey thanks Xavery. I probably will look at DirectX next year. I've used both OpenGL and DX quite a bit, and would like to talk about them, the downside is they require a lot of preparation for the viewer in terms of understanding, so I don't know if they'll fit my format - perhaps a "project" series of videos would be required. So maybe!

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

      great to hear that :D

  • @TheWeepingCorpse
    @TheWeepingCorpse 7 ปีที่แล้ว +1

    i've not looked at my code for ages, but i seem to remember the kink is called an inflection point and they normally appear around t =0.25, t=0.5 and t=0.75.

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

      Hi WeepingCorpse, I believe you are right.

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

      javidx9 I've been binge watching your channel. I keep wanting to do something like it myself but haven't plucked up the courage to go on camera lol.

  • @DavstrWrexham
    @DavstrWrexham 7 ปีที่แล้ว +1

    Quick question: Do you think it would be feasible to differentiate the equations again to get the acceleration? The reason for this is so that if you were modelling an aircraft or spacecraft, say, you could get the model to bank over in the turns.

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

      Hi Davstr, of course you can keep differentiating! Might be worth a try once I get 3D in the console finished.

  • @TimothyChapman
    @TimothyChapman ปีที่แล้ว

    Do a tutorial on how to implement NURBS curves.

  • @BrunoPiovan
    @BrunoPiovan 6 ปีที่แล้ว +1

    amazing! thanks for that!

    • @javidx9
      @javidx9  6 ปีที่แล้ว +1

      No problem Bruno, thanks!

  • @sanosanbaby
    @sanosanbaby 2 ปีที่แล้ว

    you might need to make some lookup map for any t for this purpose as splines are calculated once.

  • @lupinedreamexpress
    @lupinedreamexpress 6 ปีที่แล้ว +1

    I really love your 2D implimentations. They helped me learn a lot about interpolation, itself. I think they'd help a lot more if you did a Unity 3D implementation.

    • @javidx9
      @javidx9  6 ปีที่แล้ว +3

      Thanks Lupine, You can easily extend this to 3D, 4D and onwards! :D, the maths is applied independent of the axis, so just add a z component in the same style as x and y.

    • @lupinedreamexpress
      @lupinedreamexpress 6 ปีที่แล้ว

      Very nice! I love how extensible these equations are. Its fascinating.

    • @shoryu7891
      @shoryu7891 2 ปีที่แล้ว

      @@javidx9 Great!! Thiss helpes me a lot!! Thank you so much!!~

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

    Basically just increase the resolution of the spline for speed calculation. I wonder if this is kind of a nyquist thing. Or aliasing, essentially

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

    how do you split a quadratic spline into 2 subsplines please ?

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

    Nice! Now fCurves makes more sense in Blender :D

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

    How would apply this to create a spline of rotations -i.e. quaternions? It would allow smoothly going from one rotation to the next, then the next, and so on.

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

      The spline can exist in as many dimensions as you like, as its axis independent, so just interpolate your coefficients. Granted, with quats the output may need some tweaking to ensure continuity but it may just simply work.

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

      @@javidx9 So I scaled then added each quaternion component (w, x, y, z) with the respective coefficient -as you did in the video. I may have misunderstood your written steps above, since there's no smoothness difference from just looping the rotations through a Slerp. This leads me to hope that maybe one day you'd make a video about it -one can hope (U_U)

  • @d.j.peters
    @d.j.peters 6 ปีที่แล้ว +1

    From file OneLoneCoder_Splines2.cpp
    if t starts in the loop with 0 then newPoint=oldPoint so the t loop must start with fStepSize
    float CalculateSegmentLength(int node, bool bLooped = false) {
    float fLength = 0.0f;
    float fStepSize = 0.005;
    sPoint2D old_point, new_point;
    old_point = GetSplinePoint((float)node, bLooped);
    for (float t = fStepSize; t < 1.0f; t += fStepSize) {
    new_point = GetSplinePoint((float)node + t, bLooped);
    fLength += sqrtf((new_point.x - old_point.x)*(new_point.x - old_point.x)
    + (new_point.y - old_point.y)*(new_point.y - old_point.y));
    old_point = new_point;
    }
    return fLength;
    }
    DJ

    • @javidx9
      @javidx9  6 ปีที่แล้ว

      Thanks DJ, this is a minor, but completely valid optimisation!

  • @TeenNewsLive
    @TeenNewsLive 2 ปีที่แล้ว

    Did you mean to say Euclidean distance at 3:34?