Advertisement Jump to content


This topic is now archived and is closed to further replies.


Themepark Problem

This topic is 5461 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I know i'm going to go.. "Ohhh.. duh!!", but here we go. I'm making a theme park simulation app, and right now i'm trying to get the population to go from ride to ride, in a strait line (for now). Each ride is placed on a square, xy coordinate map, along with their walking duration (distance) from the center origin. Basically, I'm trying to figure out the theorem or equation to calculate where a person should be at X mins if they're walking from A to B: I figured, at first to use to pythagorean theorem (a^2 + b^2 = c^2) to get the missing walk duration, but after everyone walked from a certain angle and ended up somewhere i dunno, i then remembered that only worked with right triangles. (And once i have the third duration, i know i have to use this to calc where the person is between the rides.) Then I thought that since my park is square, that i can use the same theorem with the walls of the park, and figure out the third side: I felt like I was on the right track, but i'm stuck... not very good at geometry, i guess advTHANKSance [edited by - _untitled on February 5, 2004 4:09:23 PM]

Share this post

Link to post
Share on other sites
If u just need the distance between A and B:

distance=sqrt ((a.x-b.x)^2 + (a.y-b.y)^2))

if u wanna know where some1 is after
x minuts. Ull need the degrees between A and B. And the use Sinus and Cosinus to calculate the x and y.Then u multipyl x and y with the minuts he walked and add it to position of A.

I hope this is what u mean..

Share this post

Link to post
Share on other sites
Hmmm... I think i know what you mean. I'll try it out ...

edit: Ow my brain Can u elaborate further with an example maybe. Or point me to a site that has one?

[edited by - _untitled on February 5, 2004 8:36:54 PM]

Share this post

Link to post
Share on other sites
I assume that you mean people travel a constant velocity.


distance = velocity * time

time = distance / velocity

Since velocity is constant you know that already.

If the two points you are travelling between are from
A = (x1,y1) to B = (x2,y2) then the distance squared is

distance^2 = (x1-x2)^2 + (y1-y2)^2

So take the square root of both sides to get the distance.

time = distance / velocity,
you can now compute the time it takes to go from A to B (or B to A).

Now, I am guessing you need to figure out how to compute the x,y coordinates of a person travelling from A to B. Call the time to go from A to B, tAB.

Let''s say 1 person leaves point A at time t1.
Call the simulation time, time t.

if ( t - t1 == tAB ) then person is at point B.

if ( t - t1 > tAB ) then person has gone past B (signal error!)

if ( t - t1 < tAB ) then person is somewhere between A and B.

(t - t1) / tAB = fraction of total distance covered = f

Xdistance = abs(x1 - x2)
Ydistance = abs(y1 - y2)

xc = current x position relative to starting point
yc = current y position relative to starting point

xc / Xdistance = f
yc / Ydistance = f

xc = f * Xdistance
yc = f * Ydistance

if( x1 <= x2 then
x = x1 + xc
x = x1 - xc

if( y1 <= y2 then
y = y1 + yc
y = y1 - yc

So x and y will now contain the person''s coordinate.

Note xc will be 0 for vertical lines and yc will be 0 for horizontal lines.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!