Over 10 Million Study Resources Now at Your Fingertips

Download as :
Rating : ⭐⭐⭐⭐⭐
Price : $10.99
Pages: 2

When perform the same edge test point

larger than zero) then the point is in front of the plane. As soon as this happens for any edge we know the point is not contained inside the polygon and we can exit.

Figure 12.23 demonstrates testing to see if

// Phase One : Test if Ray intersects polygon’s plane
// Calculate Distance to polygons plane using first vertex as point on plane float PlaneDistance = D3DXVec3Dot( &(Origin – Polygon.VertexList[0]), &Polygon.Normal );

// Calculate Projected Ray Length onto polygons plane normal float ProjRayLength = D3DXVec3Dot( &Direction, &-Polygon.Normal );

// Calculate t
t = PlaneDistance / ProjRayLength ;

// Plane is either before the start of the ray or past the end of the ray so // not intersection
if ( t < 0.0f || t > 1.0f ) return false;

// Generate plane normal
D3DXVec3Cross ( &EdgeNormal, &EdgeVector , &pPoly->m_vecNormal);

//Create vector from point to vertex ( point on plane ) Direction = FirstVertex-IntersectionPoint;


Most often in 3D graphics we are dealing with triangles and not with N-gons. The point in polygon test can be optimized somewhat when being used specifically for “Point in Triangle” tests because we can unwind the loop and lose a bit of overhead. The following snippet of code shows how we might write a function called PointInTriangle whose code could also be substituted into the function shown above to create a RayIntersectTriangle method.

How It Works
Login account
Login Your Account
Add to cart
Add to Cart
Make payment
Document download
Download File
PageId: ELIE37668F
Uploaded by :
Page 1 Preview
when perform the same edge test point
Sell Your Old Documents & Earn Wallet Balance