We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Local to World Coordinate Translating
Page Index Toggle Pages: 1
Local to World Coordinate Translating (Read 358 times)
Local to World Coordinate Translating
Aug 11th, 2008, 5:53pm
 
Hi all,
I'm coding a wandering behavior as described in Matt Buckland AI Game Programming.
I got stuck at this part: translating the local coordinate of the wandering circle to the world (screen/global) coordinate.
For example: if I create a point in my circle by

// Theta is a random radian value
float x = random(-1,1) * Math.cos(theta);
float y = random(1-,1) * math.sin(theta);

My vehicle position has a coordinate of vX and vY.
How do I translate the x and y from relative to vX and vY to the world coordinate? I hope I phrase the question clear enough.

Thank you experts.
regards,
Doug
Re: Local to World Coordinate Translating
Reply #1 - Aug 14th, 2008, 12:50am
 
I don't know the book or example, but I think I understand the question Smiley

In many other languages you would take the size of you map(width and height)  and divide this by the size of the world to get some a scaling factor to multiply with all your x, y, coordinates.

In processing the map function takes care of that for you:

http://processing.org/reference/map_.html

Hope that helps out in your case.

Ricki
Page Index Toggle Pages: 1