Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

Polar Plot, determining Angle

Thread view: 
D-Dog - 07 Apr 2007 17:01 GMT
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
Patricia Shanahan - 07 Apr 2007 17:08 GMT
> Hi,
>   I have a polar plot graph plotted on a JPanel, and I would like to
[quoted text clipped - 4 lines]
> 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
Lew - 07 Apr 2007 17:18 GMT
>> Hi,
>>   I have a polar plot graph plotted on a JPanel, and I would like to
[quoted text clipped - 8 lines]
> 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.,
<http://java.sun.com/javase/6/docs/api/java/awt/Graphics2D.html>
, the sign of y is reversed.

> This default transform maps the user space coordinate system to screen and printer device coordinates such that the origin maps to the upper left hand corner of the target region of the device with increasing X coordinates extending to the right and increasing Y coordinates extending downward.

Signature

Lew

Patricia Shanahan - 07 Apr 2007 17:57 GMT
>>> Hi,
>>>   I have a polar plot graph plotted on a JPanel, and I would like to
[quoted text clipped - 18 lines]
>> coordinates extending to the right and increasing Y coordinates
>> extending downward.

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-Dog - 08 Apr 2007 01:02 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.