submarine commander project

new topic     » topic index » view thread      » older message » newer message

Can any of you geometry people out there help me?

function p2xy(atom r, atom a)   -- polar to xy
   return {-r*sin(a),-r*cos(a)}
end function

all measurements in pixels.

r=distance from center
x=clock in degrees 3600 = center to top
center=vector {400,273 } 
fin=cen+p2xy(r,x/1800*PI)  --the outmost position of the radius
drawLine(Pix,cen[1],cen[2],floor(fin[1]),floor(fin[2])) --one line of the sweep.

This formula gives me the position of the final dot of the radius. Works good.

What I would like to do is the opposite  to find the clock degrees and last
radius position
given the center and the vector.

For example let's say center={400,273}.

A dot is out there at {210,120}.

What would be the clock degrees to that dot?
3600=12 o'clock
1800=6 o'clock
2700=9 o'clock etc...
And how many pixels from the center to that dot?

Don Cole

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu