lerp^n?

This forum is currently in read-only mode.
  • Just a thought, don't even know if its doable, but how about an expression that does linear interpolation with a user definable set of points. For example lerp^n(a,b,c,d,e,f......,x), or lerp^5(1,2,3,4,5,0.7). The latter would give an interpolation across the numbers 1 through 5 at 70 %.

    Similar to quarp, and cubic, but your not limited to the 3 or 4 inputs.

    Yes, no, or huh?

  • One would call this a spline; a path which consists of many lerped or quarped curves. (In theory, it would be possible to use higher order bezier curves, but this takes more computing power than splines, and the control points don't effect the curve so easily.) It would be nice feature to have, but I think it could be bundled into path behavior, it has the same kind of functionality.

  • after cubic, i think u'r wasting computing power

    you can create any shape by combining cubics

  • if you want corner less smoothly transitioning curved lines, you can combine quadratics, or cubics, but you must make sure that the handles (point 2 and 3 in a cubic, point 2 in a quadratic) have opposite angles from their follow up in the next bezier set. so lets say we had 8 points which were joined into a line (you could even do a closed shape if you wanted) using 2 cubic beziers. points 1-4 were a set, and point 5-8 were another set. the angle that point 3 was relative to point 4 would need to be the opposite (simply +180 to the value) for point 6 relative to point 5, also obviously points 4 and 5 would need to share the same position so make a seamless curve. a picture would better explain things so...

    <img src="http://dl.getdropbox.com/u/1010927/spline%20tut.png">

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The question is how big a draw would something like this be, vs doing a chain of expressions?

    I mean Im imagining that each additional point added to the proposed would at to computation exponentially, so obviously there has to be a drop off point. You couldn't do something like lerp^100(1,2,3,4,5....

    Then if you were to use several lerps or quads how bad would the transition between them be?

    Because from the layman's point of view conjoining expressions like this would be somewhat contrived, and there's bound to be some skipage between expressions.

    Drasa yeah spline would be a better name.

    Perhaps a spline, or path object might be better, but if it were implemented I would want the ability to use the defined points with other calls as well, no point in just making a static curve.

  • i can say that certainly my way of doing it would be alot less of a draw for something with 20 points than you're method, and controlling higher order bezier curves gets counter intuitive. theres no plain and simple way to make large amounts of point into a smooth curved line.

    using my method the transition between them would be perfect, as long as youre drawing events did 0.0-1.0 for the t value of the beziers, and the points were all on integer positions (round(x),round(y)).

    when drawing a bezier as a full line (im assuming youre not simply wanting to get a points position based on an expression, but rather drawing a line like in my picture), u need to use loops, and for it to be smooth u need to use a large amount of loops. for a 20 point spline, made of cubics, running a loop 100 times to draw each of the 5 cubic beziers which make up the 20 point spline, youd need to run a cubic expression a total of 500 times, (1000 if you count that youre doing it for x and y, and 2000 if you count that youre doing it for x and y, and drawing a line from the point drawn before to the current one). if you were using a single bezier of 20 points, youd need to run an expression that would probably be too long to even list in the length of this entire thread, 2000 times.

    it takes alot of power to do this stuff. e.g. truetype font was chosen over type 1 simply because it used quarp to define curves instead of cubic.

    i understand you feel adding lerp^n would be a good idea, but when you actually look at different order beziers in plain algebra instead of 5 letter things you can easily write, you realize how much more expensive and complicated they get from one iteration to the next.

    lerp is simply " a+(b-a)*t "

    qarp is " ((a+(b-a)*t)+((b+(c-b)*t)-(a+(b-a)*t))*t) "

    cubic is " ((a+(b-a)*t)+((b+(c-b)*t)-(a+(b-a)*t))*t)+(((b+(c-b)*t)+((c+(d-c)*t)-(b+(c-b)*t))*t)-((a+(b-a)*t)+((b+(c-b)*t)-(a+(b-a)*t))*t))*t "

    and so forth.

    a generalization is every bezier is made up of the bezier type before it for each of the n points as the 3 values inside of a lerp.

    qarp is really just lerp(smaller)+(lerp(bigger)-lerp(smaller))*t

    cubic is really just qarp(smaller)+(qarp(bigger)-qarp(smaller))*t

    they grow fractally is the best way i find to describe it larger parts made of smaller parts repeating until made up to their simplest form.

    for a n point curve things would get really, really long. qarp, a 4 point curve is all ready pretty big, 5 would be 3 times as big, 6, 9 times and so forth for 3^n or wtv.

  • *Walks in... reads thread.... walks out*

    ~Sol

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