POV-Ray : Newsgroups : povray.binaries.images : B-DNA : Re: B-DNA Server Time
5 Nov 2024 18:22:47 EST (-0500)
  Re: B-DNA  
From: Tor Olav Kristensen
Date: 13 Feb 2024 19:00:00
Message: <web.65cbff0f41c066f0f673154389db30a9@news.povray.org>
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
>...
> To "unsimplify" the problem again, in order to deal with triangles which does
> not have their A and A2 points at origo, you can just reintroduce the translate
> -A and translate A2 transformations in the resulting composite transform
> expression.

Sorry Bill

What I wrote above is not true. I forgot to uncomment the translations in my
test transform before testing my modifications to your macro.

This macro version works when p0A = <0, 0, 0> and p2A = <0, 0, 0>:

#macro Reorient_Triangle(p0B, p0C, p2B, p2C)

    #local FirstTransform = Reorient_Trans(p0B, p2B)
    #local p1B = vtransform(p0B, FirstTransform);
    #local p1C = vtransform(p0C, FirstTransform);
    #local p1D = vdot(p1C, p1B)/vdot(p1B, p1B)*p1B;
    #local p2D = vdot(p2C, p2B)/vdot(p2B, p2B)*p2B;
    #local v1D1C = p1C - p1D;
    #local v2D2C = p2C - p2D;
    #local SecondTransform = Reorient_Trans(v1D1C, v2D2C)

    transform {
        transform { FirstTransform }
        transform { SecondTransform }
    }

#end // macro Reorient_Triangle


- and this version also works when that is not the case. I.e. It also works when
there are translations within the transformation.

#macro Reorient_Triangle(p0A, p0B, p0C, p2A, p2B, p2C)

    #local v0A0B = p0B - p0A;
    #local v0A0C = p0C - p0A;
    #local v2A2B = p2B - p2A;
    #local v2A2C = p2C - p2A;
    #local FirstTransform = Reorient_Trans(v0A0B, v2A2B)
    #local v0A1B = vtransform(v0A0B, FirstTransform);
    #local v0A1C = vtransform(v0A0C, FirstTransform);
    #local v1D1C = v0A1C - vdot(v0A1C, v0A1B)/vdot(v0A1B, v0A1B)*v0A1B;
    #local v2D2C = v2A2C - vdot(v2A2C, v2A2B)/vdot(v2A2B, v2A2B)*v2A2B;
    #local SecondTransform = Reorient_Trans(v1D1C, v2D2C)

    transform {
        transform { translate -p0A }
        transform { FirstTransform }
        transform { SecondTransform }
        transform { translate +p2A }
    }

#end // macro Reorient_Triangle


--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

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