POV-Ray : Newsgroups : povray.newusers : Aligned box? : Re: Aligned box? Server Time
29 Jul 2024 14:15:43 EDT (-0400)
  Re: Aligned box?  
From: Slime
Date: 8 Sep 2005 03:01:46
Message: <431fe1da$1@news.povray.org>
> That comes VERY close. Actually, it works as I requested, although missing
> an implied criteria. I didn't specify it, but I need the box to maintain a
> vertical orientation, whereas your macro induces a rotation around the
> P1-P2 axis. I'm guessing this is an artifact of the Reorient_Trans

Replace Reorient_Trans with this macro and it should work (untested code,
let me know if it doesn't):

// maps the x axis to vec while keeping "sky" as up,
// doesn't work if vec is parallel to sky
#macro Reorient_Trans_Sky(vec, sky)
    #local mapxto = vec;
    #local mapzto = vnormalize(vcross(sky, vec));
    #local mapyto = vcross(mapxto, mapzto);
    matrix <
        mapxto.x, mapxto.y, mapxto.z,
        mapyto.x, mapyto.y, mapyto.z,
        mapzto.x, mapzto.y, mapzto.z,
        0,0,0
    >
#end

Use it like Reorient_Trans_Sky(P2 - P1, y)

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

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