algorithm - calculating point of intersection between far or near plane and a triangle -
suppose, near , far values of gluperspective 1 , 100 respectively. want clip portion of triangle having z values greater (-near) or less (-far) , divide remaining polygon 2 triangles following images.
considering near plane:
another case:
i have calculated intersection points in following way: z_clip=-far (for considering far plane) or z_clip=-near (for considering near plane)
for example: f consider edge between (x1,y1,z1) , (x2,y2,z2), then:
co-efficient = (z_clip - z1) / (z2 - z1) xc = x1 + co-efficient * (x2 - x1) yc = y1 + co-efficient * (y2 - y1) zc = z_clip
(xc,yc,zc) point of intersection. similarly, can calculate point of intersection other edge. example: edge between (10, 0, -50) , (0, 0, -150) cut in point (5, 0, -100).
original triangle: 0 0 -150 10 0 -50 0 10 -50 after clipping: triangle1: 0 10 -50 5 0 100 0 5 -100 triangle2: 10 0 -50 0 5 -100 0 10 -50
am right in calculation procedure or there wrong in procedure?
Comments
Post a Comment