## News:

*NEW* Current Version on STEAM16.793

Webchat:
Visit the chat

## Bezier Curves Library - 2d and 3d, Linear, Quadratic, and Cubic

#### Hemlos

Bezier Curves Library - 2d and 3d, Linear, Quadratic,  and Cubic
Created By Neil Silver(aks Hemlos), November 18,2009
These math functions are documented on Wikipedia:
http://en.wikipedia.org/wiki/B%C3%A9zier_curve

Usage of this math is up to your imagination.
Really, this functionality gives alot of power.
You can merge this array with other structures of math to create some awesome stuff.
These curvatures can be applied to structures in middle of the line, or anywhere on it.
You can do alot, you could create tradjectories, or paths.
You can use these with polyvectors to make dynamic flexing objects.
If done proper, you could apply these to 3d object creations also.
The sky is the limit here, and i wish i had more time to makes more samples, but i dont.

6 function library:
LinearBezier2d
LinearBezier3d
CubicBezier2d
CubicBezier3d

Here is the lib with 3 sample projects:
sample1 draws the 2d curves.
sample2 draws a bezier spline
sample3 is a game player and an AI critter following a path

Bing ChatGpt is pretty smart

#### Kitty Hello

Excellent! I had once need for that but dropped the idea.

#### bigsofty

Yes Beziers have multiple uses, well done Hemlos!
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

#### codegit

Thank you very much. I have played with curves before and this is definitely going into my toolbox.
------------------------------------------
1 X Acer TravelMate 4270, laptop, XP PRO
1 X Dell Studio 17 laptop, Windows 7
1 X MacBook Pro 2,2 GHz Core 2 Duo, 2 GB RAM, 160 GB HDD, 9400M
2 X iTouch
1 X HTC Desire (Android 2.1)

#### Qube

Nice work, thanks for sharing

#### Hemlos

#5
Np,

The complete library with sample is in the first message of this thread.
I think i covered all the curves needed.

Unless anyone can think of a really good use for a higher order curve, im leaving this lib as is.

Edit:
You might be able to create a Bezier-Bones, cpu-based 3d bone system, with this lib.
Goodluck, enjoy.

Bing ChatGpt is pretty smart

#### Hemlos

I updated the library, it has 3 samples now, top of thread.
I included a simple program where a game player follows a path.

Bing ChatGpt is pretty smart

#### bigsofty

Ooh 3D Beziers, nice addition, thanks buddy!
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

#### Hemlos

Quote from: bigsofty on 2009-Nov-23
Ooh 3D Beziers, nice addition, thanks buddy!

Yup, you can create curvy paths or lines in 3d space.

I am going to use the 3d quadratic beziers, for homing missles paths, and radar tracking systems for my helicopter HUD.

Also, i was thinking about a 2d vector font system for GLBasic....this should actually be easy to make fonts with...i dont have the time for this now though.
And if youre crafty enough, you could use the 3d beziers for making 3d fonts too.
Vector fonts, like windows font, can be sized, colored, italics, bold, and even line resolution(number of segments, to change font style automatically).
Bing ChatGpt is pretty smart

#### Ian Price

Hi Hemlos

I came. I saw. I played.

#### Hemlos

Hi Ian,

The link is above the screenshots.

Here is a shortcut to it:

http://www.glbasic.com/forum/index.php?action=dlattach;topic=3839.0;attach=1279
Bing ChatGpt is pretty smart

#### Ian Price

D'oh! I missed it, thinking it was the screenshot link!

Cheers
I came. I saw. I played.

#### Hemlos

Quote from: Ocean on 2010-Feb-19
Hi Hemlos,

excellent work, I only stumbled across it today.  Thanks for posting it.  Did you ever consider other methods of interpolation?   Longer ago than I care to admit I once dabbled with interpolating cubic and quintic splines, would be nice to have those in GLB as well.

cheers
Ocean

What this lib currently contains for 2d and 3d array structures:

Quintic....i assume this is the form with 2 ends and 3 handles?
Do you need quintic?

I was going to add this, but thought to myself, 'Who in the world would use this?'.
Using quintic only seems to me, to be a daunting task, applying it to something useful.

Please explain to me, what do you mean by 'other methods of interpolation'

Bing ChatGpt is pretty smart

#### Hemlos

Interpolating can be done by scanning the array.
This library only contains beziers 2d and 3d array structures, for orders of these degrees:
1st 2nd 3rd (linear, quadratic, cubic, respectively)

Im currently trying to create orders of 4th(quartic) and possibly a 5th(named?) degree.
No guarantees...first test run has not been so good...as im missing something in my formula.
Bing ChatGpt is pretty smart

#### Hemlos

Knots, handles, control points, are NOT part of the curves.
For 3D animation BÃƒÂ©zier curves are often used to define 3D paths as well as 2D curves for keyframe interpolation.
Linear BÃƒÂ©zier curves are equivalent to linear interpolation.
Etc etc..

There are many resources on the internet explaining in great detail how bezier interpolation works.
For further in-depth, examination of this formula set, refer to this link:
http://en.wikipedia.org/wiki/B%C3%A9zier_curve
Bing ChatGpt is pretty smart