Difference between revisions of "Lateral Velocity"

From Robowiki
Jump to navigation Jump to search
m (Using <syntaxhighlight>.)
Line 3: Line 3:
 
An example of calculating an enemy's lateral velocity would be:
 
An example of calculating an enemy's lateral velocity would be:
  
<pre>
+
<syntaxhighlight>
 
public void onScannedRobot(ScannedRobotEvent e) {
 
public void onScannedRobot(ScannedRobotEvent e) {
 
     double enemyAbsoluteBearing = e.getBearingRadians() + getHeadingRadians();
 
     double enemyAbsoluteBearing = e.getBearingRadians() + getHeadingRadians();
 
     double enemyLatVel = e.getVelocity()*Math.sin(e.getHeadingRadians() - enemyAbsoluteBearing);
 
     double enemyLatVel = e.getVelocity()*Math.sin(e.getHeadingRadians() - enemyAbsoluteBearing);
 
}
 
}
</pre>
+
</syntaxhighlight>
  
 
In this example, a bot moving clockwise has a positive lateral velocity, while a bot moving counter-clockwise has a negative lateral velocity.
 
In this example, a bot moving clockwise has a positive lateral velocity, while a bot moving counter-clockwise has a negative lateral velocity.

Revision as of 09:28, 1 July 2010

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.

An example of calculating an enemy's lateral velocity would be:

public void onScannedRobot(ScannedRobotEvent e) {
    double enemyAbsoluteBearing = e.getBearingRadians() + getHeadingRadians();
    double enemyLatVel = e.getVelocity()*Math.sin(e.getHeadingRadians() - enemyAbsoluteBearing);
}

In this example, a bot moving clockwise has a positive lateral velocity, while a bot moving counter-clockwise has a negative lateral velocity.

See Also

Linear Targeting