lejos.robotics.mapping
Class LineMap

java.lang.Object
  extended by lejos.robotics.mapping.LineMap
All Implemented Interfaces:
RangeMap

public class LineMap
extends Object
implements RangeMap

A map of a room or other closed environment, represented by line segments

Author:
Lawrie Griffiths

Constructor Summary
LineMap()
          Constructor to use when map will be loaded from a data stream
LineMap(Line[] lines, Rectangle boundingRect)
          Create a map from an array of line segments and a bounding rectangle
 
Method Summary
 void dumpMap(DataOutputStream dos)
          Dump the map to a DataOutputStream
 Rectangle getBoundingRect()
          Return the bounding rectangle of the mapped area
 boolean inside(Point p)
          Check if a point is within the mapped area
 void loadMap(DataInputStream dis)
          Load a map from a DataInputStream
 float range(Pose pose)
          Calculate the range of a robot to the nearest wall
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineMap

public LineMap(Line[] lines,
               Rectangle boundingRect)
Create a map from an array of line segments and a bounding rectangle

Parameters:
lines - the line segments
boundingRect - the bounding rectangle

LineMap

public LineMap()
Constructor to use when map will be loaded from a data stream

Method Detail

range

public float range(Pose pose)
Calculate the range of a robot to the nearest wall

Specified by:
range in interface RangeMap
Parameters:
pose - the pose of the robot
Returns:
the range or -1 if not in range

inside

public boolean inside(Point p)
Check if a point is within the mapped area

Specified by:
inside in interface RangeMap
Parameters:
p - the Point
Returns:
true iff the point is with the mapped area

getBoundingRect

public Rectangle getBoundingRect()
Return the bounding rectangle of the mapped area

Specified by:
getBoundingRect in interface RangeMap
Returns:
the bounding rectangle

dumpMap

public void dumpMap(DataOutputStream dos)
             throws IOException
Dump the map to a DataOutputStream

Parameters:
dos - the stream
Throws:
IOException

loadMap

public void loadMap(DataInputStream dis)
             throws IOException
Load a map from a DataInputStream

Parameters:
dis - the stream
Throws:
IOException