POV-Ray : Newsgroups : povray.general : Why only a +1 clamp with VAngle, VAngleD macros in math.inc? : Why only a +1 clamp with VAngle, VAngleD macros in math.inc? Server Time
12 Jun 2021 19:52:33 EDT (-0400)
  Why only a +1 clamp with VAngle, VAngleD macros in math.inc?  
From: William F Pokorny
Date: 6 May 2021 09:06:30
Message: <6093e9d6$1@news.povray.org>
In creating some testing for include file macros I came across code for 
the two VAngle* macros (and two similar rotation related macros):

#macro VAngle(V1, V2)
         acos(min(1, vdot(vnormalize(V1), vnormalize(V2))))
#end

The min(1,..) is obviously trying to protect acos from domain errors.

Why only the clamp to the positive side? Aren't we as exposed to <-1.0?

Often enough in code - including POV_Ray's own - I've seen code clamping 
to a [-1..1] range after a dot product into acos() for acos domain 
concerns.

I cannot come up with reasoning to clamp only the positive side. Anyone 
else? If valid to do, we might be able to slightly streamline some 
internal code.

Bill P.


Post a reply to this message

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