POV-Ray : Newsgroups : povray.general : Calculate normal vector? : Re: Calculate normal vector? Server Time
1 Aug 2024 20:11:51 EDT (-0400)
  Re: Calculate normal vector?  
From: alphaQuad
Date: 26 Sep 2008 13:55:01
Message: <web.48dd20ef92437aab8ea364160@news.povray.org>
everyone has explained it, here's my 2 cents. I have had to do this twice but
not in pov script (yet)

the normal for the vertex is the addition of the normals of all triangles that
share it. but you want a condition that supports limiting to an angle variable,
ideally.

first the triangle normal

#macro normal_vector(A,B,C)
 #local result = vcross(C-B,A-B);
 result
 // 1
 // |
 // 2__ 3 vz points at you (neg) unless reverse y like pov, then
 //
 // 2__ 3
 // |
 // 1
#end

vcrossing 2 vectors is almost never a length of one, unless it is.
normalize for a length of 1.

pov renders 2-sided, so reverse normals are seldom an issue but do it right the
first time, if you want outside vectors, input is clockwise


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.