coordenadas polares en un picture box
Publicado por CRISTIAN (1 intervención) el 30/01/2009 21:40:44
hola a todos porfa necesita ayuda en un programa que me grafique un par de coordenadas polares en un picture boxs. Ya tengo la mayor parte del programa pero no me grafica nada. Talvez alguien que me ayude porfa de urgencia que es para una nota.
Aqui les agrego la codificacion que tengo. No se si alguien tenga otra idea o el programa ya implementado porfavor ayudenme
Dim Q As Single, H As Single
Dim a As Double, k As Double
Dim T As Double, pi As Double
Private Sub Command1_Click()
If 0 < a And a <= 10 Then
If 1 < k And k <= 100 Then
Picture1.DrawStyle = 4
Picture1.Scale (-Q / 4500, H / 4500)-(Q / 4500, -H / 4500)
For I = 0 To a + 3 Step 1 / a
Picture1.Circle (0, 0), I
Next I
Picture1.Line (H / 2, 0)-(-H / 2, 0)
Picture1.Line (0, H / 2)-(0, -H / 2)
Picture1.Line (Q / 2, (Q * Sqr(3)) / 6)-(-Q / 2, -(Q * Sqr(3)) / 6)
Picture1.Line (-Q / 2, (Q * Sqr(3)) / 6)-(Q / 2, -(Q * Sqr(3)) / 6)
Picture1.Line ((Q * Sqr(3) / 6), H / 2)-(-(Q * Sqr(3) / 6), -H / 2)
Picture1.Line (-(Q * Sqr(3) / 6), H / 2)-((Q * Sqr(3) / 6), -H / 2)
Else
MsgBox ("Valor del parametro k no válido (k entre 1 y 100)")
End If
Else
MsgBox ("Valor del parametro a no válido (a entre 1 y 10)")
End If
End Sub
Private Sub Command2_Click()
SavePicture Picture1.Image, "C:Funciones.bmp"
End Sub
Private Sub Command3_Click()
Picture1.Cls
Text1.Text = " "
Text2.Text = " "
Text3.Text = " "
Text4.Text = " "
End Sub
Private Sub Form_Load()
Form1.Left = (Screen.Width - Form1.Width) / 2
Form1.Top = (Screen.Height - Form1.Height) / 2
Q = Picture1.Width
H = Picture1.Height
a = Val(Text3.Text)
k = Val(Text4.Text)
End Sub
Private Sub Text3_Change()
a = Val(Text3.Text)
End Sub
Private Sub Text4_Change()
k = Val(Text4.Text)
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.Scale (-Q / 2, H / 2)-(Q / 2, -H / 2)
pi = 4 * Atn(1)
R = Sqr(X ^ 2 + Y ^ 2) / 2250
If X > 0 And Y >= 0 Then
T = (Atn(Y / X) * 180 / pi)
End If
If X > 0 And Y < 0 Then
T = Atn(Y / X) * 180 / pi + 360
End If
If X < 0 Then
T = Atn(Y / X) * 180 / pi + 180
End If
If X = 0 And Y > 0 Then
T = 180 / 2
End If
If X = 0 And Y < 0 Then
T = 3 * 90
End If
Rt = a * R
Text1.Text = Format(Rt, "0.#")
Text2.Text = Format(T, "0.#")
End Sub
Aqui les agrego la codificacion que tengo. No se si alguien tenga otra idea o el programa ya implementado porfavor ayudenme
Dim Q As Single, H As Single
Dim a As Double, k As Double
Dim T As Double, pi As Double
Private Sub Command1_Click()
If 0 < a And a <= 10 Then
If 1 < k And k <= 100 Then
Picture1.DrawStyle = 4
Picture1.Scale (-Q / 4500, H / 4500)-(Q / 4500, -H / 4500)
For I = 0 To a + 3 Step 1 / a
Picture1.Circle (0, 0), I
Next I
Picture1.Line (H / 2, 0)-(-H / 2, 0)
Picture1.Line (0, H / 2)-(0, -H / 2)
Picture1.Line (Q / 2, (Q * Sqr(3)) / 6)-(-Q / 2, -(Q * Sqr(3)) / 6)
Picture1.Line (-Q / 2, (Q * Sqr(3)) / 6)-(Q / 2, -(Q * Sqr(3)) / 6)
Picture1.Line ((Q * Sqr(3) / 6), H / 2)-(-(Q * Sqr(3) / 6), -H / 2)
Picture1.Line (-(Q * Sqr(3) / 6), H / 2)-((Q * Sqr(3) / 6), -H / 2)
Else
MsgBox ("Valor del parametro k no válido (k entre 1 y 100)")
End If
Else
MsgBox ("Valor del parametro a no válido (a entre 1 y 10)")
End If
End Sub
Private Sub Command2_Click()
SavePicture Picture1.Image, "C:Funciones.bmp"
End Sub
Private Sub Command3_Click()
Picture1.Cls
Text1.Text = " "
Text2.Text = " "
Text3.Text = " "
Text4.Text = " "
End Sub
Private Sub Form_Load()
Form1.Left = (Screen.Width - Form1.Width) / 2
Form1.Top = (Screen.Height - Form1.Height) / 2
Q = Picture1.Width
H = Picture1.Height
a = Val(Text3.Text)
k = Val(Text4.Text)
End Sub
Private Sub Text3_Change()
a = Val(Text3.Text)
End Sub
Private Sub Text4_Change()
k = Val(Text4.Text)
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.Scale (-Q / 2, H / 2)-(Q / 2, -H / 2)
pi = 4 * Atn(1)
R = Sqr(X ^ 2 + Y ^ 2) / 2250
If X > 0 And Y >= 0 Then
T = (Atn(Y / X) * 180 / pi)
End If
If X > 0 And Y < 0 Then
T = Atn(Y / X) * 180 / pi + 360
End If
If X < 0 Then
T = Atn(Y / X) * 180 / pi + 180
End If
If X = 0 And Y > 0 Then
T = 180 / 2
End If
If X = 0 And Y < 0 Then
T = 3 * 90
End If
Rt = a * R
Text1.Text = Format(Rt, "0.#")
Text2.Text = Format(T, "0.#")
End Sub
Valora esta pregunta


0