Difference between revisions of "U"

From Robowiki
Jump to navigation Jump to search
(Initial commit.)
 
m (Fix)
Line 17: Line 17:
 
Vec dis = displacement(bot.pos(), enemy.pos());
 
Vec dis = displacement(bot.pos(), enemy.pos());
 
double latVel = cross(dis, enemy.vel());
 
double latVel = cross(dis, enemy.vel());
double advVel = dot(dis, enemy.vel());
+
double advVel = -dot(dis, enemy.vel());
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 04:44, 15 August 2017

This page is dedicated for describing the xor.util.ds.U


U is a immutable data-structure library, where U stands for both Util and Universal.

With U, you can write code just like this:

Vec dis = displacement(bot.pos(), enemy.pos());
dis = rotate(dis, radians(PI / 2));
Point projected = project(bot.pos(), dis);

Or even this:

Vec dis = displacement(bot.pos(), enemy.pos());
double latVel = cross(dis, enemy.vel());
double advVel = -dot(dis, enemy.vel());