Loading...
 

General


Rotation toLocation

The JavaDoc is pretty unclear as to exactly what the toLocation method in Rotation is doing. This might be the method I need, but let me instead describe what I want and then hopefully someone can tell me the easiest way to do it.

Given the bot's current rotation, I want to get a Location that is exactly X distance units in front of the bot along its line of sight. I was hoping that there was a method that would turn the Rotation into a vector whose origin was the bot, and that pointed in the direction it was facing, since then I could simply scale and add this vector to the bot's Location.

Are there already some methods in place that will make this easy, or do I need to do some vector math to figure this out?
toLocation is the method you want to use. E.g.

Location OneHundredInFrontOfTheBot = info.getLocation().add(info.getRotation().toLocation().getNormalized().scale(100));


returns a location 100 ut units (~ 1 meter) in front of the bot. Just be careful - the vector will be in the same direction as the bot is currently looking to (so if the bot is looking up it will be above the ground). To account for this you can set the pitch attribute of the rotation you will be using to 0.
I think that toLocation converts Rotation to normalized location vector (but I've added getNormalized() just to be sure).
You might also check DistanceUtils static class - there are some useful methods (mainly for distance computations).
Thanks again. It looks like instead of setting pitch to 0, I can just use the getHorizontalRotation() method of the bot.
 

News

News RSS RSS feed for News link



Pogamut

Quarterly RSS RSS feed for quarterly reports

Acknowledgement

This work is supported by GA UK 1053/2007/A-INF/MFF (2007-8), GA UK 351/2006/A-INF/MFF (2006-8), the Ministry of Education of the Czech Republic (grant MSM0021620838) (2008-9), by the Program "Information Society" under project 1ET100300517 (2006-9), and the project Integration of IT Tools into Education of Humanities (2006-8) and by the project CZ.2.17/3.1.00/31162, which are financed by the European Social Fund, the state budget of the Czech Republic, and by the budget of Municipal House Prague.