Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!mailrus!rutgers!iuvax!pur-ee!uiucdcs!uiucdcsm!shirley From: shirley@uiucdcsm.cs.uiuc.edu Newsgroups: comp.graphics Subject: Re: ray to triangle Message-ID: <4400020@uiucdcsm> Date: 21 Apr 88 03:01:00 GMT References: <15@ Lines: 64 Nf-ID: #R: 0' is 'k0 > 0'). Now assume that the ray hits the plane: tv = k0*p0 + k1*p1 + k2*p2 since k0/k1/k2 are unknowns we can rewrite: v = k0'*p0 + k1'*p1 + k2'*p2 or |p0x p1x p2x| |k0'| |vx| |p0y p1y p2y| * |k1'| = |vy| |p0z p1z p2z| |k2'| |vz| To solve : |k0'| |p0x p1x p2x|-1 |vx| |k1'| = |p0y p1y p2y| * |vy| |k2'| |p0z p1z p2z| |vz| If t is positive then the ray hits inside iff all k's are positive, otherwise it hits only if they are all negative (a case we probably aren't interested in for normal ray tracing applications). Since we can precompute the inverted matrix, that gives a maximum of 9 multiplies, 6 adds, and 3 compares for each intersection. Usually we can get away with fewer operations since all k's must be above 0. Another thing I forgot to mention in my last response-- k1 and k2 are texture coordinates for interpolation if colors or normal vectors are defined at the vertices (if using the method here renormalize k's using condition that k0 + k1 + k2 = 1. This also will give t). The interpolation formula is (1 - k1 - k2)*c0 + k1*c1 + k2*c2 As a final note, this method was shown to me by Hiroshi Degushi, whose group implemented this on LINKS-1 hardware in Japan. Peter Shirley