How do I distribute equall space in bezier curve?

0 favourites
From the Asset Store
Spaces Ambience contains 102 Sounds: 53 track and 49 sounds
  • i create bezier curve using cubic() expression. now i want equall/predefined spce in this curve. before posting this question i did google there are many results but all of those are in programming which is difficult to understand. can anybody explain me how can i do this?

    a simple idea is to first calculate total width of the curve then divide with number of steps or segments whatever we say, this is avg. for all those steps or if i predefined space i.e 20px on each then i have to increase steps as there will be shortage of steps on predefined space.

    any idea how to do this?

    Tagged:

  • a simple idea is to first calculate total width of the curve then divide with number of steps or segments whatever we say, this is avg. for all those steps or if i predefined space i.e 20px on each then i have to increase steps as there will be shortage of steps on predefined space.

    You can have infinite points, but a quick way is to get the distance of the line, and divide that by a certain amount that will make up the segments of that curve.

    The divisor is what you would call the resolution. How smooth it is.

    You can use log or ^ if you think you will need to scale a lot.

  • I have 5 segments and I got distance of the each segment that it (513.79, 243.38, 59.49, 129.07, 213.84) adding all these and dividing with 5 I have 231.92. This will be the distance of each segment but now my question is how to reposition all those segments.

  • You can run a loop and create your lines using tiled bg objects setting their positions, angles, a length using cubic.

    One line/ segment after the other.

    pigmalien.github.io/cubic

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • pigmalien.github.io/cubic

    this example also doesn't have an equal distribution

  • R0J0hound will probably have the correct answer for you.

    My dumb idea is first to calculate the total curve length and segment length. Then run the loop again for the same curve, calculating distance from the starting point along the way. Once the distance exceeds segment length, draw a dot and reset the distance counter.

  • I have got a solution link. I have read that many many times but it is complex for me.

  • Yep its a lerp with dots instead of segments.(note the ease in and out)

    I use distance() as an approximation since drawing pixels for every point along a curve is not performant, and connected segments are.

    Its not great for extreme curves, you could add the distance between the endpoints, and control points, but ehh.

  • yes, R0J0hound will probably have the solution. He is legend and he has solutions for almost every problem.

  • Eh, my ideas aren’t always the smartest or simplest. There are pros and cons to most solutions.

    Anyways, I’d say dop2000’s idea is the best way to do it. The more mathy solutions look tedious to implement.

  • If you've made objects along the curve, iterate the instances add up the distances.

    repeat sprite count times distance(sprite(loopindex).x,sprite(loopindex).y,sprite(loopindex+1).x,sprite(loopindex+1).y)

    Divide.

  • Here is my version:

    https://www.dropbox.com/s/voli93iwitpz9mn/cubic_curve_demo.c3p?dl=0

    the result is similar to what I have done.

    my file

  • Not sure what you mean. My demo does exactly what you want:

  • oh! my mistake I downloaded your file but mistakenly opened a wrong file (someone else's) with similar name.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)