VB.Net: Angle to X/Y co-ordinates

~J~

~J~

Soldato
Joined
20 Oct 2003
Posts
7,558
Location
London
Feel ashamed asking this as my maths is so bad!!!

I'm try to plot points around a circle, based on an angle specified (with 0 degrees been at the top, and moving in a clockwise direction, 90 been far right, etc, etc).

Has anyone got any pointers on how I can do something 'similar' (or better) than the following...

a=angle
r=radius

x=[magic in here]
y=[magic in here]

e.graphics.DrawRectangle(color.black,x,y,2,2)

TIA
 
Some hints, seeing as your math is so bad: :p



Points to watch out for:

1.) Unit of measure for z, typically this is Radians, NOT degrees. If you insist on using degrees then you'll need to convert first.
2.) Y axis as per trigonometry is increasing upwards. A display is typically the other way round, so there's another conversion needed.
 
Dunno if VB.Net uses radians or degrees for its trig functions, I'm assuming radians:

deg2rad = (2*pi)/360

x = sin(a*deg2rad)*r
y = cos(a*deg2rad)*r

edit: bah, beaten :p
 
Exactly what I was after, some pointers and not an answer.

Cheers folks, appreciate it.
 
Back
Top Bottom