Calculation of Position and Facing

Started by
3 comments, last by RonHiler 20 years, 6 months ago
Hi gang, Suppose I have, at a known time T1 (in microseconds), a known position(X1, Y1, Z1), a known look-at(XA, YA, ZA), a known Delta-position (DX1, DY1, DY2), where the delta-position is change of location (in arbitrary units) per microsecond, and a delta-look-at(DXA, DYA, DZA) (again, change per microsecond). Then, at another known time after T1 (let''s say T2) I want to calculate the new position and new look-at. The deltas will have been constant during this amount of time. How should I go about this? It sounds suspiciously like a calculus problem to me, but I have to keep it reasonably quick. Time is an issue here. The context of this is to calculate a player position and rotation given the player holding down a movment or rotation key, and then lifting (or pressing) one of them. Note I can''t calculate it while it is happening. This is a multiplayer game I''m talking about, and the keypress commands (with thier timestamps) are sent off to the server, where the position needs to be calculated from this information. Basically, the server gets information like this: At Time X, player 1 pressed key A At Time Y, player 1 pressed key B At Time Z, player 1 lifted key B etc. Ron
Creation is an act of sheer will
Advertisement
If you have two known locations, as well as two known deltas, and a period of time, then wouldn''t you just add the deltas to the locations? I know this isn''t what you''re looking for, because otherwise it would be extremely simple, but I''m having trouble understanding the context and what exactly you''re trying to do. Are the look-at vectors directions or actual points?
No, because the facing is changing over time. I guess I didn''t state my problem clearly enough, so I''ll retry

I''ll take out the third dimension, because I''m pretty sure at this point I can ignore the y-axis location (it''s just a height calculation from my terrain anyway).

Given (at Time T0):
Known location {X0, Z0} (in meters)
Known Rotation relative to y-axis: Ry0 (in radians)
Known Velocity V (in meters/second) - Constant from T0->T1
Known delta-Rotation dRy (in radians/second) - Constant from T0->T1

Calculate (at Time T1 (in seconds)):
New position {X1, Z1}
New Rotation Ry1

Note:Movement is always in direction of rotation, as it changes over time, the direction of movement also changes. This is why I think it''s a calculus problem. Unfortunately, my calculus is very rusty (I haven''t really used it much since college, heh).

Tips?

Ron
Creation is an act of sheer will
Well, if anyone is interested, here is what I came up with:

R(t) = R0 + wt;
Px(t) = Px(0) + v/w * cos (atan2(Py(0), Px(0)) - wt));
Py(t) = Py(0) + v/w * sin (atan2(Py(0), Px(0)) - wt));

where:
v = speed (m/s)
w = angular rotation (radians/s)
t = time (s)
R0 = Initial rotation
P0 = Initial point

These aren''t verified yet, I''m working on it

Ron
Creation is an act of sheer will
Correction, I made a mistake in my derivation. The calculations are:

Px(t)=Px(0) + v/w * (1-cos(w*t))
Pz(t)=Pz(0) + v/w * sin(w*t)

These *have* been confirmed, programmatically.
Creation is an act of sheer will

This topic is closed to new replies.

Advertisement