Rotation d'une ellipse

bouchiki Messages postés 4 Date d'inscription vendredi 10 décembre 2004 Statut Membre Dernière intervention 24 juillet 2005 - 29 mai 2005 à 12:50
Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 - 29 mai 2005 à 20:16
salut, je n'arrive pas a faire pivoter une ellipse qui est dessiner dans le code par circle(x,y),r....ect

2 réponses

cs_MasterHack Messages postés 586 Date d'inscription jeudi 18 septembre 2003 Statut Membre Dernière intervention 13 février 2008 2
29 mai 2005 à 18:12
je te conseil d'utliser le cos() et le sin() c mieux pour creer un ellipse


<HR>

Life is short...Learn more
Copy Rights <> Rights to Copy
0
Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
29 mai 2005 à 20:16
Rotation d'une ellipse de 15° avec les axes.



ne me demande pas d'expliquer !





Option Explicit



Const GM_ADVANCED As Long = 2



Private Type XForm

eM11 As Single

eM12 As Single

eM21 As Single

eM22 As Single

eDx As Single

eDy As Single

End Type



Private Type RectAPI

Left As Long

Top As Long

Right As Long

Bottom As Long

End Type



Private Type PointAPI

X As Long

Y As Long

End Type



Private Declare Function SetViewportOrgEx Lib "gdi32" (ByVal hDC As
Long, ByVal nX As Long, ByVal nY As Long, lpPoint As PointAPI) As Long

Private Declare Function SetGraphicsMode Lib "GDI32.dll" (ByVal hDC As Long, ByVal iMode As Long) As Long

Private Declare Function GetWorldTransform Lib "GDI32.dll" (ByVal hDC As Long, ByRef lpXform As XForm) As Long

Private Declare Function SetWorldTransform Lib "GDI32.dll" (ByVal hDC As Long, ByRef lpXform As XForm) As Long

Private Declare Function GetClientRect Lib "User32.dll" (ByVal hWnd As Long, ByRef lpRect As RectAPI) As Long



Private Sub Command1_Click()

Const Pi As Single = 3.14159

Const RotAng As Single = 15

Const RotRad As Single = (RotAng / 180) * Pi

Dim WndArea As RectAPI

Dim OldOrg As PointAPI

Dim OldMode As Long

Dim OldXForm As XForm

Dim MyXForm As XForm



MyXForm.eM11 = Cos(RotRad)

MyXForm.eM12 = Sin(RotRad)

MyXForm.eM21 = -MyXForm.eM12

MyXForm.eM22 = MyXForm.eM11



' Get window size

Call GetClientRect(Me.hWnd, WndArea)



' Set view-port origin to centre of window

Call SetViewportOrgEx(Me.hDC, WndArea.Right \ 2, WndArea.Bottom \ 2, OldOrg)



' Set graphics mode to advanced mode to use world transformation

OldMode = SetGraphicsMode(Me.hDC, GM_ADVANCED)



' Get current transformation matrix

Call GetWorldTransform(Me.hDC, OldXForm)



' Apply new transformation matrix

Call SetWorldTransform(Me.hDC, MyXForm)



' Draw ellipse

Me.Line (-1500, 0)-(1500, 0), vbBlue

Me.Line (0, -750)-(0, 750), vbBlue

Me.Circle (0, 0), 1500, vbRed, , , 0.5



End Sub




Daniel
0
Rejoignez-nous