#### Archived

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

# <---- Do you see this face?!

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

## Recommended Posts

Well it''s red and mad because nobody replied to my question about "Frustrums and DotProducts" Doesnt anybody know the answer to this?? So, I will narrow down and redefine my question. Im doing frustrum culling...and I know 3 things. 1) my camera position. 2) my camera''s direction vector. 3) my frustrum''s FOV (60 degrees) Now i''ve tried dotproducts and arcCosines to get angles and stuff. But the results seem to be wrong. So here are my uncertainties: 1) Doing an arcCosine on angles gives me anywhere from 0 to 2 degrees (or could it be radians?). 2) Each component (x,y,z) of my camera''s direction vector are anywhere from 0 to 1, and never greater. Is this correct? thanks. I would appreciate any response! ~ I''''m a wannabe programmer ~

##### Share on other sites
if it is in rad and you want it in degrees
just multiply it by 180 and divide it by pi

do a small test program (console or dos app) to see what the function does. it will make your life much easier

Beer - the love catalyst
I didn''t answer because I wasn''t sure exactly what you were asking.

The acos function in C along with all the other trig and inverse trig functions are in radians. So the range of acos is 0 to pi. You can check that by getting the acos of -1 and 1. asin ranges from -pi/2 to pi/2 and has the same domain. atan ranges from -pi/2 to pi/2 and has a range from negative to positive infinity. atan2 on the other hand has a full 2pi range and takes two parameters each of which can range from negative to positive infinity. That is the real function and on a computer you don''t actually have negative and positive infinity. Instead you have a max and min.

The dot product is the sum of the products of each individual component. So (x1,y1,z1) * (x2,y2,z2) = x1*x2 + y1*y2 + z1*z2. Given two vectors v1 and v2 it is also |v1|*|v2|*cos(theta) where theta is the angle between them. So cos(theta)=(v1*v2)/(|v1|*|v2|). |v1| is the magnitude or length of the vector, i.e. sqrt(x^2+y^2+z^2). The camera direction vector is a unit vector. Its length is one. So yes the maximum any single component can be is one when the other two are zero. The camera direction vector is a unit vector for a reason. The reason is the second form of the dot product. If the magnitude of both vectors is one then the dot product is the cosine of the angle between them. The angle between them is measured in terms of puting the tales of the vectors together. It is the smallest angle between them. So the angle between a vector pointing down the x-axis and another pointing down the y-axis is 90 degrees, or pi/2 radians, no matter which way they point. Their dot product will be zero because the cosine(pi/2) is zero.

The cosine is positive from zero to 90 degrees and negative from 90 to 180 degrees. That is the key to visibility testing. You can see a surface pointing towards you, you cannot see a surface pointing away from you. A surface points toward you if its normal is less than 90 degrees off of a vector from the camera to a point on the surface if you are using perspective projection. If you are doing an orthographic projection it is just the cameras direction, i.e. you cannot see the equator or anywhere near it standing at the north pole. Rather you can only see about a mile at an elevation of six feet above the surface. You find the normal of a flat surface by taking the cross product of a vector from one vertex to another with a vector from the same vertex to yet another. A X B is generally not equal to B X A so order matters. You either go clockwise or counter clockwise around the polygon depending upon whether you are in a left or right handed system. If you get it wrong only the surfaces facing away from you are visible.

Now graphics terminology isn''t a strong suite for me so I''m not sure what culling includes. I do know you have three types of surfaces you can''t see. One type faces away from you so you can''t see it. Another is obscured by another surface. The third is outside the view frustrum. Hidden surface removal is what you use the dot product for. Obscured surfaces are best done with a depth buffer. Basically every time you start to draw a pixel on the screen you check if the z value for that point is in front of any pixel you may have previous drawn there. Otherwise you have to project edges of one polygon onto any other polygon that might be behind it and then create a new polygon for the obscured on. As far as I know that is prohibitively expensive to actually do except perhaps in an extremely simple scene. The same is true of objects that fall outside the frustrum because it may not be completely outside the frustrum, but it isn''t nearly as expensive. You can do line segment/plane intersections and cut off the parts that fall outside the frustrum. Alternatively you can just do that after you have projected the points, but I believe by then you have done much of the work. With a wireframe that might not make much differance, but I believe with lighting and texture mapping you end up doing a lot of wasted work. I can''t swear to that though.

##### Share on other sites
Dude.
Theres such a things as editing your post.
I don`t know much about software graphics, but seeing your confrontational post topic makes me simply want to totally dis you.
So next time, dont get pissed off, k ?

##### Share on other sites
Who...are you talking to me?
I wasnt trying to make my post confrontational, I thought it was rather funny, but then again, such posts are usually misinterpreted.

Anyway, the fact that cos and acos returns radians is a big help!

thanks!

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631781
• Total Posts
3002314
×