Main Menu

Bezier Curves

Started by kevin, November 21, 2023, 07:50:34 PM

Previous topic - Next topic

kevin


Bezier Curves by ScottyBro



PlayBASIC Code: [Select]
; PROJECT : Bezier Curves
; AUTHOR : Scott_Bro_1
; CREATED : 7/7/2022
; EDITED : 7/7/2022
; ---------------------------------------------------------------------

X1 = 0
Y1 = 600

X2 = 800
Y2 = 300

X3 = 0
Y3 = 0

X4 = 400
Y4 = 600

Line X1,Y1,X2,Y2
Line X2,Y2,X3,Y3
Line X3,Y3,X4,Y4

Ink RGB(255,0,0)

For T# = 0 To 1 Step 0.001

//P = (1-t)P1 + tP2
//P = (1-t)2P1 + 2(1-t)tP2 + t2P3
//P = (1-t)3P1 + 3(1-t)2tP2 +3(1-t)t2P3 + t3P4

// Three control points
//X = (1 - T#)^2 * X1 + 2*(1 - T#)*T# * X2 + T#^2 * X3
//Y = (1 - T#)^2 * Y1 + 2*(1 - T#)*T# * Y2 + T#^2 * Y3

// Four control points
X = (1 - T#)^3 * X1 + 3*(1 - T#)^2*T# * X2 + 3*(1 - T#)*T#^2 * X3 + T#^3 * X4
Y = (1 - T#)^3 * Y1 + 3*(1 - T#)^2*T# * Y2 + 3*(1 - T#)*T#^2 * Y3 + T#^3 * Y4

Dot X,Y

Next T#

Sync

Waitkey

End