Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

How to get the Visual Representation of Angle into Radian or Degree

Author: DevASP
Download Source Code : 430_Angle.zip

This article is about how you can visually see an angle in radians or degrees. This means by giving the value of angle, you will get the value either in radians or degrees and its visual representation.

  • Steps you will do. 
  • Start visual studio and create a new window application. 
  • Drop a picture box control on the form and set its following properties. 

Name = “pbCircle”

BackColor = ”White”

Image = “browse and give a round circle image if you have any.”

  • Now drop a text field and set its following properties. 

Name = “txtMeasure”

Text = “0”

  • Now drop a button control on the form and set its following properties. 

Name = “btnDrawline”

Text = “Graph”

 

  • Now drop two radio buttons on the form and set their following properties as below:

 

First radio button.

 

Name = “radRadian”

Checked = “True”

Text = “Radian”

 

Second radio button.

 

Name = “radDegree”

Text = “Degree”

 

  • Finally drop a timer control in designer. Open your code window and write following code in the click event of the button.

 

Dim myPen As New Pen(Color.Black), cenX As Integer, cenY As Integer, endX As Integer, endY As Integer    

Dim myPen2 As New Pen(Color.Black)

 

pbCircle.Refresh()

 

If radRadian.Checked = True Then

 

 txtEndx.Text = (159 - (70 - ((Math.Sin(Math.PI / 2 - txtMeasure.Text)) * 70)))

 txtEndy.Text = (88 - (Math.Sin(txtMeasure.Text)) * 70)

 

End If

 

If radDegree.Checked = True Then

 

 txtEndx.Text = (159 - (70 - ((Math.Sin(Math.PI / 2 - (txtMeasure.Text * (Math.PI / 180))) * 70))))

 txtEndy.Text = (88 - (Math.Sin((txtMeasure.Text * (Math.PI / 180)))) * 70)

 

End If

 

 cenX = txtCenterx.Text

 cenY = txtCentery.Text

 endX = txtEndx.Text

 endY = txtEndy.Text

 myPen.Width = 2

 myPen2.Width = 3

 pbCircle.CreateGraphics.DrawLine(myPen, cenX, cenY, endX, endY)

 pbCircle.CreateGraphics.DrawLine(myPen2, cenX, cenY, 159, 88)

 

  • In the Elapsed event of the timer control write the following code.

 

Dim myPen2 As New Pen(Color.Black), cenX As Integer, cenY As Integer, endX As Integer, endY As Integer

pbCircle.Refresh()

cenX = txtCenterx.Text

cenY = txtCentery.Text

myPen2.Width = 3

pbCircle.CreateGraphics.DrawLine(myPen2, cenX, cenY, 159, 88)

Timer1.Enabled = False

 

Now run your application, enter the angle you desire to see, select any option from radian and degree and finally click the button.

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< How we can make XP Style Buttons in VB.Net

Disclaimer - Privacy
© 2002-2017 DevASP.net