POV-Ray : Newsgroups : povray.binaries.images : B-DNA : Re: B-DNA Server Time
3 Mar 2024 18:33:59 EST (-0500)
  Re: B-DNA  
From: Thomas de Groot
Date: 6 Feb 2024 07:47:13
Message: <65c22a51$1@news.povray.org>
Op 5-2-2024 om 01:11 schreef Bald Eagle:
> Thomas de Groot <tho### [at] degrootorg> wrote:
>>> I currently have my nose to the ground, trying to find an algorithm to generate
>>> the inverse of a 9x9 rigid body transform matrix - if I can puzzle that out,
>>> then any object specified with 4 points can be mapped to any other instance with
>>> a transform {matrix{}} statement.
>>> Then I can take one base, look over where it sits somewhere else in the helix,
>>> and calculate exactly how to get it from one place to another.
>> That could be very useful. Also in a universal sense, applied to all
>> sort of transformations/mutations.
> OK, So I haven't ferreted out all the details of the purely matrix approach, but
> while closing one of the 100 browser tabs I have open, I stumbled across a guy
> using Reorient_Trans, and figured that would be a viable approach.
> I had a few false starts due to not really being able to visualize what was
> going on, but after making an IRL model and turning it around a few times, the
> part I was missing / improperly implementing became obvious, and I was able to
> package it all up into a single macro.
> Identify any three points on your original object (A, B, C), and where those
> three points end up (A2, B2, C2)
> Apply the macro like so:
> #declare MyTransform = Reorient_Triangle (A, B, C, A2, B2, C2)
> object {MyObject transform {MyTransform}}
> Please try this out with a large assortment of objects in various orientations
> to see if I missed anything.   The only thing not included is a sanity check for
> plugging in a second set of coordinates that are identical to the first.
> #macro Reorient_Triangle (A, B, C, A2, B2, C2)
>   // Bill Walker "Bald Eagle" February 2024
>    #include "transforms.inc"
>   #end
>   #local Translate1 = transform {translate -A}
>   #local Vector1 = B - A;
>   #local Vector2 = B2 - A2;
>   // Align Vector1 to Vector2
>   #local FirstTransform = transform {Reorient_Trans (Vector1, Vector2)};
>   #local A1 = vtransform (A-A, FirstTransform)+A;
>   #local B1 = vtransform (B-A, FirstTransform)+A;
>   #local C1 = vtransform (C-A, FirstTransform)+A;
>   // Find the vector to C1 that is perpendicular to Vector2
>   #local T1 = vdot (B1-A1, C1-A1) / vdot (B1-A1, B1-A1);
>   #local D = A1 + T1 * (B1-A1);
>   #local Vector3 = C1 - D;
>   // Find the vector to C2 that is perpendicular to Vector2
>   #local T2 = vdot (B2-A2, C2-A2) / vdot (B2-A2, B2-A2);
>   #local D2 = A2 + T2 * (B2-A2);
>   #local Vector4 = C2 - D2;
>   // Rotate everything around Vector2 so that the perpendicular vectors match
>   #local SecondTransform = transform {Reorient_Trans (Vector3, Vector4)};
>   // Now everything is similarly aligned with 3 sequential transforms
>   // and translating a final time puts the object at the destination
>   #local Translate2 = transform {translate A2}
>   #local T = transform { transform {Translate1} transform {FirstTransform}
> transform {SecondTransform} transform {Translate2} }
>   T
> #end

Impressive. I have started to play, first with a complex mesh2 object, 
and it works like a charm. I still need to dig deeper obviously, but I 
love it.


Post a reply to this message

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