robocode.util
Class Coordinates

java.lang.Object
  extended by robocode.util.Coordinates

public class Coordinates
extends Object

This class is responsible for transforming points into exact coordinates using the AffineTransform class.

Since:
Robocode 1.8.3.0 Alpha 1 / Naval Edition
Version:
1.1 (Support for the splashscreen!)
Author:
Thales B.V. / Jiri Waning

Constructor Summary
Coordinates()
           
 
Method Summary
static AffineTransform getAffineTransform(double heading, double x, double y)
          Get the AffineTransform from the given values.
static AffineTransform getAffineTransformShip(ITransformablePeer peer)
          Get the AffineTransform for the ShipPeer.
static double getParallax(ITransformable peer, IComponent component, double x, double y)
          Get the parallax (angle) between the component and the other coordinates.
static Point2D getPivot(ITransformable peer, double y)
          getPivot(ITransformable, double, double)
static Point2D getPivot(ITransformable peer, double x, double y)
          Get the transformed pivot point of an object on the ship.
static AffineTransform getPivotTransform(double heading, double x1, double y1, double x2, double y2, double rotation)
          Get the AffineTransform for the given values.
static AffineTransform getPivotTransform(ITransformable peer, double y, double rotation)
          getPivotTransform(ITransformable, double, double, double)
static AffineTransform getPivotTransform(ITransformable peer, double x, double y, double rotation)
          Get the AffineTransform for the specified coordinates on the peer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Coordinates

public Coordinates()
Method Detail

getPivot

public static final Point2D getPivot(ITransformable peer,
                                     double y)
getPivot(ITransformable, double, double)


getPivot

public static final Point2D getPivot(ITransformable peer,
                                     double x,
                                     double y)
Get the transformed pivot point of an object on the ship.

Parameters:
peer - The peer for whom to calculate the pivot point.
x - The X-coordinate relative to that of the ship.
y - The Y-coordinate relative to that of the ship.
Returns:
The transformed (exact) position of the pivot point.

getPivotTransform

public static final AffineTransform getPivotTransform(ITransformable peer,
                                                      double y,
                                                      double rotation)
getPivotTransform(ITransformable, double, double, double)


getPivotTransform

public static final AffineTransform getPivotTransform(ITransformable peer,
                                                      double x,
                                                      double y,
                                                      double rotation)
Get the AffineTransform for the specified coordinates on the peer.

Parameters:
peer - The peer for whom to get the transformation.
x - The X-coordinate relative to that of the ship.
y - The Y-coordinate relative to that of the ship.
rotation - The amount the pivot has to rotate around its own axis.
Returns:
The AffineTransform for the specified point.

getPivotTransform

public static final AffineTransform getPivotTransform(double heading,
                                                      double x1,
                                                      double y1,
                                                      double x2,
                                                      double y2,
                                                      double rotation)
Get the AffineTransform for the given values.

Parameters:
heading - The heading of the robot.
x1 - The X-coordinate of the robot.
y1 - The Y-coordinate of the robot.
x2 - The relative X-coordinate of the component.
y2 - The relative Y-coordinate of the component.
rotation - The angle of the component.
Returns:
An AffineTranform representing the given values.

getAffineTransformShip

public static final AffineTransform getAffineTransformShip(ITransformablePeer peer)
Get the AffineTransform for the ShipPeer.

Parameters:
peer - The peer of whom the get the AffineTransform.
Returns:
An AffineTransform for the given Ship.

getAffineTransform

public static final AffineTransform getAffineTransform(double heading,
                                                       double x,
                                                       double y)
Get the AffineTransform from the given values.

Parameters:
heading - The heading of the robot.
x - The X-coordinate of the robot.
y - The Y-coordinate of the robot.
Returns:
The AffineTransform matching the given values.

getParallax

public static double getParallax(ITransformable peer,
                                 IComponent component,
                                 double x,
                                 double y)
Get the parallax (angle) between the component and the other coordinates.

The angle is relative based upon the component. (With angle 0 facing north!)

Parameters:
peer - The robot to whom the component belongs to.
component - The component from whom to measure the parallax to the given coordinates.
projectile - The coordinates from whom to find the parallax.
Returns:
The relative angle between the component and the other; in radians.


Copyright © 2015 Robocode. All Rights Reserved.