Question N°4 de Giovanni
Macajone du 6/9/1 à 21h 52 :
Je recherche un cours (ou un article) pour débutant sur les B-Spline.
Si quelqu'un peut me fournir des renseignements, je l'en remercie d'avance.
Question N°3 de Laurent :
Bonjour, j'ai trouvé le lien de votre site par un moteur de recherche. Vous est-il
possible de m'indiquer de quelle façon je peux obtenir un contrôle de la position des
points sur une courbe B-spline ?
J'ai constaté que plus la courbe est serrée plus les points sont côte à côte. Dans le
programme suivant j'ai un controle sur les 4 points en (x,y).
Un rectangle est dessiné pour chaque point calculé de cette courbe et ainsi visualiser
la courbe à l'écran.
Est-ce qu'il exite une solution pour controler la position des points calculés ? :
- obtenir une distance égale entre chaque point.
- controler la distance entre chaque point.
- obtenir une distance croissante du 1er au dernier point de la courbe et
inversement.
- obtenir plus de 4 points pour controler la courbe.
J'espère que vous pourrez m'aider(attention je ne suis pas un "pro" des maths)
salutations
Laurent (83000 Toulon) e-mail : atelier3w@hotmail.com
Programme :
;Bezier curve
Const ScrnW=1280, ScrnH=1024
Graphics ScrnW,ScrnH
Dim x(3), y(3)
Global tsteps
;load initial data
For i=0 To 3
Read x(i),y(i)
Next
edge =True
Data 20,500
Data 100,200
Data 580,300
Data 750,50
SetBuffer BackBuffer()
;p == index of active point
Repeat
;process keyboard
If KeyDown(1) Then done =True
;spacebar next point
If KeyDown(57) Then
p=p+1
If p=4 Then p=0
Delay 150 ;give user time to relase key
FlushKeys ;
EndIf
;number key, change point
If KeyDown(2) Then p=1
If KeyDown(3) Then p=2
If KeyDown(4) Then p=3
If KeyDown(11) Then p=0
If KeyDown(79) Then p=1
If KeyDown(80) Then p=2
If KeyDown(81) Then p=3
If KeyDown(82) Then p=0
If KeyDown(59) Then edge =Not edge :Delay 150
;arrow keys move point
If KeyDown(200) Then y(p)=y(p)-1
If KeyDown(208) Then y(p)=y(p)+1
If KeyDown(203) Then x(p)=x(p)-1
If KeyDown(205) Then x(p)=x(p)+1
;update bezier coefficents
cx=3*(x(1)-x(0))
bx=3*(x(2)-x(1))-cX
aX=X(3)-X(0)-cX-bX
cy=3*(y(1)-y(0))
by=3*(y(2)-y(1))-cy
aY=y(3)-y(0)-cy-by
;number of points to draw on bezier curve
tsteps=50
ysteps=50
Cls
;draw a curve
Color 255,0,0
For t#=0 To tsteps
tt#=t#/tsteps
xt=aX*(tt#)^3+bX*(tt#)^2+cX*(tt#)+x(0) ;
xt=aX*(tt#)^3+bX*(tt#)^2+cX*(tt#)+x(0)
yt=aY*(tt#)^3+bY*(tt#)^2+cY*(tt#)+Y(0) ;
yt=aY*(tt#)^3+bY*(tt#)^2+cY*(tt#)+Y(0)
Rect xt-2,yt-2,5,5
Next
;draw control points
Color 0,0,255
For i=0 To 3
Rect x(i),y(i),4,4
Next
;highlight current point
Rect 10,20+20*p,120,19
Color 255,255,255
;mark active point
Oval x(p)-2,y(p)-2,8,8,-1
;update point info
For i=0 To 3
Text 10,20+I*20,Str$(i)+" "+Str$(x(i))+" "+Str$(y(i))
Next
Text 10,100, "Steps: "+Str$(tsteps)
tx=580
Text tx,500, "Space: next point"
Text tx,520, "Arrow keys: move point"
Text tx,540, "F1: toggle edge"
Text tx,560, "0-3 select control point
Text tx,580, "Esc: quit"
Text tx,600, "cx "+cx
Text tx,615, "bx "+bx
Text tx,630, "ax "+ax
Text tx,645, "cy "+cy
Text tx,660, "by "+by
Text tx,675, "ay "+ay
Flip
Until done
End
|