Piloter un point le long d'une courbe

labriji Messages postés 10 Date d'inscription lundi 2 juin 2003 Statut Membre Dernière intervention 20 mars 2008 - 28 janv. 2005 à 15:45
Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 - 28 janv. 2005 à 23:00
comment faire piloter un point M à l'aide de la sourie par exemple le long d'un
cercle trigonometique en donnant le sinus et le cosinus

merci infiniment

1 réponse

Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
28 janv. 2005 à 23:00
3 controles à ajouter: SHAPE1 , SHAPE2 et LINE1

Option Explicit

Dim bb As Boolean
Dim R As Long
Dim X0 As Long
Dim Y0 As Long

Private Sub Form_Load()
R = 100
X0 = 250
Y0 = 200
Shape1.BackColor = vbRed
Shape1.Move 200, 50, 11, 11
Shape2.Shape = 3
Shape2.Move X0 - R, Y0 - R, R * 2, R * 2
Line1.X1 = X0
Line1.Y1 = Y0
End Sub

Private Sub Intersection()
Dim X As Double
Dim Y As Double
Dim Zx As Double
Dim Zy As Double
Dim Lx As Long

Zx = Line1.X2 - Line1.X1
Zy = Line1.Y2 - Line1.Y1
Lx = Sqr(Zy * Zy + Zx * Zx)

X = X0 + (Zx * R) / Lx
Y = Y0 + (Zy * R) / Lx
Shape1.Visible = True
Shape1.Top = Y - 5
Shape1.Left = X - 5
End Sub


Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
bb = True
End Sub


Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If bb = True Then
If Button = 1 Then Line1.X2 X: Line1.Y2 Y
Call Intersection
End If
End If
End Sub


Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
bb = False
End Sub

Daniel
0
Rejoignez-nous