POV-Ray : Newsgroups : povray.general : transforms.inc issue with Spline_Trans : transforms.inc issue with Spline_Trans Server Time
18 Apr 2025 23:09:36 EDT (-0400)
  transforms.inc issue with Spline_Trans  
From: Chris R
Date: 14 Mar 2025 12:10:00
Message: <web.67d4541fce33082853fb81ab5cc1b6e@news.povray.org>
While playing with the Spline_Trans macro from transforms.inc in my text layout
tests I ran into an issue when the spline I was using hand segments that aligned
with the Sky axis.

The problem is that Spline_Trans computes Forward and then determines the
"right" vector using VPerp_To_Plane(Sky,Forward).  VPerp_To_Plane calls
vnormalize(vcross(V1,V2)), and vnormalize barfs on a zero-length vector, which
is what happens if V1 and V2 are co-linear.

I have created a new version that I am now using that checks for this
possibility when computing the Right axis.  If the Forward is co-linear with
Sky, then the right vector can be any arbitrary vector that is perpendicular to
the Sky vector, so I compute the transformation from the "y" vector <0,1,0>, to
the given Sky vector, and apply the same transformation to the "x" vector
<1,0,0> and use that as Right.  Otherwise, I just use VPerp_To_Plane as before.

The choice of x is arbitrary, but the easiest to implement since Spline_Trans
has an assumption that the forward direction of the object being transformed is
on the z axis.

-- Chris R.


Post a reply to this message

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