Jump to content
  • Advertisement

Archived

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

hammerstein_02

The maths behind 3D

This topic is 5782 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

Ok, I have been looking for a few weeks now, reading tutorials and trying to understand the maths behind 3d. I have read the 3D Black Hole tutorial, I have read the primers and stuff on this site.. but I think I have a problem.. I am stupid. I can''t understand them and don''t want to go further into them into matrices and everything because I don''t understand the vector stuff. I know that a vector has two values and defines direction and magnitude (??) Thats about all I can understand.. The tutorials all seem to move onto dot products and vector addition and subtraction before I fully understand them. What I need is a practical, simple example of what vectors are, how they apply to 3d and quite simply somewhere to start. I don''t want to even attempt to understand Direct3D or OGL until I know the simple maths stuff.. I never did this stuff in school, and it has been 7 years since I even looked at equations and stuff so what I am asking is quite simply HELP! This is not a school project.. this is a simple personal goal.. and its annoying me.. I need to understand it but don''t know how to gain my understanding. I assure you all I have read tutorial after tutorial on this and I can''t find anything.. i have scoured google and ask and altavista to try and find something to explain it to me.. please help.. I feel really dumb! =*= If things seem bad, think that they can get a whole load worse, and they don''t seem so bad anymore =*=

Share this post


Link to post
Share on other sites
Advertisement
Vectors are just a representation of a point in three dimensions (because obviously, we live in a 3D world)

You can describe any point in 3D space with 3 coordinates, and they are normally called x, y, and z. When you sit in front of your computer, imagine it this way:

Take the lower left corner of your monitor: that is your x=0, y=0, z=0 point, or as a vector (0,0,0).
Now look to the bottom right of the monitor. Depending how large your monitor is, it''s going to be about 15" to the right (which is the positive x axis). So that point is (15,0,0)

The top left point is along the positive y axis, some odd 12" or so. So that point is (0,12,0).

Now comes the first important step - what is the coordinate of the top right corner? Well, it''s 15 to the right and 12 to the top, or (15, 12, 0). But we can get that from a simple addition as well:
(0,12,0) + (15, 0, 0) = (15, 12, 0) (in an addition, you add every component separately)

When you look at the back of the monitor then, you go along the positive z axis, and you may end up at a point (0, 0, 17) (bottom left in the rear) or (15, 12, 17) (top right in the rear)

It''s hard to describe it in words, but I hope you got some idea now. Transformation through matrices is a lot harder to grasp...

Share this post


Link to post
Share on other sites
I thought vertices represented a point in 3d space.. now I am really confused.. I get the explanation, I can understand that we work in 3 dimensions, I just can''t understand how the points work.. I can''t understand the basics..

=*=
If things seem bad, think that they can get a whole load worse, and they don''t seem so bad anymore

=*=

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
you might think about getting out a basic maths or physics book from a library. They will prolly explain it better than a website or tutorial thing. Don''t know any of the top of my head...

Share this post


Link to post
Share on other sites
I''ll have another crack at trying to explain it in a different way.

A point in 3d space is defined by 3 values, as you know: (x, y, z)

A vector in 3d space is also defined by 3 values: (x, y, z)

You''re probably thinking, well what is so great about vectors then, they''re exactly the same as points. Well, going from your definiton, vectors actually don''t define just a point in 3d space, they define a direction and magnitude. To explain this:

Take the point (1, 1, 0). Draw it on a piece of paper or something.

Now draw a line between (0,0,0) and this point (1,1,0) and draw an arrow head pointing to (1,1,0).

(1,1,0) is the point, the vector is this line with the arrowhead.

See the vector is pointing in a direction. It''s magnitude is the length of the line. (calculated by the distance formula between the points (1,1,0) and (0,0,0)).

Because the vector is this line, we can do a lot of meaningful operations on them. For example rotating the vector by 45 degrees will make it point straight up the y axis. It doesn''t make any sense to rotate a point, it will still lie at the same spot.

I hope that helps a bit. I didn''t do an vector math in school, so when i started to learn it by myself i remember having the trouble with what was the difference between a point and a vector, what do vectors do, all that stuff.

If u understand the above, then the next best step is probably to start learning about some operations like vector addition and subtraction. Even if u don''t fully get what i''ve written, then drawing the operations out on paper as you learn them may help to visualise vectors and understand them more and more.

