0

I'm trying to build an automated guided vehicle simulator using fuzzy logic in Java, but I stuck on this.

I'd like to calculate distance between point and area using Graphics2D. I know point location, angle and color of the area. It looks like this:

i.imgur.com/X3jufMk.png

camickr
  • 321,443
  • 19
  • 166
  • 288
Senoy
  • 1
  • 2
  • 1
    Welcome to SO! Can you provide more information on where you are stuck, including what code you have tried so far? – Derek Oct 25 '13 at 18:24
  • You mean that you are provided an image similar to the one above, most probably with only the blue blob and the black angled rectangle, and then the coordinate of a point that is on that rectangle, and the angle in which the distance is to be calculated. Is that right? – James Oct 25 '13 at 18:31
  • I get something like this i.imgur.com/shAOoGz.png but without green lines. The green lines are distances to calculate, and based on that using fuzzy logic I can adjust the angle of "car" moving through the course. I don't have any code other than drawing the course, which is fairly easy (using fillOval on Graphics2D). – Senoy Oct 25 '13 at 19:11

1 Answers1

0

I won't provide code at this point, but here is a simple strategy that you might use.

First, apply an AffineTransform rotation to the image so that the "green" line in your sketch is aligned on the horizontal axis, and the provided point is at the origin. Then crop the image to a single pixel height. Then obtain the image's raster in a specific encoding that will be easy to work with. And finally, walk each pixel in the Raster, until you reach the first pixel of the given color. You might then need some adjustment of that distance in order to account for the rotation angle.

James
  • 4,211
  • 1
  • 18
  • 34