POV-Ray : Newsgroups : povray.binaries.images : B-DNA : Re: B-DNA - testing the macro Server Time
20 May 2024 01:21:05 EDT (-0400)
  Re: B-DNA - testing the macro  
From: Thomas de Groot
Date: 9 Feb 2024 03:48:31
Message: <65c5e6df@news.povray.org>
OK. I think I have understood the mechanism, after a couple of wild, 
uncontrolled, experiments which were very helpful in the end. A couple 
of simple but useful comments:

1) the place of the initial triangle in/on the object is crucial to 
understand how the object is going to be moved. The orientation of the 
initial triangle is less crucial, although one should keep in mind that 
it /might/ become so in some cases.

2) Point 1 is crucial to define/calculate the target triangle. It is 
*not* defined from the origin but from the initial triangle.

3) All apices from the triangle have to be translated by an identical 
vector value. If not, you may have interesting surprises, mostly 
additional rotations to the object. However, those are difficult to 
control from the onset if used on purpose.

4) Here follows the code I used to control the macro. The object used is 
a prism object that can be found in POV-Ray's Insert Menu. Here it is 
declared as 'Roof':

//---------------------------------------------------------------------
#declare Roof =
union {
   object {Roof} //the original, inserted, prism object
   union {
     cylinder {<0,-3,0>,<0,3,0>,0.02 pigment {Green}}
     cylinder {<0,-3,0>,<0,3,0>,0.02 pigment {Blue} rotate 90*x}
     cylinder {<0,-3,0>,<0,3,0>,0.02 pigment {Red} rotate 90*z}
   }
   scale <1.00, 1.00, 1.00>*3
   rotate <0,0,0>
   translate <3.00, 0.00, 3.00>
}

#declare Text0 =
text {
   internal 1 "0"
   1.0, 0
   scale 2
   translate <2.5, 1.0, -0.1>
}


#declare Roof0 =
union {
   object {Roof}
   object {Text0}
}

Roof0

//---------------------------------------------------------------------

//defining the different triangles and translations:
#declare A1 = <0,0,3>;
#declare B1 = <3,4,3>;
#declare C1 = <6,0,3>;
#declare A2 = A1 + <-6,7,-9>;
#declare B2 = B1 + <-6,7,-9>;
#declare C2 = C1 + <-6,7,-9>;
#declare A3 = A2 + <6,0,-12>;
#declare B3 = B2 + <6,0,-12>;
#declare C3 = C2 + <6,0,-12>;
#declare A4 = A3 + <-6,0,0>;
#declare B4 = A3 + <-6,0,0>;
#declare C4 = A3 + <-6,0,0>;

//---------------------------------------------------------------------

#declare MyTransform1 = //A1,B1,C1 -> A2,B2,C2
Reorient_Triangle (
   A1, B1, C1,
   A2, B2, C2
)

#declare Text1 =
text {
   internal 1 "1"
   1.0, 0
   scale 2
   translate <2.5, 1.0, -0.1>
}

#declare Roof1 =
union {
   object {Roof}
   object {Text1}
}

#declare Roof1 =
object {Roof1 transform {MyTransform1} }

Roof1

//---------------------------------------------------------------------

#declare MyTransform2 = //A2,B2,C2 -> A3,B3,C3
Reorient_Triangle (
   A2, B2, C2,
   A3, B3, C3
)

#declare Text2 =
text {
   internal 1 "2"
   1.0, 0
   scale 2
   translate <2.5, 1.0, -0.1>
}

#declare Roof2 =
union {
   object {Roof}
   object {Text2}
}

#declare Roof2 =
object {Roof2 transform {MyTransform2} }

Roof2

//---------------------------------------------------------------------

#declare MyTransform3 = //A3,B3,C3 -> A4,B4,C4
Reorient_Triangle (
   A3, B3, C3,
   A4, B4, C4
)

#declare Text3 =
text {
   internal 1 "3"
   1.0, 0
   scale 2
   translate <2.5, 1.0, -0.1>
}

#declare Roof3 =
union {
   object {Roof}
   object {Text3}
}

#declare Roof3 =
object {Roof3 transform {MyTransform3} }

Roof3

//---------------------------------------------------------------------


-- 
Thomas


Post a reply to this message


Attachments:
Download 'be_reorient_triangle_test.png' (331 KB)

Preview of image 'be_reorient_triangle_test.png'
be_reorient_triangle_test.png


 

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