how do you convert degrees to radians?

BlitzMax Forums/BlitzMax Beginners Area/how do you convert degrees to radians?

Matt McFarland(Posted 2006) [#1]
so if I were to have a moon orbit a planet..

moon.x = planet.x+cos(degreestoradians(angle))*radius
moon.y = planet.y-planet.y-sin(degreestoradians(angle))*radius

But what should angle be? and how do I convert degrees to radians?

sorry for my noobishness!

-Matt


SillyPutty(Posted 2006) [#2]
degrees = radians*(180/pi)

radians = degrees*(pi/180)

post some sample code, why you need radians ?


FlameDuck(Posted 2006) [#3]
Additionally in BlitzMAX trigonometry functions
(Sin, Cos, Tan, ASin, ACos, ATan) all work in degrees, not radians, so you do not need to convert them for what it looks like you're trying to do.


Matt McFarland(Posted 2006) [#4]
I'm just trying to understand the orbiting concept. Making something move in a circle :)

Is there a different way to do this?


Matty(Posted 2006) [#5]
Here is a different way of making something move in a circle. It is written in blitzbasic/blitz3d code as I don't have blitzmax but I am sure it could easily be ported (it is only a few lines after all)

Graphics 800,600,32,2
SetBuffer BackBuffer()

planetx#=400
planety#=300

moonx#=400
moony#=250

moonax#=(planetx-moonx)/250.0
moonay#=(planety-moony)/250.0

moonvx#=3.0
moonvy#=0


Repeat
Cls

moonx=moonx+moonvx*0.5+(moonvx+moonax*0.5+(planetx-moonx)/1024.0)*0.5
moony=moony+moonvy*0.5+(moonvy+moonay*0.5+(planety-moony)/1024.0)*0.5
moonvx=(moonvx+moonax*0.5+(planetx-moonx)/1024.0)
moonvy=(moonvy+moonay*0.5+(planety-moony)/1024.0)
moonax#=(planetx-moonx)/512.0
moonay#=(planety-moony)/512.0



Color 0,100,200
Oval planetx,planety,4,4,1

Color 100,100,100
Oval moonx,moony,2,2,1

dist=((planetx-moonx)^2+(planety-moony)^2)
If dist>maxdist Then maxdist=dist
Color 255,255,255
Text 0,0,maxdist
Flip



Until KeyDown(1)