noatom 927 Report post Posted June 29, 2013 I know that you can find it a polygon is facing the camera using that method.You need the polygon normal and the position of a vertex on that polygon.I don't remember more. Can someone explain with details,and maybe some drawings? Thanks 0 Share this post Link to post Share on other sites
Brother Bob 10344 Report post Posted June 29, 2013 (edited) You take the dot product of the normal and the vector between the viewpoint and one of the vertices. A negative dot product means the side of the polygon in the direction of the normal is visible from the view point. Edited June 29, 2013 by Brother Bob 0 Share this post Link to post Share on other sites
Paradigm Shifter 5832 Report post Posted June 29, 2013 (edited) If you do the dot product of the normal and the vector from the camera to a point on the polygon it will be negative if they are facing in opposite directions, which means the polygon is facing the camera. Dot product positive -> vectors are facing same direction (within 90 degrees each way) Dot product negative -> vectors facing different directions Dot product 0 -> vectors are perpendicular You can also use the z-component of the cross product of polygon edge directions in screen space to check if the polygon is back facing. EDIT: My first answer was incorrect, edited now. Edited June 29, 2013 by Paradigm Shifter 0 Share this post Link to post Share on other sites
frob 44911 Report post Posted June 29, 2013 (edited) I know that you can find it a polygon is facing the camera using that method. Can someone explain with details,and maybe some drawings? There are several formulas to define a dot product, just like there are several formulas that can define a line. One of those formulas is: DotProduct = |A| * |B| * cos(AngleBetweenAB) The dot product equals the magnitude (length) of the first vector, times the magnitude of the second vector, times the cosine of the angle between the two vectors. If both vectors are normalized (length = 1) they drop out of the equation. So if we have normalized vectors A and B: DotProduct = cos(AngleBetweenAB). If you remember from the definition of a cosine, angles between -90 degrees and 90 degrees are all positive, with 90 and -90 being exactly zero. So if one vector is pointing forward and the dot product is positive, the second vector is also pointing forward. It might only be a tiny bit forward, but it is still at least partially forward. The opposite is also true: if one vector is pointing forward and the dot product is negative, the second vector is pointing backwards. It might only be a tiny bit backward, but it is still at least partially backward. And since for the normalized angles DotProduct = cos(AngleBetweenAB), that means you can undo the cosine: AngleBetweenAB = arccos(DotProduct) Sorry no pictures, but I hope that clears it up. Edited June 29, 2013 by frob 0 Share this post Link to post Share on other sites
Paradigm Shifter 5832 Report post Posted June 29, 2013 If you are just testing relative facing (towards/away from/perpendicular) you don't need to normalise, all that matters is the sign (+ve -> facing same way, -ve -> facing opposite way, 0 -> perp). 0 Share this post Link to post Share on other sites
noatom 927 Report post Posted June 29, 2013 Ok,got it: If you are just testing relative facing (towards/away from/perpendicular) you don't need to normalise, all that matters is the sign (+ve -> facing same way, -ve -> facing opposite way, 0 -> perp) But I still have problems visualizing the test.For example: What I think happens is: Obviously,my thoughts are wrong,but can someone say where and why? Thanks 0 Share this post Link to post Share on other sites
Brother Bob 10344 Report post Posted June 29, 2013 The angles you measure in for the two polygons have different references. Notice how on the left side the angle is measured between the normal and the red line, while on the right hand side the angle is measured between the inverse of the normal and the red line. 0 Share this post Link to post Share on other sites
noatom 927 Report post Posted June 29, 2013 You ment the inverse of the normal and the blue line right? 0 Share this post Link to post Share on other sites
Brother Bob 10344 Report post Posted June 29, 2013 The angle is between the blue line and the red line. I thought the blue line was the extended normal from the origin since that is what you measured the angle from and not the black line itself. What are the red and blue lines then in your picture, just to make sure we're talking about the same thing. 0 Share this post Link to post Share on other sites
Burnt_Fyr 1665 Report post Posted June 30, 2013 Your angle measurement is a misinterpretation. Think of the vectors as free vectors, not localized.Now imagine both vectors(the normal and the camera to vertex vector) with their tails attached. The polygon on the left has a normal pointing away from the blue vector. If you do the same on the right, you can see they point the same direction. 0 Share this post Link to post Share on other sites