POV-Ray : Newsgroups : povray.beta-test : VPerp_To_Vector() macro bug, also Axial_Scale_Trans() : VPerp_To_Vector() macro bug, also Axial_Scale_Trans() Server Time
29 Jul 2024 12:26:20 EDT (-0400)
  VPerp_To_Vector() macro bug, also Axial_Scale_Trans()  
From: Gelu Stoicescu
Date: 6 May 2002 14:12:46
Message: <3cd6c79e@news.povray.org>
WinPOV 3.5.beta.RC3.icl.win32, AMD K6-II 3D 333MHz 160M RAM, Win98SE
(not that it matters whatsoever, only to embarrass myself with my
outdated hardware)

This is the kind of thing a beginner (like me) would spot, getting busy
with the ready made stuff. Let me quote the definition, for the sake of
explanations:

#macro VPerp_To_Vector(V)
   vnormalize(vcross(V, vrotate(V, <90, 90, 0>)))
#end

However, when V has values such as <1, 1, -1> (and all proportional
vectors such as <2, 2, -2>, <-1, -1, 1> etc - what matters is the
direction) the two rotations performed by vrotate() bring the vector in
a round trip right where it started (isn't math amazing? I wouldn't see
it coming either), then vcross() has identical vectors and returns <0,
0, 0>, so vnormalize() throws the appropriate error. IMHO the purpose of
this VPerp_To_Vector() macro is rather confusing. Manual says "Find a
vector perpendicular to the given vector". I'm no Einstein, but vectors
perpendicular to a given vector are more than one (actually a whole
plane of them), and this function only picks one by its own acquired
taste. Such a "pick a card" tweak may find its use (whoever made it
probably needed it; I woun't be so cheeky as to mention Rune's name -
oops!), although I saw it used quite sparingly (only 2 occurences in 2
different files in \include). But the preferential choice of the two
axis in vrotate(), leaves a "blind angle" on the mentioned direction.
I guess the workaround would be to add to the code a lil' test for the
offending direction and return an explicit vector. Here I feel I must
state that me for one I wouldn't vote for returning phony values from
vnormalize() for zero-lenght vectors - just to cut down another
extensive debate.
BTW the VPerp_To_Vector() macro also causes Axial_Scale_Trans() macro to
display the same behaviour (throws error for the mentioned direction)
and that's only what I stepped on.
All above is a beginner's opinion, no IRTC entry yet, please no flames
(at need I can plead non native English speaker). If it's known issue,
yesterday news etc., merely ignore.

Gelu


Post a reply to this message

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