Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drawing with VB 1

Status
Not open for further replies.

alehawk

Programmer
Jun 18, 2003
332
AR
Hi!
I need to do a little drawing with VB...
I got 3 numbers, 12 degrees, 45 minutes, 35 seconds.
I need to draw a circle and in the position 12deg45'35" I need to place an X over the circle.
Does anyone knows how can I do that???? :S

Tnx!!!
 
I assume want to draw the angle CCW from the x-axis with the point to the right of the center of the circle.
Place a button on a form, set autoredraw=true, and scalemode=pixels.
Note that 45' is 45/60 of a degree
and 35" is 35/3600 of a degree.

Option Explicit

Private Sub Command1_Click()
Dim Angle As Single, Arad As Single
Dim Adj As Single, Opp As Single, Hyp As Single
Dim x As Long, y As Long

Angle = 12# + 45# / 60# + 35# / 3600#
Arad = Angle * 3.14159 / 180 ' Angle in radians = Angle * PI/180

' Tan(Arad)= Opp/Adj
Adj = 100 ' arbitrary length of the base of the triangle
Opp = Tan(Arad) * Adj ' height of the triangle

x = 300: y = 200 ' center of the circle

Form1.Line (x, y)-(x + Adj, y) 'draw base of the triangle
Form1.Line (x + Adj, y)-(x + Adj, y - Opp) ' draw opposite side of triangle

Hyp = Sqr(Adj * Adj + Opp * Opp) ' compute radius of circle

Form1.Circle (x, y), Hyp

' Then draw the X

End Sub
 
Tnx gperk, I didnt express my Idea correctly.
What I need to draw is on that position, over the circle, in Deg, Mins and Secs the character X.
Tnx!
 
The 0 Deg is in de middle top of the circle.

I mean:

+--- 0 Deg
000
00 00
00 00
000
 
The following should work by calculating the offsets.

Private Sub Command1_Click()
Dim Angle As Single, Arad As Single
Dim circrad As Single
Dim x As Long, y As Long
Dim PI

PI = (4 * Atn(1))
circrad = 2000 'set radius
Angle = 12 + (45 / 60) + (35 / 3600)
Arad = Angle * PI / 180 ' convert to rads
x = 3000: y = 3000 ' set center of circle
Circle (x, y), circrad ' draw circle
CurrentX = x + Sin(Arad) * circrad 'calc x offset
CurrentY = y - Cos(Arad) * circrad - 80 ' calc y offset & print offset
Print "x"
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top