Sign in to follow this  
lordmetroid

Raw Basic 3D theory, please help...

Recommended Posts

lordmetroid    122
I'm currently coding for an hardware without any 3D acceleration nor possibility to utilize such an API. However it was probably 1.5 years ago since I did anything in 3D and now I can't recall the basic 3D mathematics. Quite disturbing actually. First of all I have problems understanding what a Cross and Dot product really calculates. To discover whether a polygon is facing towards the camera or not. I know I should calculate the normal for the polygon but how shall I check that normal with the camera direction? Furthermore it has slipped my mind if I need to sort the vertices on a polygon depending on y-coordinates before I start calculating the edge's slopes and set initial values for the scan conversion to begin from. From my previous work it doesn't seem I have but it could be some kind of optimization I have forgotten about. I really appreciate if someone could help me solve these out and show me how it is done explaining the process as I'm so lost at the moment.

Share this post


Link to post
Share on other sites
haegarr    7372
Quote:
Original post by lordmetroid
First of all I have problems understanding what a Cross and Dot product really calculates.

What do you mean with "really"?

The cross product
v' := v1 x v2
computes the vector that
(a) is perpendicular to both of the argument vectors
v' . v1 == 0 (see dot product below)
v' . v2 == 0 (see dot product below)
(b) has a length equal to the area of the diamond spanned out by the argument vectors
||v'|| == ||v1|| * ||v2|| * |sin( <v1,v2> )|
(c) with a right handed orientation (i.e. in order v1 thumb, v2 forefinger, v' middle finger of the right hand).

The dot product
s' := v1 . v2
computes the scalar that is equal to
||v1|| * ||v2|| * cos( <v1,v2> )
Assuming that both arguments are not of zero length, then the resulting scalar gives some information about the angle between them:
s' > 0 : the angle is less than 90°
s' < 0 : the angle is greater than 90°
s' == 0 : the angle is exactly 90° (perpendicularity!)
s' == s'max = ||v1|| * ||v2|| : the angle is 0°
s' == s'min = -||v1|| * ||v2|| : the angle is 180°

The absolute value |s'| can be understood as the length with which the one argument vector is projected onto the other argument vector. Or, in other words, its the length of the one argument vector in direction of the other argument vector. This property is often used to find the decomposition of a vector in its parallel and perpendicular parts w.r.t. a reference vector.


Quote:
Original post by lordmetroid
To discover whether a polygon is facing towards the camera or not. I know I should calculate the normal for the polygon but how shall I check that normal with the camera direction?

See the explanation belonging to the sign of the scalar resulting from the dot product above.

[Edited by - haegarr on November 7, 2006 8:36:03 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this