|
-
Jan 8th, 2005, 06:03 PM
#1
Thread Starter
PowerPoster
Velocity Vector
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.
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
-
Jan 8th, 2005, 06:19 PM
#2
Re: Velocity Vector
Velocity vectors in games are often just a zero vector.
-
Jan 8th, 2005, 06:53 PM
#3
Thread Starter
PowerPoster
Re: Velocity Vector
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...
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
-
Jan 8th, 2005, 07:48 PM
#4
Thread Starter
PowerPoster
Re: Velocity Vector
Is this the velocity vector???
PHP Code:
//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.
Last edited by Halsafar; Jan 8th, 2005 at 07:53 PM.
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
-
Jan 9th, 2005, 04:39 AM
#5
Re: Velocity Vector
 Originally Posted by Halsafar
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
I don't live here any more.
-
Jan 9th, 2005, 08:40 AM
#6
Fanatic Member
Re: Velocity Vector
^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!
-
Jan 9th, 2005, 11:28 AM
#7
Re: Velocity Vector
 Originally Posted by Halsafar
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.
-
Jan 9th, 2005, 11:45 AM
#8
Fanatic Member
-
Jan 9th, 2005, 12:39 PM
#9
Re: Velocity Vector
 Originally Posted by azteched
Thats what math guys calls zero vector....boring math guys calls what we game programmer calls zero vector for free vector...
-
Jan 9th, 2005, 01:48 PM
#10
Fanatic Member
Re: Velocity Vector
Sorry but "zero vector" for "free vector" is misleading - the mathematics terminology makes much more sense. This is the Maths forum anyway
-
Jan 9th, 2005, 03:15 PM
#11
Re: Velocity Vector
But HE is a game programmer, and he asked a game programming question... ....don't be offended. Just trying to resolve the missunderstanding.
-
Jan 9th, 2005, 03:33 PM
#12
Fanatic Member
Re: Velocity Vector
I'm not at all offended 
I just think the term "zero vector" doesn't really help here.
-
Jan 9th, 2005, 04:17 PM
#13
Re: Velocity Vector
Well, you can call it what ever you want. But that is how it is done in game programming...
-
Jan 9th, 2005, 07:37 PM
#14
Thread Starter
PowerPoster
Re: Velocity Vector
 Originally Posted by azteched
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
 Originally Posted by wossname
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.
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
-
Jan 9th, 2005, 07:54 PM
#15
Thread Starter
PowerPoster
Re: Velocity Vector
All I have is the players position, the angle at which he wants to move, the speed as a float.
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
-
Jan 9th, 2005, 08:04 PM
#16
Re: Velocity Vector
 Originally Posted by Halsafar
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.
ØØ
-
Jan 9th, 2005, 08:13 PM
#17
Thread Starter
PowerPoster
Re: Velocity Vector
Can you show a quick example?
Pick any numbers.
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
-
Jan 9th, 2005, 10:32 PM
#18
Thread Starter
PowerPoster
Re: Velocity Vector
All I need is some numbers showing me whats you mean.
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
-
Jan 10th, 2005, 06:12 AM
#19
Fanatic Member
Re: Velocity Vector
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.
-
Jan 10th, 2005, 08:01 AM
#20
Re: Velocity Vector
 Originally Posted by azteched
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.
-
Jan 10th, 2005, 02:27 PM
#21
Thread Starter
PowerPoster
Re: Velocity Vector
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.
Last edited by Halsafar; Jan 10th, 2005 at 02:32 PM.
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
-
Jan 11th, 2005, 02:12 PM
#22
Thread Starter
PowerPoster
Re: Velocity Vector
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???
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
-
Jan 12th, 2005, 04:00 PM
#23
Thread Starter
PowerPoster
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
-
Jan 14th, 2005, 05:39 AM
#24
Re: Velocity Vector
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...
-
Jan 16th, 2005, 10:57 AM
#25
Thread Starter
PowerPoster
Re: Velocity Vector
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.
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|