A Maths/Physics/SDD problem. :D (1 Viewer)

hurrotisrobbo

Cabbage
Joined
Jul 30, 2002
Messages
531
Location
Sydney, Newtown.
Gender
Male
HSC
2002
Hello,

I have a bit of a maths/physics/SDD problem (and I'm not sure which :D).

Ok, for illustrative purposes, we have an object (Fred). Fred has a point D that he is attempting to reach. The following is a _2D_ problem, and we are looking at Fred from a top-down perspective.

I know one can get the Gradient to show which direction he should travel (ie. directly at D), however, he has to reach D gradually, in a number of steps (and it has a limit of how far it can move in one 'step.')

I need to figure out how to:
a) Make Fred walk towards D
b) at a constant rate.


Thanks in advance,
Robbo

PS: Will - None of your smart-ass f***ing comments here, thanks.
 

wogboy

Terminator
Joined
Sep 2, 2002
Messages
653
Location
Sydney
Gender
Male
HSC
2002
If you imagine a 2D grid, with XY coordinates, let's have Fred starting at point F and the target be point D. I suppose you can use vector (complex number) addition to solve the problem, with point F being represented by vector z1, and point D being represented by vector z2. Now Fred starts from z1 (point F) and moves towards his destination z2 (point F). The equation you need is:

p = z1 + vt(z2 - z1) (v = velocity at which Fred moves)

p = vector (complex number) that shows Fred's position at any time
z1 = vector (complex number) representing point F, the original starting point of Fred
z2 = vector (complex number) representing point D, Fred's destination
t = time (real number, scalar) representing the time elapsed.
v = speed at which Fred moves (real number, scalar)

With the above equation, all of the "vector" quantities (which are p, z1, z2) are in the format:

z = x + iy (where x is the x-coordinate, and y is the y-coordinate),

whereas the scalars (which are t & v) are simply ordinary (real) numbers.

(note that when t = 1/v, p = z2 and Fred has reached his destination).
 
Last edited:

hurrotisrobbo

Cabbage
Joined
Jul 30, 2002
Messages
531
Location
Sydney, Newtown.
Gender
Male
HSC
2002
Well, such questions as:

- How do you get i (in 'z = x + iy')

- What is a 'Complex Number'?!

- What do you mean by 'Scalar'?!

(As you can tell, I didn't study Physics. Or Maths 3U.)
 

McLake

The Perfect Nerd
Joined
Aug 14, 2002
Messages
4,187
Location
The Shire
Gender
Male
HSC
2002
Originally posted by hurrotisrobbo
Well, such questions as:

- How do you get i (in 'z = x + iy')

- What is a 'Complex Number'?!

- What do you mean by 'Scalar'?!

(As you can tell, I didn't study Physics. Or Maths 3U.)
(That's 4U maths, "i" is a complex number which = sqrt[-1], just don't worry about it ...)

Um, your going to need a new approach then. I have a feeling this ia an SDD problem, since I have no idea what you mean by it.
 

wogboy

Terminator
Joined
Sep 2, 2002
Messages
653
Location
Sydney
Gender
Male
HSC
2002
oops I (wrongly) assumed that you did 4U maths. :D

Anyway, don't worry about the first method with vectors I told you. That's the way most professional programmers do it, but you need to know 4U stuff.

Another simpler way to do it is by considering the screen to be just an ordinary number plane (like the one you studied in 2U coordinate geometry with XY coordinates) with the origin being, say for instance at the bottom left corner of the screen. Let point F (Fred's original position) be at (x1, y1), and his destination point D be (x2, y2). Also, let his current position at any time be point X (x, y). You need to consider his horizontal & vertical positions on the screen SEPARATELY.

HORIZONTAL POSITION (x-coordinates):

x = x1 + vt(x2 - x1)

VERTICAL POSITION (y-coordinates):

y = y1 + vt(y2 - y1)

where:

x = x-coordinate at any time
y = y-coordinate at any time
x1 = x-coordinate of point F (Fred's starting position)
y1 = y-coordinate of point F (Fred's starting position)
x2 = x-coordinate of point D (Fred's destination)
y2 = y-coordinate of point D (Fred's destination)
t = time elapsed
v = speed at which Fred moves.

(Note that when t = 1/v, x = x2, y = y2, and Fred has reached his destination)

Hope this helps.:)
 

hurrotisrobbo

Cabbage
Joined
Jul 30, 2002
Messages
531
Location
Sydney, Newtown.
Gender
Male
HSC
2002
Thanks _HEAPS_. :D

Umm... If it's not too much to ask, do you mind explaining how you arrived at the above equations?


That, and, umm... there's another bit. :D

Fred is moving as part of a group of people - those people have a goal (G), but while he is moving towards the goal, he must move towards the group (to a position determined by the averaging of the coordinates of the rest of the people in the group). This 'minor goal' uses the above to solve it - it works perfectly - I need no more help with it. :D

However, I have been struggling to work out how to incorporate this 'major goal' into Fred's movement.


(Next up, figuring out how to determine this 'major goal' from the angles the people are walking... AAAAAAAARGH! :eek: )

Thanks again,
Robbo
 
Last edited:

wogboy

Terminator
Joined
Sep 2, 2002
Messages
653
Location
Sydney
Gender
Male
HSC
2002
Umm... If it's not too much to ask, do you mind explaining how you arrived at the above equations?
To figure out the current position of Fred, we know:

speed = distance moved / time elapsed,
distance moved = speed * time elapsed

also,

current position = initial position + distance moved,
current position = initial position + (speed * time elapsed)

so if we let current position be (x,y), initial position be (x1, y1) and speed be v, and time elapsed be t, we get:

x = x1 + vt
y = y1 + vt

however, the reason for the (x2 - x1) and (y2 - y1) to be multiplied by vt is just for the sake of easy calculation. If we were to leave it out, the speed of Fred would be (x2 - x1)/t horizontally and (y2 - y1) vertically which (by Pythagoras' theorem) gives a total speed of sqrt([(x2 - x1)^2/t^2] + [(y2 - y1)^2/t^2]) which is simply too complicated, and an eyesore to look at (I don't blame you if you didn't bother looking at it :D)

When we multiply (x2 - x1) and (y2 - y1) with vt, it becomes such that the speed of Fred is simply 1/t or the recipricol of the total time taken, rather than that complicated equation above. So that's how we get:

x = x1 + vt(x2 - x1)
y = y1 + vt(y2 - y1)

Fred is moving as part of a group of people - those people have a goal (G), but while he is moving towards the goal, he must move towards the group (to a position determined by the averaging of the coordinates of the rest of the people in the group). This 'minor goal' uses the above to solve it - it works perfectly - I need no more help with it.

However, I have been struggling to work out how to incorporate this 'major goal' into Fred's movement.
I don't undertand what you exactly mean :confused: Do you mean he has to move to the midpoint of the goal, and the group of people? Probably you can take the average of all the coordinates of the people in the group and get that centre coordinate of the group. Now find the midpoint of this group "centre" and the goal (G) and make this midpoint your "new minor target" using the formula above. Is this what you mean?

(Next up, figuring out how to determine this 'major goal' from the angles the people are walking... AAAAAAAARGH! )
I'm totally lost now :confused: :confused:
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top