Difference between revisions of "Lateral Velocity"
m (add link to advancing velocity) |
m (Minor edit.) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | A bot's velocity in a direction perpendicular to the reference bot. For a bot moving perpendicular, abs(velocity) would equal abs(lateral velocity), while for a bot moving directly toward or away from a reference bot, lateral velocity would be zero. | + | A bot's velocity in a direction perpendicular to the reference bot. For a bot moving exactly perpendicular to the reference bot, abs(velocity) would equal abs(lateral velocity), while for a bot moving directly toward or away from a reference bot, lateral velocity would be zero. |
− | + | As a hypothetical example, let's imagine an enemy bot moving full speed at a 45 degree angle toward or away from the reference bot. From the reference bot's perspective, the actual lateral distance the enemy covers would be the same as if the enemy was moving perpendicular at half-speed. So, if the reference bot was using [[Linear Targeting|linear targeting]], it would aim at a velocity of 4 (or -4 if the enemy was moving counter-clockwise), and (assuming the enemy moved in a straight line and didn't hit a wall), it would hit the enemy every time! | |
+ | |||
+ | Lateral velocities are very commonly used in [[:Category:Targeting|targeting algorithms]], ranging from simple linear targeting to extremely complex [[GuessFactor Targeting (traditional)|guess factor guns]]. | ||
+ | |||
+ | Here is an example of how to calculate an enemy's lateral velocity: | ||
<syntaxhighlight> | <syntaxhighlight> | ||
public void onScannedRobot(ScannedRobotEvent e) { | public void onScannedRobot(ScannedRobotEvent e) { | ||
double enemyAbsoluteBearing = e.getBearingRadians() + getHeadingRadians(); | double enemyAbsoluteBearing = e.getBearingRadians() + getHeadingRadians(); | ||
− | double | + | double enemyLateralVelocity = e.getVelocity() * Math.sin(e.getHeadingRadians() - enemyAbsoluteBearing); |
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | In this example, a bot moving clockwise | + | In this example, a bot moving clockwise would have a positive lateral velocity, and a bot moving counter-clockwise would have a negative lateral velocity. |
== See Also == | == See Also == | ||
* [[Linear Targeting]] | * [[Linear Targeting]] | ||
* [[Advancing Velocity]] | * [[Advancing Velocity]] | ||
+ | * [[Angular Velocity]] | ||
[[Category:Terminology]] | [[Category:Terminology]] |
Latest revision as of 19:02, 1 May 2013
A bot's velocity in a direction perpendicular to the reference bot. For a bot moving exactly perpendicular to the reference bot, abs(velocity) would equal abs(lateral velocity), while for a bot moving directly toward or away from a reference bot, lateral velocity would be zero.
As a hypothetical example, let's imagine an enemy bot moving full speed at a 45 degree angle toward or away from the reference bot. From the reference bot's perspective, the actual lateral distance the enemy covers would be the same as if the enemy was moving perpendicular at half-speed. So, if the reference bot was using linear targeting, it would aim at a velocity of 4 (or -4 if the enemy was moving counter-clockwise), and (assuming the enemy moved in a straight line and didn't hit a wall), it would hit the enemy every time!
Lateral velocities are very commonly used in targeting algorithms, ranging from simple linear targeting to extremely complex guess factor guns.
Here is an example of how to calculate an enemy's lateral velocity:
public void onScannedRobot(ScannedRobotEvent e) {
double enemyAbsoluteBearing = e.getBearingRadians() + getHeadingRadians();
double enemyLateralVelocity = e.getVelocity() * Math.sin(e.getHeadingRadians() - enemyAbsoluteBearing);
}
In this example, a bot moving clockwise would have a positive lateral velocity, and a bot moving counter-clockwise would have a negative lateral velocity.