Difference between revisions of "U"
Jump to navigation
Jump to search
m |
(update to date) |
||
Line 1: | Line 1: | ||
− | This page is dedicated for describing the <code> | + | {{Stub}} |
+ | |||
+ | This page is dedicated for describing the <code>aaa.util.math.U</code> | ||
Line 5: | Line 7: | ||
− | U is a universal | + | ''U'' is a universal math library, where ''U'' stands for ''U''niversal. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | The propose of U is to avoid code like this, which coupled business logic and math logic | |
<syntaxhighlight lang="java"> | <syntaxhighlight lang="java"> | ||
− | |||
− | |||
double absoluteBearing = this.getHeadingRadians() + event.getBearingRadians(); | double absoluteBearing = this.getHeadingRadians() + event.getBearingRadians(); | ||
double latVel = Math.sin(event.getHeadingRadians() - absoluteBearing) * event.getVelocity(); | double latVel = Math.sin(event.getHeadingRadians() - absoluteBearing) * event.getVelocity(); | ||
double advVel = -Math.cos(event.getHeadingRadians() - absoluteBearing) * event.getVelocity(); | double advVel = -Math.cos(event.getHeadingRadians() - absoluteBearing) * event.getVelocity(); | ||
− | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 61: | Line 20: | ||
<syntaxhighlight lang="java"> | <syntaxhighlight lang="java"> | ||
− | + | V direct = displacement(robot.pos(), enemy.pos()); | |
− | |||
− | |||
double latVel = cross(direct, enemy.vel()); | double latVel = cross(direct, enemy.vel()); | ||
double advVel = -dot(direct, enemy.vel()); | double advVel = -dot(direct, enemy.vel()); | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 07:05, 8 August 2018
This article is a stub. You can help RoboWiki by expanding it. |
This page is dedicated for describing the aaa.util.math.U
U is a universal math library, where U stands for Universal.
The propose of U is to avoid code like this, which coupled business logic and math logic
double absoluteBearing = this.getHeadingRadians() + event.getBearingRadians();
double latVel = Math.sin(event.getHeadingRadians() - absoluteBearing) * event.getVelocity();
double advVel = -Math.cos(event.getHeadingRadians() - absoluteBearing) * event.getVelocity();
write like this:
V direct = displacement(robot.pos(), enemy.pos());
double latVel = cross(direct, enemy.vel());
double advVel = -dot(direct, enemy.vel());