# Mirror Movement

Mirror Movement is a form of 1v1 movement that tries to imitate the movement of the enemy. Though it can be effective against opponents with strong movement, it is utterly useless against opponents with weak movement or anti-mirror targeting.

Implementing mirror movement requires a decent radar lock.

The current state-of-art mirror is PolishedRuby.

## Coordinate Mirror Movement

This style of mirror movement tries to move to a point "opposite" the opponent. It requires a GoTo method, such as this one:

```private void goTo(double x, double y) {
/* Transform our coordinates into a vector */
x -= getX();
y -= getY();

/* Calculate the angle to the target position */
double angleToTarget = Math.atan2(x, y);

/* Calculate the turn required get there */

/*
* The Java Hypot method is a quick way of getting the length
* of a vector. Which in this case is also the distance between
* our robot and the target location.
*/
double distance = Math.hypot(x, y);

/* This is a simple method of performing set front as back */
double turnAngle = Math.atan(Math.tan(targetAngle));
if(targetAngle == turnAngle) {
} else {
setBack(distance);
}
}
```

It also requires calculating the coordinates of the enemy robot:

```public void onScannedRobot(ScannedRobotEvent e) {

// TODO
}
```

The enemy coordinates must then be transformed, before being passed to the goTo() function. The transformation depends on the type of mirroring:

Vertical line-reflection
```goTo(getBattleFieldWidth() - enemyX, enemyY);
```
Horizontal line-reflection
```goTo(enemyX, getBattleFieldHeight() - enemyY);
```
Point-reflection over the battlefield center
```goTo(getBattleFieldWidth() - enemyX, getBattleFieldHeight() - enemyY);
```

## Relative Mirror Movement

This type of movement attempts to imitate the opponent's movement (same direction and same velocity), starting at the bot's current location. For instance, if the enemy moves upward 100 units, your bot will also move upward 100 units. Not very effective against most guns, and must be combined with Wall Smoothing for any level of usefulness.

```public void onScannedRobot(ScannedRobotEvent e) {
setMaxVelocity(Math.abs(e.getVelocity()));
}
```

## Perpendicular Mirror Movement

This type of movement will circle the enemy, by turning perpendicular to it and moving at roughly the same velocity.

```public void onScannedRobot(ScannedRobotEvent e) {