angle maths

BlitzMax Forums/BlitzMax Programming/angle maths

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

yes - I had to jiggle the wires a little to get what i wanted

Global x=14
Global y=14

Function ADtoXY:Float[](a:Float,d:Float)
	Local r:Float[2]
	r[0]=d*Sin(a)'x
	r[1]=-d*Cos(a)'y
	Return r
EndFunction

Function XYtoAD:Float[](x:Float,y:Float)
	Local r:Float[2]
	r[0]=ATan(y/x)'a
	If x<0 r[0]:+180
	r[0]:+90
	r[1]=Sqr(x^2 + y^2)'d
	Return r
EndFunction

Local solution1:Float[2]
solution1  =  XYtoAD(x,y)

Local solution2:Float[2]
solution2  =  ADtoXY(solution1[0],solution1[1])

Print "should be "+x+" and "+y
Print solution2[0]
Print solution2[1]