Results 1 to 16 of 16

Thread: Vector me This

  1. #1

    Thread Starter
    Member Chipcrap's Avatar
    Join Date
    Mar 2001
    Posts
    52
    OK this is a VERY basic question. A vector is a line on a graph representing something (Velocity, Displacement, ect...). Which is the best way to define a Vector:

    1. Vector1 = (x1,y1,x2,y2) or

    2. Vector1 = x1,y1, degree, magnitude


    I working on a basic physics sim, so which would be easier? Or are both fine? Or are both wrong?

  2. #2
    Addicted Member Shrog's Avatar
    Join Date
    Aug 1999
    Location
    Darkest Africa
    Posts
    186
    Both are fine from a design principle point of view, but neither are syntactically correct for VB.

    How are you planning to do it in VB?

    Shrog
    VB6 Ent SP5
    Win2000

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    not really, a vector is a one value per dimension measurement, therefore a line can either be a position vector and a offset vector or two position vectors. The second is more commonly used for lines, but since you use velocity, which is derived from displacement, you should use an offset vector.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4

    Thread Starter
    Member Chipcrap's Avatar
    Join Date
    Mar 2001
    Posts
    52
    Kedamin- Using your example, say I had Rock at XY Location 0,16 (Y Being Verticle Axis). I want to find out the rocks location in Realtime using Gravity. At time 0 the rock is 16 meters high. So could I use the following 2 vectors to determine rocks position using a calculation based on time elapsed?:

    Dim Rock as Vector
    Rock.X=0
    Rock.Y=16

    Dim Gravity As Vector
    Gravity.X = 0?
    Gravity.Y = -9.8

    Do those two vectors look right? I'm not so sure about the Gravity. THANKS!

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    yes, if the first is suppose to be a displacement and the second, gravity. gravity though is acceleration and derived from velocity, so displacement is velocity*time+0.5*acceleration*time^2
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6
    Hyperactive Member
    Join Date
    Mar 2001
    Location
    Calgary, Canada
    Posts
    453
    Just to throw in my two pennies, you could have a class Vectore which handled bot the 2 point vector and the 1 point, angle/magnitude.

    Changing one set of parameters would automatically change the other.

    e.g.

    Vector1.x1=0
    .y1=0
    .x2=1
    .y2=0

    Reading the .angle for this would give 90 (if working in degrees) and .magnitude would give 1

    Changing .angle to 0 would change .x2=0 and .y2=1 (assuming 0,0 is bottom left).

    I don't know if this helps matters,

    SD
    "I'd rather have a full bottle in front of me than a full frontal lobotomy!"

  7. #7

    Thread Starter
    Member Chipcrap's Avatar
    Join Date
    Mar 2001
    Posts
    52
    OK So I have:

    Private Type Vector
    x As Double
    y As Double
    End Type

    Private Type xyObject
    Displacement As Vector
    Velocity As Vector
    End Type

    Dim Rock As xyObject
    Rock.Displacement.x = 0
    Rock.Displacement.y = 16
    Rock.Velocity.x = 0
    Rock.Velocity.y = 0
    Dim Gravity As Double
    Dim Time As Double

    CurrentVel = Rock.Velocity.y + (Gravity * Time)
    CurrentY = Rock.Displacement.y + ((CurrentVel + Rock.Velocity.y) / 2 * Time)

    It works, but I'm not sure if it is right. Do these equations look right?

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Are you operating in 2 dimensions at all? because otherways drop the vector concept and work with scalars
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9

    Thread Starter
    Member Chipcrap's Avatar
    Join Date
    Mar 2001
    Posts
    52
    LOL! Yes-eventually---I want to simulate an object falling straight down first, and then when I get that right I'm going to add an x direction, and then a Z. So do those look right?

  10. #10
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    well not really, youre a bit incosistent, having scalar results, are you just doing an analysis or is this a simulation?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  11. #11

    Thread Starter
    Member Chipcrap's Avatar
    Join Date
    Mar 2001
    Posts
    52
    It's a simulation

  12. #12
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    then you have a loop or a timer procedure in which you
    1. add acceleration to velocity
    2. add velocity to displacement
    and vector addition is done by adding each component .x+.x and .y+.y and so on
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  13. #13

    Thread Starter
    Member Chipcrap's Avatar
    Join Date
    Mar 2001
    Posts
    52
    Like so:

    Do Until Rock.Displacement.y < -0.01
    Time = modPhysics.GetTime(False) 'This tells how much time has passed since last loop.

    Rock.Velocity.y = Rock.Velocity.y + (Gravity * Time)
    Rock.Displacement.y = Rock.Displacement.y + ((2 * Rock.Velocity.y + Gravity * Time) / 2 * Time)

    Loop

    I got those EQ's out of a physics book and they seem to work. I just don't get why you have to add Gravity*Time to the Rocks Velocity in both EQ's. Is this what you mean?

  14. #14
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    more like

    Rock.Velocity.y = Rock.Velocity.y + Gravity
    Rock.Displacement.y = Rock.Displacement.y + Rock.Velocity.y

    assuming one time unit per loop, where time unit is the measurement for velocity mt^-1 and acceleration mt^-2
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  15. #15
    Hyperactive Member
    Join Date
    Mar 2001
    Location
    Calgary, Canada
    Posts
    453
    Originally posted by kedaman
    Are you operating in 2 dimensions at all? because otherways drop the vector concept and work with scalars
    Mmmmmmmm, yes, but wouldn't this be a contrarian approach?

    SD
    "I'd rather have a full bottle in front of me than a full frontal lobotomy!"

  16. #16
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    maybe sD .p
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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