View Full Version : Fastest way to determin which side of a triangle

NicholasFrancis

01-02-2002, 12:52 PM

I have a real dump question... Here goes:

What is the fastest way to determine if a point lies on one side or the other of a triangle (for shadow volume backface culling)?

Any help would be appreciated...

Nich.

ScottManDeath

01-02-2002, 01:08 PM

Hi

I would use following:

prerequisite:

triangles vertices

t[0]

t[1]

t[2]

point

p

build two vector from the triangles

a=t[1]-t[0]

b=t[2]-t[0]

cross product a x b = n

(be aware of order)

build vector from p to one triangle vertex

c=p-t[0]

dot product c with n

switch(c dot n)

case 0:

p lies on plane containing triangle

case < 0:

p lies on the side the normal is not pointg to

case >0:

p lies on the side normal is pointing to

i hope its correct and useful

bye

ScottManDeath

NicholasFrancis

01-02-2002, 01:19 PM

Cool. Exactly what I was looking for. I've already got the surface normal, so I don't know why I didn't see this one.

THNX.

Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.