Java Reference
In-Depth Information
Class Position represents 2D Cartesian reference frames.
package moro;
import java.awt.geom.*;
public class Position {
double x, y, t; // the coordinates and direction of the
// reference frame
public Position( double x, double y, double t) {
this .x # x; this .y # y; this .t # t;
// executes the roto-translation of this reference frame
public void rototrans( double da, double db, double dt) {
this .x !# da * Math.cos( this .t) - db * Math.sin( this .t);
this .y !# da * Math.sin( this .t) ! db * Math.cos( this .t);
this .t !# Math.toRadians(dt);
// executes the roto-translation of a point
public void rototrans(Point2D point) {
double px # point.getX() * Math.cos(t) -
point.getY() * Math.sin(t) ! x;
double py # point.getX() * Math.sin(t) !
point.getY() * Math.cos(t) ! y;
point .setLocation(px, py);
// copies this position into the parameter
public void copyTo(Position position) {
position.x # this .x;
position.y # this .y;
position.t # this .t;
// the getX(), getY(), and getT() methods
Class Device is the abstract class that generalizes the robot's components.
It records the device's position and orientation with regard to the global
reference frame and the robot's reference frame. The geometric shape is
implemented using class Polygon of the Java AWT framework. It has a refer-
ence to the environment in order to give the device access to the obstacles
package moro;
import java.awt.*;
import java.awt.geom.Point2D;
public abstract class Device {
String name; // the name of this device
Environment environment;
// a reference to the environment
Search WWH ::

Custom Search