Finding the Plane in Which a Polygon Triangle Sits

[ LiB ]

Finding the Plane in Which a Polygon/ Triangle Sits

The world in a 3D environment is composed of infinite planes. Now most people don't realize it, but the X, Y, and Z axes create flat planes. These planes sit flat on any two axes at a time. For example, the X and Y axes create a flat plane. This plane is called an axis-aligned plane .

Objects sit in their own planes and you can have infinite planes where each object sits. A common technique used in 3D graphics is to find the plane of a polygon or triangle. The definition of a plane is a unit vector normal depicting the direction a polygon/triangle is facing . A scalar tracks the distance the plane is away from the origin of the world.

The vector normal is computed by using the cross product of three points on the triangle/polygon. This value is then scaled down to a baseline value of 1.0.

To find the plane of a flat surface (triangle or polygon), you take three of the points on the surface and find two line segments between them. These segments are two vectors that originate from one base point on the surface extending to the other two points. This depicts two sides of the surface:

 SideA = Vector2  Vector1 SideB = Vector3  Vector1 

Crossing the two sides creates a perpendicular vector to the surface. This means the plane normal is found.

 Normal = SideA ^ SideB 

The perpendicular vector is long and can become a problem, so it's best to normalize the vector. Normalizing a vector forces a vector's magnitude to be 1.0.

 Normal = Normal.Normalize() 

The next thing you must do is find the plane distance. The plane distance is found by multiplying one point of the surface by the plane normal. The plane distance is a scalar that tells how far the plane is away from the origin of the world.

 Plane_Distance = - (Normal * Vertex1) 

By using the dot product with the normalized vector and the plane distance, you can determine whether a point lies in front, behind, or exactly on a plane, triangle, or polygon (the flat surface).

[ LiB ]


Focus On Photon Mapping
Focus On Photon Mapping (Premier Press Game Development)
ISBN: 1592000088
EAN: 2147483647
Year: 2005
Pages: 128
Authors: Marlon John

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net