The maths behind 3D

Started by
45 comments, last by hammerstein_02 21 years, 4 months ago
Vectors are damn hard to understand so don''t worry if you aren''t getting it. The main problem with them is they are used is so many diffrent situations that it is hard to understand which context its in.

Scalar = value
Vector = value + direction

For physics context here is a simple example:
speed = scalar eg 200 m/s or 200ms^-1
velocity = vector eg 200 m/s or 200ms^-1

now your probably thinking wtf, there the same & how the hell does the velocity have a direction ? The thing is the velocity vector is 1D ( so there is only 1 inifte axis on the graph ).
Now if you ask someone how fast there going & they say -100ms you think what the hell are they going on about you can''t have a negative speed even when your reversing your speed is still postive.
But since velocity is a vector it can be negative, the fact that its negative or postive is what is stating its direction. Negative means to the left & postive means to thr right. Velocity can be used for collsion for example two cars hit each other directly:
car1 velocity = -100m/s
car2 velocity = 200m/s

so when they collide the cars will pushed to the right 100m, In 1D its quite simple to see that. When you move to 2D you use two seprate 1D vectors. 1 for the x-axis & 1 for the y-axis and the angle between them is theta. But when you break down to it its just a collection of 1D vectors so is 3D.

who is it that keeps on nicking WizHarD name !! :P
Advertisement
In my previous post I meant magnitude not value !
who is it that keeps on nicking WizHarD name !! :P
quote:Original post by WizHarDx
car1 velocity = -100m/s
car2 velocity = 200m/s

so when they collide the cars will pushed to the right 100m.


I''m pretty sure that''s not correct. Two cars colliding together requires more than just vector addition of their velocities. Their final velocities are dependent on their masses, their momentums and their energy. To find the final velocities for a questio such as that, you need to equate the momentums of the two cars for before and after(using equations m1v1 + m2v2 = m1v1'' + m2v2''). Their final velocities will be the same however, because they are inelastic collisions, so solving for the final velocity would be basic.
right, the main problem we are all having here is that we do not differentiate between

scalar and vector QUANTITIES
POSITION vectors
plain old vector
vector EQUATIONS OF A LINE
if you like programming, you like maths, you just don't know it yet
Apocalypse_Demon i was trying to show a simple example of vectors its obviously not real world physics or it would use 3D vectors first. You can''t exactly apply gravity to a 1D vector you would at least need another dimension
who is it that keeps on nicking WizHarD name !! :P
Ok here is an application problem of vectors.

If your making a 2d space game where you fly around I would store values like this.

VECTOR position(2,4);
VECTOR direction(4,2);
VECTOR acceleration(-2,-1);

So I''m position (2,4) in space. I then move in the direction (4,2)

so (2,4) + (4,2) = (6,6)

my new position is at (6,6) in space. Now I don''t have thrusters on anymore so I''m slowing down hence the acceleration.

direction(4,2) + acceleration(-2,1) = direction(2,1)

so now I''m moving again but this time when I move I add my new direction value.

position(6,6) + direction(2,1) = position(8,7)

So what has happened in my game is the ship is moving up and over to the right, but each frame it slows down. When the direction == 0 I will stop adding acceleration to it.

Same with if I was speeding up with the ship, instead of adding a negative acceleration to the direction I would add a positive, direction and probaly stop at a value like (10,10) because our ship can only go so fast.

This is how I use vectors in my games, and I hope this real world example helped clear things up.
Do you know what a scalar quantity is? You sure do! You''ve probably used it all your life. My weight is 120 pounds, or I''m 150 cm tall. These are scalar quantities in that they only have a magnitude and unit, it being 120 and pounds, and 150 and centimetres respectively.

Vectors, on the other hand, have a magnitude, direction, and unit (in most cases). Let''s look at the weight example. A weight of 120 pounds is a scalar quantity, and can be written as 120 Lb. Now, to convert this to a vector, we add a direction, to make it 120 Lb [Down]. Your weight is acting downward on the scale.

Now, let''s look at the two-dimensional Cartesian plane. A vector quantity can be expressed using polar coordinates very easily, and this good for you to start with, so you can get the math down.

The polar coordinates look like this:

90
180-|-0
270

That is, vertically from your starting point is 90 degrees. Horizontally to the right is 0, to the left is 180, and down is 270 degrees.

So we can define a vector like this: Quantity Unit [Direction]

Ex.

180 N [90] (Up)
267 Lb [180] (Left)

The best way to visualize a vector is a force. Say you''re pushing a book sideways on the desk. You''re applying a force both horizontally and vertically, and the resultant force is the vector in the direction the book is moving in.

To find the force you''re applying horizontally and vertically, you find the components of the vector, by using trigonometry:

If our resultant vector is 150 N [45], then we can find the horizontal and vertical components:

150 Cos 45 = 106 N (Horizontal)
150 Sin 45 = 106 N (Vertical)

We can check this using the Pythagorean theorem: 106^2 + 106^2 = 150^2.

This is a very basic introduction to vectors, but you have to start somewhere. There is no point into going into 3D vectors defined using rectangular coordinates if you don''t even know what a vector is!
[email=ubc_wiskatos@hotmail.com" target="_blank" style="width: 10px; height: 10px; background: #fe7a21; overflow: hidden; display: block; margin-bottom: 2px;][/email]Wiskatosxp

This topic is closed to new replies.

Advertisement