views:

246

answers:

1

My current problem is not so much a blackberry issue as it is a java package issue.

In the application I have a rectangular region. This region is rotated by about 30%.

I need to accomplish two things: when a user clicks, is he inside the region? when a user draws a straight line on the screen, does any part of that line intersect the region? if so, what is the length of the line inside the region?

I know that I can write my own functions to accomplish this (after dusting off some algebra and geometry skills that aren't needed for web forms) but I was thinking that this is a common issue in game programming. I found some libraries for c++ and some for c# but nothing for java.

Does anyone have suggestions for good java packages? The packages don't need to have graphical components. In fact it would be best if they just handled the geometry and calculations based on x,y co-ordinates alone.

+1  A: 

The usefulness of this answer will depend on exactly what type (SE or ME) and what version (and, for ME, what config and profile) of JVM you are targeting. Since it's a blackberry, you are likely J2ME of some flavor - YMMV.

That said, the functions you want appear to be present in java.awt.Rectangle, java.awt.geom.Rectangle2D and java.awt.geom.Line2D.

Software Monkey