Bookshelf icon indicating copy to clipboard operation
Bookshelf copied to clipboard

Various Bezier functions (both 3 point and 4 point, provided examples are for 4 point specifically)

Open fan-of123 opened this issue 1 year ago • 4 comments

Bezier curves are rather underused within minecraft mapmaking and there's precious little library support for them. Despite this, they're really useful for many things including visual effects, camera paths, curved projectile arcs, and more.

Main function ideas I had were:

  • Given a start, end, two points, and a t value, find a point along a curve or the derivative at that point.
  • Given a start, end, and two points, approximate the length of a curve.
  • Given a start, end, two points for the curve to pass through and the t values at those points, calculate the control points of a curve (math for this is pretty big so having the t values be hardest to like .333/.666 or .25/.75 would simplify it a lot).
  • Given the start, end, two controls, and an amount of iterations, calculate velocity, acceleration, and jerk values to use for iterating along a curve cheaply (useful for making things like projectiles that follow set arcs but with a guaranteed target).

fan-of123 avatar Aug 12 '24 18:08 fan-of123

Thanks for your proposition! Can you give some uses you see for Minecraft?

theogiraudet avatar Aug 12 '24 18:08 theogiraudet

I'm not the most creative person, the big use I see is mostly in just making cool VFX. If you want examples, here's two effects ive done using them: https://youtu.be/ykD7muPQkD0 (4 point and 3 point beziers, respectively). I also have this clip from awhile ago that uses them for lightning: https://youtu.be/6YeJW4Yh3JI

Aside from that I can see niche uses for, as mentioned above, projectile attacks and such (most of my datapack experience is in boss/enemy/weapon design). That and camera paths, but you guys seem to already be working on a module for that.

Really, the main use is just: making cool looking things. If that's not enough of a reason to add something to your lib, then that's totally ok, just wanted to put the idea out there.

fan-of123 avatar Aug 12 '24 19:08 fan-of123

Thank you very much! We will see if we have time to implement that after your current tasks. If someone else is interested in implementing this system, do not hesitate to say it here!

theogiraudet avatar Aug 12 '24 19:08 theogiraudet

I think we should move this to a separate module, since we'll need other type of splines for the camera module. Maybe a module interpolate?

aksiome avatar Aug 14 '24 12:08 aksiome

To start the module i propose to only have evaluation functions for the following splines (bezier, bspline, catmull rom, and hermite). I think derivative could be nice to have then, Not sure we need acceleration and jolt and i'm not sure it's that useful to compute control points directly inside minecraft. Then we could implement functions to compute arclen and to walk a curve with constant speed but this is pretty heavy to do

aksiome avatar Jan 24 '25 20:01 aksiome