POV-Ray : Newsgroups : povray.binaries.images : How to untwist Reorient_Trans? : How to untwist Reorient_Trans? Server Time
25 Apr 2024 08:00:26 EDT (-0400)
  How to untwist Reorient_Trans?  
From: Cousin Ricky
Date: 10 Jun 2019 13:35:13
Message: <5cfe94d1@news.povray.org>
I want to string objects together in a chain.  Each segment is initially 
defined vertically, then rotated using macro Reorient_Trans() before 
being translated into position.

When I string the objects together, they usually end up rotated with 
respect to each other.  Since the objects all start out vertical, a 
simple counter-rotation about y should align them.  The question is, by 
what amount?  I've been wrestling with this problem for days, and I am 
utterly stumped.  I even tried bypassing Reorient_Trans() altogether, 
the result being boxes scattered seemingly randomly all over the place. 
Is there a general solution to this problem?

This is the code for the images in montage reorient-twist-pbi.jpg:

--------------------[BEGIN CODE]--------------------
// +KFF10
#version 3.7;

#ifndef (Rad) #declare Rad = yes; #end

#declare NCASES = 10;
#declare Rots = array [NCASES] { 0, 0, 30, 60, 150, 210, 30, 90, 150, 210, }
#declare Axes = array [NCASES] { 0, 2, 2, 2, 2, 2, 1, 1, 1, 1, }
#declare s_Axes = array [3] { "coil", "x", "y", }
#declare Case = min (NCASES - 1, max (0, frame_number - 1));

#include "colors.inc"
#include "screen.inc"
#include "shapes.inc"
#include "transforms.inc"

//========================== ENVIRONMENT =============================

#default { finish { diffuse 0.6 ambient rgb 0.15308 emission 0 } }
global_settings
{ assumed_gamma 1
   #if (Rad)
     radiosity
     { count 200
       error_bound 0.5
       pretrace_end 2 / image_width
       pretrace_start 32 / image_width
       recursion_limit 2
     }
   #end
}
box
{ <-8, 0, -8>, <8, 9, 8>
   pigment { rgb 1 }
}
light_source
{ <-3.2625, 7.6250, -5.6508>,
   rgb <3924, 3924, 3924>
   fade_power 2 fade_distance 0.10417
   spotlight point_at <0, 1.1, 0> radius 45 falloff 90
}

#declare V_CAM = <0, 1.1, -6.2384>;
// Position the camera to avoid the plane of the test object:
#if (Rots [Case] = 90)
   #switch (Axes [Case])
     #case (1) #declare V_CAM = <0, 4.2192, -5.4026>; #break
     #case (2) #declare V_CAM = <-3.1192, 1.1, -5.4026>; #break
   #end
#end
Set_Camera (V_CAM, <0, 1.1, 0>, 28.9995)

//============================== TEST ================================

Screen_Object
( text
   { ttf "cyrvetic"
     concat
     ( #if (Axes [Case] = 0) "",
       #else str (Rots [Case], 0, 1), " * ",
       #end
       s_Axes [Axes [Case]]
     )
     0.001, 0
     scale 0.065
     pigment { rgb 0 }
   },
   <0, 1>, <0.02, 0.02>, yes, 1
)

#declare Pts = array[9]
#for (I, 0, 8)
   #declare Pt = vrotate (y, -45 * I * z);
   #switch (Axes [Case])
     #case (1)
       #declare Pts[I] = vrotate (Pt, Rots [Case] * x);
       #break
     #case (2)
       #declare Pts[I] = vrotate (Pt, Rots [Case] * y);
       #break
     #case (0)
     #else
       #declare Pts[I] = vrotate (Pt, 90 * x) - (I - 4) / 4 * y;
   #end
#end

#macro Mark (Text, Rot)
   object
   { Center_Object (text { ttf "cyrvetic" Text 1, 0 }, x)
     scale <1, 1, -10>
     translate y
     rotate Rot * y
   }
#end
#declare Compass = union
{ Mark ("-z", 0)
   Mark ("-x", 90)
   Mark ("z", 180)
   Mark ("x", 270)
   scale 0.18
}

union
{ #for (I, 0, 7)
     box
     { <-1, 0, -1>, 1
       scale <0.1, vlength (Pts[I+1] - Pts[I]), 0.1>
       pigment { object { Compass rgb CH2RGB (I * 45) rgb 0 } }
       Reorient_Trans (y, Pts[I+1] - Pts[I])
       translate Pts[I]
     }
   #end
   translate <0, 1.1, 0>
}
---------------------[END CODE]---------------------

Such a solution would have obvious application toward uv-textured sphere 
sweeps.  Image test_sswp_textured10.jpg shows the suboptimal results 
when the cylindrical warp is transformed with Reorient_Trans() without 
any counter-rotation.  (Filling in those gray gaps is a separate issue 
that I'm not inclined to address while I have this more fundamental 
unsolved problem.)


Post a reply to this message


Attachments:
Download 'reorient-twist-pbi.jpg' (189 KB) Download 'test_sswp_texture10.jpg' (55 KB)

Preview of image 'reorient-twist-pbi.jpg'
reorient-twist-pbi.jpg

Preview of image 'test_sswp_texture10.jpg'
test_sswp_texture10.jpg


 

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