The angles are crazy!

1

I am creating a simple orbit system, where you have the earth and the sun, created based on a UserControl , the problem is that I do not know why the angle gets wacky when placing an angle in the Angle property. The control is this:

Andhere'syourcode:

PublicPropertyAngleAsIntegerPrivateSubOrbit_Paint(senderAsObject,eAsPaintEventArgs)HandlesMe.PaintDimg_AsGraphics=e.Graphicsg_.SmoothingMode=SmoothingMode.HighQualityDimpAsNewPen(Color.White,1)DimmyRect=Me.ClientRectangleDimoriginAsNewPoint(myRect.Width/2,myRect.Height/2)g_.DrawEllipse(p,myRect)Dimr=myRect.Height/2Dima=AngleDimnx=r*Cos(a)+origin.XDimny=r*Sin(a)+origin.YDimnpAsNewPoint(nx,ny)Dimax_earthAsNewPoint(np.X-5,np.Y-5)Dimax_sunAsNewPoint(origin.X-5,origin.Y-5)g_.DrawLine(NewPen(Color.Gray,1),origin,np)g_.FillEllipse(NewSolidBrush(Color.DeepSkyBlue),NewRectangle(ax_earth,NewSize(5,5)))g_.FillEllipse(NewSolidBrush(Color.Gold),NewRectangle(ax_sun,NewSize(10,10)))EndSub

Iused polar coordinates to calculate the x, y point of where the planet will be earth, the formulas are as follows:

risthehorizontalsizedividedbytwo.θisdefinedbytheAngle

Theproblem

Evenbeauty,whenforexampleIputinthepropertyAngle90,thecorrectthingwastobeintheperfecthorizontalhalf,butthatwaswhatitgave:

SoItried120:

IthinktheproblemisintheDima=Angleline,butIhonestlydonotknowtheformulatosolvethis.AsIleavetheperfectangle,moreorlesslikethis[?]:

    
asked by anonymous 15.07.2016 / 08:24

1 answer

2

Well, digging a little and reading a bit about trigonometry I just split the angle by 180 and multiplied by the PI, like this:

Dim a = Angle / 180 * PI

And it worked. I honestly did not know how to solve this, and magically a light from heaven came and solved my problem spontaneously.

    
15.07.2016 / 08:28