Archive: Bezier curve


4th September 2003 16:27 UTC

Bezier curve
Lately I lack of creativity but i have trying to do more math in avs... so I got bored as hell and did some curve ssc's.
This is my best one so far:
Bezier curve with 10 control points, its not hard to add more control points but we got one "lovely" thing called varjable limit :(

Anyways... its not some kind of nice-looking-preset, it is basicly a ssc... but i goes REALLY well with heavy beat ;)
It is not very optimized, but doing it is a big pain in the ass... even when dealing with 4 control point curve :(

If anyone want to know how the Bezier curve works just say it... I will try to do tutorial

So here it is, enjoy :D


4th September 2003 17:51 UTC

That's nice, but it's not the most interesting thing. It does do well on heavy beats(I was listening to godsmack at the time). The only thing I can think of to make it more interesting would be to do it in 3 Dimensions. Oh, and don't display the control points with your final version - it doesn't look that great.


4th September 2003 17:58 UTC

Make 3d... I think it will be impossible coz i need 60 varjables... for only point movement (beat and per frame)
Ofcource i will delete the control points on final version


4th September 2003 18:08 UTC

You can cut down on the variables used. For example - don't store x0, y0, etc. Just use sin(a), cos(a), etc. It makes it slower, but that could end up being better.


4th September 2003 18:15 UTC

i still think its impossible... i allready got 46 varjable on 2d version... another way could be using less control points... 7 control point one shoul allready be possible, i hope


5th September 2003 01:46 UTC

hmm nice... maybe you can make a plasma ball (3d)?


5th September 2003 03:40 UTC

I think it would be possible to make it 3-D, you just have to use some creative ways to store variables. It would be almost impossible though, it would take a little bit of work, nice job on the 2-d version though


5th September 2003 03:53 UTC

I would do it(3D), but I don't feel like figuring out how bezier curves work right now. They aren't that difficult from what I gather about them, but bleh. Right now, it's just not interesting enough - adding another dimension would help, but it would still be lacking some I think.


5th September 2003 05:16 UTC

Originally posted by 3dino
hmm nice... maybe you can make a plasma ball (3d)?
Yay1 this is good idea, and isnt THAT hard... maybe just slow, ill start working on it when i got some spare time (you know, school :hang: )

[edit]I havent figured out yet how to make continious curve, that may make things uglier[/edit]

5th September 2003 14:02 UTC

Rather than using such large amounts of control points, you should stick to cubic beziers (i.e. 4 control points). More than 4 doesn't really add much extra flexibility.
By piecing many cubic beziers together, you can create nice, varied, smooth curves.

For C1 continuity, make sure that the control points line up at the switch from one bezier to another. I.e.

Suppose you have control points:

1 2 3 4 5 6 7

Then you can create two cubic beziers, namely 1-2-3-4 and 4-5-6-7. For C1 continuity (smooth curve), you need to make sure that points 3-4-5 lie on one line. For continuous curvature, you need to make sure that the distance 3-4 is the same as 4-5.
To combine these two, you can just 'mirror' point 3 around point 4 to get point 5 (this saves you some variables btw):

Add the coordinate difference from 3 to 4 to the coordinate of 4 to get the coordinate of 5:

x5 = x4 + (x4 - x3) = 2*x4 - x3
y5 = y4 + (y4 - y3) = 2*y4 - y3

That's how I made my avatar... I create one cubic bezier 1-2-3-4, and then connect the ends with another cubic bezier 4-5-6-7 that is completely defined by the first bezier (p7 = p1, p6 = p2 mirrored around p1, p5 = p3 mirrored around p4, p4 = p4).

A forum search for bezier or bézier should turn up some stuff.

Oh and if you need to evaluate polynomials, it's usually best to write everything grouped by coefficient of 'x' or 't' or whatever, and then do:

ax^3 + bx^2 + cx + d
= ((a*x + b)*x + c)*x + d
(Horner's scheme)
Much faster and less multiplications required.


5th September 2003 14:45 UTC

That's what you'd think, but what about stack operations? Less brackets is faster too.


5th September 2003 18:43 UTC

Thanks UCD


6th September 2003 13:10 UTC

Hmmm.. I could swear I told you that (string cubics together) on mirc Jaak.


6th September 2003 18:02 UTC

Yea i know you did, but i didnt understand how to do it... :S

Anyways I understand now... :D
Here's proof.

http://acko.net/dump/jaak/1.zip


6th September 2003 18:20 UTC

The starting/ending point isn't smooth though. It should be able to move around the screen as well.

Presets getting better, though.


6th September 2003 18:43 UTC

Zevensoft: you may be right about that, but AVS does a jump for every possible operation, so less brackets doesn't really matter.

e.g. C=A*B

jump into multiplication routine
jump into routine to load A, return
jump into routine to load B, return
multiply, return
jump into routine to save into C, return

So while there would be more jumps due to brackets, there'd be less multiplications. For a quadratic or cubic, this might be disadvantageous, but for quintics or higher I'm pretty sure horner's scheme still has the advantage, even on AVS.


6th September 2003 21:32 UTC

Anubis: they arent smooth if three points get too close together... this is all done right... but... if anybody finds good way making the starting/ending points smooth then let me know ;)