Polar Plot, determining Angle

D

D-Dog

Hi,
I have a polar plot graph plotted on a JPanel, and I would like to
determine the angle selected around that graph, given the x,y position
of the mouse. I know this is probably more of a math (trig) question,
but I figured I would check here first, as I'm sure someone has dealt
with this before. I know how to retrieve the x,y position given the
radius, center_point, and angle, just not how to do the reverse of
that.

Thanks,

Dennis
 
P

Patricia Shanahan

D-Dog said:
Hi,
I have a polar plot graph plotted on a JPanel, and I would like to
determine the angle selected around that graph, given the x,y position
of the mouse. I know this is probably more of a math (trig) question,
but I figured I would check here first, as I'm sure someone has dealt
with this before. I know how to retrieve the x,y position given the
radius, center_point, and angle, just not how to do the reverse of
that.

I've never done this in Java graphics, so I don't know if there is any
graphics-specific method. On general trig principles, if the center
point is at (x1,y1), I would use Math.atan2(y-y1,x-x1).

Patricia
 
L

Lew

Patricia said:
I've never done this in Java graphics, so I don't know if there is any
graphics-specific method. On general trig principles, if the center
point is at (x1,y1), I would use Math.atan2(y-y1,x-x1).

In the graphics libraries, e.g.,
 
P

Patricia Shanahan

Lew said:
In the graphics libraries, e.g.,

Very good point. If the OP uses something like -r*Math.sin(theta) to get
the y coordinate, the y coordinate sign also needs to be flipped in the
atan2 call.

Patricia
 
D

D-Dog

Thank you! I already ran across the Y coordinate inverse problem when
I was orginally determined the x,y. Your information will help a
great deal.

Thanks again.

Dennis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top