Advertisement

Vectors?

Started by January 10, 2003 10:02 PM
5 comments, last by Tazel 22 years, 1 month ago
I know a vector holds the velocity/speed and direction of an object. But can you explain to me the properties of a vector? Or give me a nice easy site on the topic? I already have googled and everything is in the level of 11th graders and up.
tcache Contact Me ----------- AH! MY BRAIN IS GOING TO SELF-DETONATE! -- Yours Truly (Jan, 2003)
tcacheContact Me-----------AH! MY BRAIN IS GOING TO SELF-DETONATE! -- Yours Truly (Jan, 2003)
Hey there Tazel. A vector doesn''t have to define a velocity in a certain direction. Think of a vector as having a certain magnitude and a direction. There are special vectors called unit vectors that are basically vectors with a magnitude of 1.

The major properties of a vector are the dot product and the cross product. The dot product tells the user how far apart the vectors are in terms of the angle in between them. The cross product is slighting more complicated, but still fairly easy. The cross product of two vectors gives you a vector perpendicular to the plane that they are both on. Imagine that you have the two vectors layed down flat on a table top. If you take the cross product of those two vectors you will get a vector that is going straight up from the table surface. The cross product of two vectors essentially produces a normal to the plane they are on. A normal is a vector perpendicular to a plane.

This stuff isn''t your standard algebra and what not. This stuff is hard and I just started getting into it. These basic definitions are a piece of cake, but the applications can get really crazy.

I hope my explanations helped.

- HalcyonBlaze
"Computers in the future may weigh no more than 1.5 tons."- Popular Mechanics, 1949
Advertisement
A vector is an n-dimensional collection of quantities. Most often when we talk about vectors with regard to computer games, we''re talking about 3D vectors, which can represent many things. Your average vector is composed of three values, one for each axis (x, y, z). If a vector represents a location, these numbers are the "distances" of the point''s components from the origin. For example, the point <3, 4, 5> is 3 units from the x axis, 4 units from the y axis, etc. However, the length (aka magnitude) of the vector is sqrt(50), or approximately 7.07.

Vectors can be used to represent location, velocity, acceleration, and other things, ...

Ehh, it''s getting late. Read these:
(1)
(2)
(3)

Later,
ZE.


//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[twitter]warrenm[/twitter]

*cough*

Death of one is a tragedy, death of a million is just a statistic.
If at first you don't succeed, redefine success.
So check this theory:

A Pong game.

The purpose of a vector for the ball is this.

The ball is traveling until it hits a paddle or it passes it''s magnitude. If it hits a paddle, it''s direction reverses and it''s magnitude is squared. and it does this again and again until it passes someone?



tcache
Contact Me
-----------
AH! MY BRAIN IS GOING TO SELF-DETONATE! -- Yours Truly (Jan, 2003)
tcacheContact Me-----------AH! MY BRAIN IS GOING TO SELF-DETONATE! -- Yours Truly (Jan, 2003)
Can you define "passing magnitude"?

When writing a simple Pong game, it''s best to use 2 2D vectors to represent the ball''s state: one for location, and one for velocity (direction*speed). Each frame, you add the velocity to the position to get the new position.

For horizontal collision, you check if the x coordinate of the ball (plus its radius) is greater than the x coordinate of (for example) the right paddle. If so, you negate the x coordinate to make it appear to "bounce" off the paddle. Oh-la-la.

Likewise, you simply compare the proper coordinates to the bounds of your arena and the other paddle faces, reversing directions in a single axis where necessary.

"magnitude is squared"? the magnitude of the velocity will remain constant if the ball is moving at a constant speed. The magnitude of the position is irrelevant.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[twitter]warrenm[/twitter]

Advertisement
Here is another good link ...........

http://www.flipcode.com/geometry/

This topic is closed to new replies.

Advertisement