Archived

This topic is now archived and is closed to further replies.

Struggling to understand

This topic is 5747 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

It''s time for me to suck it in, and swallow my pride! Been *scouring* GD.net, & flipcode.com, & planetsourcecode.com random coding sites & even DK encylopedia of science! And I still can''t grasp that which the rest of you seem to have! It boils down to this question... Why do we use Vectors in 3D engines? More precisely... - I have a clear understanding of Vectors in a mathematical sense. - I can imagine how (in many ways) I could implement them into a programme. (Two points, one for the head one for the tail, a Point + 3d angle + module, and other methods) - Why would you need to *know* the direction of a point in 3D space (other then a few, i.e. normals, raytraces) But why also Vertexs? - I read somewhere that all Vectors extend from the origin?!? (which origin?) There are many other questions but i think these are the important ones... ANY help from anyone who could help the penny drop would be greatfully appreciated. Maybe then i can tackle Matrix math!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Vectors come in handy for things like camera operations (you need to know which way the camera is facing) and lighting. As far as vectors extending from the origin, I think that''s just your usual x,y,z origin, I''m not sure what other origin you could be talking about (polar? spherical? cylinderical?), but an easier way to think about it (I think) is that you can break vectors down into components, one representing each direction (x, y and z). Have you heard of i hat, j hat and k hat (where the hat is ^ over each letter)? That''s a vector broken down into it''s components and essentially that''s what the idea of vectors extending from the origin comes from. Hmmm maybe I just made that more confusing... sorry...

Share this post


Link to post
Share on other sites
When I wrote a simple 3D renderer long ago, I started with a left(x), up(y) and forward(z) vector that represented the screen camera.

When I took the vector formed by the camera point to a vertex location, and found the dot product against the x, y, and z vectors, it provided me with the horizontal and vertical offsets from the center of the screen at which to draw the point (after dividing the offset by z - it''s a formula I figured out myself from what I knew about 3D drafting)

This is the simplest implementation of the matrix math you mentioned. The 3D APIs use extensive vector and matrix math in their rendering.

Vectors are also useful for storing an object velocity as it moves through 3D space, object orientations, etc. but that is only for behaviors and physics.

There''s no real way around it. If you want to do 3D programming, you have to learn the vector stuff!

- Waverider

Share this post


Link to post
Share on other sites
Not no more confusing you've just pointed out the major problem,
I cant understand that a (3D) vector in maths has the usual XYZ components but that defines a vertex not a vector.
That is the what i cant get my head around!

-waverider- are u saying that u can perform the math needed within a 3D transfomation using _just_ vertexs?
This makes sense to me.

[edited by - Ikus on March 20, 2002 2:32:04 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Ikus

Why do we use Vectors in 3D engines?




Because the equations are simpler, basically. They aren''t _needed_ but they are handy.

quote:

More precisely...
- I have a clear understanding of Vectors in a mathematical sense.
- I can imagine how (in many ways) I could implement them into a programme. (Two points, one for the head one for the tail, a Point + 3d angle + module, and other methods)



Vectors only have one point. When they are drawn, the first ''endpoint'' is always at the origin. Vectors don''t really have a position at all. They''re a direction and a distance. When you treat a point as a vector, it''s really like giving directions _to_ the point, rather than the point itself. This makes rotations and such nice, because you can rotate the direction to each point around an axis, which ''moves'' the points themselves.

quote:

- Why would you need to *know* the direction of a point in 3D space (other then a few, i.e. normals, raytraces) But why also Vertexs?



See above. It''s not the direction *of* a point, it''s the direction *to* the point.

Also, by treating _everything_ as a direction, the math/algorithms for dealing with all these things is the same.

quote:

- I read somewhere that all Vectors extend from the origin?!? (which origin?)



The origin of your coordinate system. In 3d graphics, usually x = 0, y = 0, z = 0. This is the standard starting place you give directions from. Kind of like if you were talking about the locations of stores about town, you might give all the directions starting at your house.

Share this post


Link to post
Share on other sites
Okay CheeseGrater its focusing into view now!

So by definition im thinking Vectors in maths are principly *diferent* from the way we use/implement them in our 3d ''world''.
A vector can freely represent a specific XYZ point, and nothing more.
And this (if i understand you) makes your rotation equations easier.
That is making perfect sense so far, i now think i should reread what i have read and apply this *different* way of thinking.

Share this post


Link to post
Share on other sites
(I won't do the quote thing)
You can use a vector to define other things apart from just points, you can use it to define directions: up direction,
facing direction etc.
When I think of a vector I think of an arrow pointing (EDIT from the origin usually (0,0,0).
I hope this helps, I don't know a lot about 3d myself!

[edited by - stevenmarky on March 20, 2002 2:49:32 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Ikus
Okay CheeseGrater its focusing into view now!

So by definition im thinking Vectors in maths are principly *diferent* from the way we use/implement them in our 3d ''world''.



Well, most of the math world defines vectors the same way we use them in graphics. Some authors do use the word to mean different things, though. So be careful as you read.

What you were describing sounds more like the mathematical concept of a ''ray'' (as in a ''ray trace'') which is a starting point and a direction.

quote:

A vector can freely represent a specific XYZ point, and nothing more.
And this (if i understand you) makes your rotation equations easier.
That is making perfect sense so far, i now think i should reread what i have read and apply this *different* way of thinking.


Sounds like you''re getting it.

Share this post


Link to post
Share on other sites
Ka-plunk!
There she goes!

Its all about the relative spaces in 3D, individual objects which have there origin of rotation and also rotate with the world, the world which has its origin for the general roation of everything, and the view/camera origins for thinks like projection and personal origins!

There all that i need to do is implement!
*sigh* always with the implement...
...
...

Thumbs up guys!

Share this post


Link to post
Share on other sites