Share this post


Link to post
Share on other sites
that's because a vector means more than one thing, position vectors and just plain vectors. A postio vector obviously is a point in space refering to a certain point in space, say 0,0,0 which is 0i+0j+0k in vector format. A standard vector is the directiony thingy. we'll take a point in space as P whihc is say 1i+1j+1k. the vector OA o being the origin is 1i+1j+1k as its the distance travelled from O to P. the magintude of the vector is the size of the vector. In 2d for example :

whoops they aren;t happy with ASCII art

and can be calculated using pythagarous(spl??) mag^2=i^2+j^2.


oh just to clarify there are several types of coordinate systems, two ones we are concerened with, cartesian and vector(and parametric but no one care about that ) cartesian is in(x,y,z) whilst vector is usually taken in the form (i+j+k)

[edited by - Foobat on November 19, 2002 10:21:04 AM]

[edited by - Foobat on November 19, 2002 10:24:28 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
read this: http://www.cfxweb.net/~cfxamir/tutorials.html

Share this post


Link to post
Share on other sites
Sorry to be pedantic but that tutorial is wrong

"All vectors must start at the origin (0,0,0)"

which is in correct for example you have 2 position vectors A and B with position vectors 1i+1j+1k and 4i+4j+4k respectively. The vector AB clearly does start not from the origin. the vecotr AB is AO+OB. seee....


[edited by - Foobat on November 19, 2002 10:46:19 AM]

Share this post


Link to post
Share on other sites
Ill have a go at explaining vectors. Basically the vectors used in 3D rendering math are called cartecian vectors. Which means a vector can be defined by a x,y,z. So your probably thinking this is a point, to explain the diffrence ill give an example.
imagine the point <0,0,1>
and the vector <0,0,1>

the point is an actual point in space ( duh ), but the vector is actully pointing down the z-axis ( into the screen )so thats it direction. Its magnitude is is of 1.

Ok you know what a vector is now, ill show you the way I think of them. Now were gonna go to 2D to explain this. Let say you have the point <5,9> . You can draw a line to that point to show the vector. You relize that 5 means 5 points across the x-axis & 9 points up the y - axis. Draw lines from this point and you''ll have a triangle. when you hear right-angle triangle you should think trignometry & pythagoras theorem. By making it a triangle you can rotate the vector by doing this:
rember
sin=opposite/hypotenuse, cos=adjacent/hypotenuse
hypotenuse^2 = a^2 + b^2 // Pythag theroem

therfor the hypotenuse for the <5,9> vector is:
=sqrt( 5^2 + 9^2 )
=sqrt( 25 + 81 )
=10.3

if you look back at the triangle I asked you to make that actully gives the magnitude of the vector. Now that you know the magnitude/hypotenuse you can rotate the vector using trig:
NewX=cos(RotationAngle)*10.3
NewY=sin(RotationAngle)*10.3

and that will rotate it anyway you want. The only other thing left is translation which is a simple:
NewX=x+translationX;
NewY=y+translationY;

Moving to 3D is just adding another dimension. If you ever get stuck take the equation down to 2D (ignore Z). If your stuck on that try 1D(ignore Y).

I hope this helped. I know it was alot. It would really be much better with pictures. If you really don''t get it I could write a little 1 page tutorial with pictures , but have a go at it. What I recon you should do is try make a 2D engine which just invovles having rendering 2D shapes rotating them and translating them.

WizHarD

Share this post


Link to post
Share on other sites
Right.. forgive me if I am really not getting this.. And you guys have been more help than I ever could of wished for so far. Thank-you, very much appreciated, all of you.

If I have a point,

4,4 and there is another point 10,6

the vector there is 6,2 , yes? because the vector, if relative to 4,4 would be the movement? Do I understand that correctly. The other values are vertices. So, being able to work out the length of the vector

sqrt(6 * 6 + 2 * 2)

What does that help me with? How does knowing how to manipulate that help me? What can getting the length of the vector help me with? I suppose I am just asking because I think that by asking questions you learn. And you guys all know what you are talking about. Thanks very much for the assistance.

=*=
If things seem bad, think that they can get a whole load worse, and they don''t seem so bad anymore

=*=

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!