Results 1 to 25 of 25

Thread: Velocity Vector

  1. #1

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    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

  2. #2
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Velocity Vector

    Velocity vectors in games are often just a zero vector.

  3. #3

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    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

  4. #4

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    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.= (m_VectorCircle[m_Angle].m_Velocity) * (m_VectorCircle[m_UpAngle].u);
    m_vVelocity.= (m_VectorCircle[m_UpAngle].m_Velocity);
    m_vVelocity.= (m_VectorCircle[m_Angle].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

  5. #5
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Velocity Vector

    Quote 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.

  6. #6
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    703

    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!
    an ending

  7. #7
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Velocity Vector

    Quote 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.

  8. #8
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    703
    an ending

  9. #9
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Velocity Vector

    Quote 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...

  10. #10
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    703

    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
    an ending

  11. #11
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    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.

  12. #12
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    703

    Re: Velocity Vector

    I'm not at all offended
    I just think the term "zero vector" doesn't really help here.
    an ending

  13. #13
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Velocity Vector

    Well, you can call it what ever you want. But that is how it is done in game programming...

  14. #14

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    Re: Velocity Vector

    Quote 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
    Quote 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

  15. #15

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    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

  16. #16
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Velocity Vector

    Quote 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.


    ØØ

  17. #17

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    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

  18. #18

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    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

  19. #19
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    703

    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.
    an ending

  20. #20
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Velocity Vector

    Quote 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.

  21. #21

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    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

  22. #22

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    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

  23. #23

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    Re: Velocity Vector

    ur all leavin me hangin.
    "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

  24. #24
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    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...

  25. #25

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    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
  •  



Click Here to Expand Forum to Full Width