Click to See Complete Forum and Search --> : Velocity Vector
Halsafar
Jan 8th, 2005, 05:03 PM
So far I've been defining by individual unit speeds as a float.
So Velocity = Speed * Time;
Time = TimeDelta = the time it took to go through the frame
But I am getting into equations that is looking for a VELOCITY VECTOR
I am curious as to exactly what that is...I mean other than the obvious.
Is it simply a vector I use to define speed so in other words (1,0,1)...
Is it the numbers used to move 1 unit forward on any angle (some sin, cos of the x,z values)? Those numbers are used multiplied by the velocity above to get the new position.
NoteMe
Jan 8th, 2005, 05:19 PM
Velocity vectors in games are often just a zero vector.
Halsafar
Jan 8th, 2005, 05:53 PM
So you mean 0,0,0?
How can that be?
I figured it would at least be the
vNewPos - vOldPos = vVelocity;
But that is distance travelled...
Halsafar
Jan 8th, 2005, 06:48 PM
Is this the velocity vector???
//m_VectorCircle is a lookup table full of sin/cos values.
float m_Velocity = Speed * TimeDelta;
m_vVelocity.x = (m_VectorCircle[m_Angle].u * m_Velocity) * (m_VectorCircle[m_UpAngle].u);
m_vVelocity.y = (m_VectorCircle[m_UpAngle].v * m_Velocity);
m_vVelocity.z = (m_VectorCircle[m_Angle].v * m_Velocity) * (m_VectorCircle[m_UpAngle].u);
This vector has direction...given the angle.
This vector would represent 1 step in the direction of the angle specified.
Multiplied the scalar Velocity we should end up with a Vector representing velocity.
wossname
Jan 9th, 2005, 03:39 AM
So Velocity = Speed * Time
Not surprised you are having problems.
Velocity: v = u + at
Where u is initial velocity, a is acceleration and t is time
Distance Travelled: d = vt
azteched
Jan 9th, 2005, 07:40 AM
^For constant acceleration.
Generally, including variable acceleration,
v = integral(a.dt)
dist = integral(v.dt)
over the time interval you're interested in.
Halsafar, every frame, just do
VelVec = OldVelVec + AccelVec*TimeDelta
PosVec = OldPosVec + VelVec*TimeDelta
Simple!
NoteMe
Jan 9th, 2005, 10:28 AM
So you mean 0,0,0?
How can that be?
Thats not a zero vector silly....A zero vector is a vector that has it's starting point in orico, and can both be looked at as a point in 3D/2D and a vector.
azteched
Jan 9th, 2005, 10:45 AM
http://mathworld.wolfram.com/ZeroVector.html
NoteMe
Jan 9th, 2005, 11:39 AM
http://mathworld.wolfram.com/ZeroVector.html
Thats what math guys calls zero vector....boring math guys calls what we game programmer calls zero vector for free vector...;) :)
azteched
Jan 9th, 2005, 12:48 PM
Sorry but "zero vector" for "free vector" is misleading - the mathematics terminology makes much more sense. This is the Maths forum anyway ;)
NoteMe
Jan 9th, 2005, 02:15 PM
But HE is a game programmer, and he asked a game programming question...:)....don't be offended. Just trying to resolve the missunderstanding.
azteched
Jan 9th, 2005, 02:33 PM
I'm not at all offended :)
I just think the term "zero vector" doesn't really help here.
NoteMe
Jan 9th, 2005, 03:17 PM
Well, you can call it what ever you want. But that is how it is done in game programming...:)
Halsafar
Jan 9th, 2005, 06:37 PM
Generally, including variable acceleration,
v = integral(a.dt)
dist = integral(v.dt)
over the time interval you're interested in.
Halsafar, every frame, just do
VelVec = OldVelVec + AccelVec*TimeDelta
PosVec = OldPosVec + VelVec*TimeDelta
Not surprised you are having problems.
Velocity: v = u + at
Where u is initial velocity, a is acceleration and t is time
Distance Travelled: d = vt
I am still confued.
Initial Velocity u is 0.0f always i presume
My speed is a float -- 0.05f
Time is a float -- average 50.00ms
See I don't know how to define velocity as a vector....
Nothing is a vector, I can't get vectors from floats.
This is really bugging me because I'm sure I'm just missing the point.
Halsafar
Jan 9th, 2005, 06:54 PM
All I have is the players position, the angle at which he wants to move, the speed as a float.
NoteMe
Jan 9th, 2005, 07:04 PM
All I have is the players position, the angle at which he wants to move, the speed as a float.
Thats because you started in the wrong end. Use a Zero (or for azteched, a free vector), a vector has you direction, then find the magnitude of that vector to find the speed. Simple as that.
ии
Halsafar
Jan 9th, 2005, 07:13 PM
Can you show a quick example?
Pick any numbers.
Halsafar
Jan 9th, 2005, 09:32 PM
All I need is some numbers showing me whats you mean.
azteched
Jan 10th, 2005, 05:12 AM
e.g velocity = (1,1,1)
speed = magnitude(velocity) = sqrt(3)
If you need the angle between the velocity and an axis, do the dot product of the normalised velocity with the unit vector along that axis.
NoteMe
Jan 10th, 2005, 07:01 AM
e.g velocity = (1,1,1)
speed = magnitude(velocity) = sqrt(3)
If you need the angle between the velocity and an axis, do the dot product of the normalised velocity with the unit vector along that axis.
Thanks...I was asleep when he asked...:)
PS: And if any forces is "pulled" on the object, just use vector addition to handle it.
Halsafar
Jan 10th, 2005, 01:27 PM
You're still blowing my mind...
My player is at 0,0,0
He is facing 0 Degree...thus along the x axis so I could use (1,0,0) as my velocity * speed
Oh, but now the player is at 0,0,0 facing 45...(0.5, 0, 0.5) -- I believe to walk 45 degree down the x,z.
Like -- either i'm really stupid or we aren't on the same page.
The player decides the angle he wants to walk.
The velocity used to move the player is determined by:
the angle he is, multiplied by (acceleration * time) or in my game (5.0 * time)
How can I assume a velocity of 1,1,1 always...or for that matter a velocity of 10,0,5...the movement would be so messed up...each step move 10 down the x and 5 down the z....
If the player pushes 'W' - - means he wants to move forward at whichever angle he is facing.
The force pushing on the player is now a directional vector.
That vector would have to be calculated like this
UnitVelocity.x = cos(angle);
UnitVelocity.y = 0;
UnitVelocity.z = sin(angle);
UnitVelocity is now a vector which would take the unit 1 step in the angle it is facing.
To simply move the unit relevant to time and speed we:
UnitVelocity = UnitVelocity * (acceleration * timeDelta);
Now we have a Vector which represents the unit velocity.
This vector has a direction, a direction based on the angle the unit wants to walk. It contains the velocity of the unit as well.
I do not understand how I can apply a force of (1,0,0) or (1,0,1) and expect things to EVER work.
Halsafar
Jan 11th, 2005, 01:12 PM
Va = (0.05, 0, 0.05);
t = 35;
Vu = (0,0,0);
Vo = Vu + (Va * t);
Vo = (0,0,0) + (0.05, 0, 0.05) * 35;
Vo = (1.75, 0, 1.75);
Is that my velocity vector?
I can then go
Player.x += cos(angle) + Vo.x;
Player.y += 0
Player.z += sin(angle) + Vo.z;
Is this what you are all trying to say???
Halsafar
Jan 12th, 2005, 03:00 PM
ur all leavin me hangin.
NoteMe
Jan 14th, 2005, 04:39 AM
I still don't get why you are trying to do it that way. Use a Zero vector for the "angle", forget about normal angles...thats just a dull way to do it. Then you can rotate it using rotation matrices. And you can find the magnitude with your formula. Then you have everything.
Speed and Direction
I am not sure what Velocity would be in all this in Norwegian. Sorry for my English knowledge...
Halsafar
Jan 16th, 2005, 09:57 AM
LoL. I see your point.
Hmmm, I haven't thought much about what to do when the player is rotated.
I also didn't think about usnig a matrices for movement...in fact I guess my math skills at this stuff is still somewhat primitive.
But the velocity vector I am looking for is the vector which would displace the original position to the new position. So it is simply calculated by
vVelocity.x = cos(angle);
vVelocity.z = sin(angle);
m_fVelocity = Speed * Time;
vVelocity *= m_fVelocity;
Now I have a vector representing direction, speed; In fact this works just fine and my collision detection is now working nearly perfect.
I still gotta work out sliding though so I'll go over hills and such.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.