Bezier Curves

by Mightymo
Use Bezier curves in your games. [More]
To download this library for your Linux/Mac installation, enter this on your command line:

DreamDownload byond://Mightymo.BezierCurves##version=7

Emulator users, in the BYOND pager go to File | Open Location and enter this URL:

byond://Mightymo.BezierCurves##version=7

121 downloads
Version 1.2.1
Date added: Jan 21 2015
Last updated: Jan 29 2015
4 fans
When you need things to curve in your game, from projectile paths to tracing, Bezier curves are often a god fit. This library provides everything you need to create and manipulate Bezier curves, as well as providing various information about the curve.

Comments

Mightymo: (Feb 13 2015, 2:48 pm)
My plan is to change the system to use forward differencing. While this does force the curve to use discreet intervals, it allows the entire curve to be calculated using only addition after calculating several values. I believe that this will be considerably faster than my current method or even its simplification. Regardless, I do plan to make efficiency changes, although I've been a bit too busy to do so recently.
Lummox JR: (Feb 13 2015, 9:29 am)
I would recommend some modifications to the lib, if you haven't considered them already.

The short of it is that you can precalculate a lot of coefficients that you're re-calculating on each iteration, including with three calls to a factorial proc which is probably the least efficient way to go. A number of multiplication and division operations can also be simplified out.
FKI: (Jan 28 2015, 5:30 am)
Nifty and easy to use. Fanned and thanks for sharing.
Mightymo: (Jan 26 2015, 3:37 pm)
I'm not entirely certain what you mean by angle. Do you mean at the critical points of the curve? Or the angle between curves of a path? Something else entirely?

Also, it is important to note that mathematically speaking, there are a lot of curves that Bezier curves cannot match, only approximate (like circles).
Mightymo: (Jan 24 2015, 9:15 am)
Increment by whatever percentage fits your needs.
for(i=0; i <= 1; i += 0.01) // 1% each loop. This is arbitrary, of course.
coords=path.getPoint(i)