|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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'
Preview of image 'test_sswp_texture10.jpg'
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Le 10/06/2019 à 19:35, Cousin Ricky a écrit :
> Such a solution would have obvious application toward uv-textured sphere
> sweeps.
sphere_sweep have been uv-mapped (in hgpovray).
Basic approach: an initial vector and the first 2 points define the
origin for one uv axis, as two normals. It's arbitrary anyway, but being
predictable and adjustable is better when using uv-mapping.
(the two normals and the oriented segment make a local 3D reference
system that is going to slide along the sphere sweep)
On each successive point, compute the plane in which the rotation is
occurring (3 poins, one plane) and propagate the normals on next segment
using the "natural" rotation in the plane. Repeat until there is no more
point.
Alas, currently in hgpovray38, sphere_sweep is not marked as UVMeshable,
so you cannot read back the data from uv values using uv_min, uv_max,
uv_vertex and uv_normal (also extension of hgpovray38).
Nevertheless, you can use trace() as usual to retrieve the uv value if
you known how to have an intersection (hint: middle of a segment and
trying two perpendicular vectors, for linear sphere sweep; more
difficult for the other types)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 6/10/19 1:35 PM, Cousin Ricky wrote:
> 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?
Quick stab in the dark if hgpovray38 not an option for you. Look at the
shipped animation scene:
<install>/scenes/animations/splinefollow.
I remember Rune supporting a banking parameter in that sample - which
perhaps can be 0.0.
Bill P.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Cousin Ricky <ric### [at] yahoocom> wrote:
> 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'm assuming that you want to rotate them around y the opposite way before
applying the macro which will then cancel your pre-rotation.
Here's my logic, untested.
The transforms in Reorient_Trans() are matrix transformations that have elements
that are cos, sin and -sin of the angle in radians.
Just intercept the values of that before they are used, convert them to degrees,
(make sure they all match), and then rotate your object around -y by that
amount.
I think just uncommenting the two rotate directives below ought to do it.
[I didn't correct the
transform { Axis_Rotate_Trans(vZ,180) }
part in the #else block.]
// Corrected Reorient_Trans() macro by Bill Walker (Bald Eagle) 2019
// based on original Reorient() macro by John VanSickle
#macro Reorient_Trans(Axis1, Axis2)
#local vX1 = vnormalize(Axis1);
#local vX2 = vnormalize(Axis2);
#local Y = vcross(vX1, vX2);
#if(vlength(Y) > 0)
#local vY = vnormalize(Y);
#local vZ1 = vnormalize(vcross(vX1, vY));
#local vZ2 = vnormalize(vcross(vX2, vY));
#declare Angle1A = degrees (acos ( vX1.x));
#declare Angle1B = degrees (asin ( vZ1.x));
#declare Angle1A = degrees (asin (-vX1.x));
#declare Angle1D = degrees (acos ( vZ1.z));
#debug "1st rotation about y in degrees \n"
#debug concat (vstr(3, Angle1A, ", ", 7, 3), "\n")
#debug concat (vstr(3, Angle1B, ", ", 7, 3), "\n")
#debug concat (vstr(3, Angle1C, ", ", 7, 3), "\n")
#debug concat (vstr(3, Angle1D, ", ", 7, 3), "\n")
#declare Angle2A = degrees (acos ( vX2.x));
#declare Angle2B = degrees (asin ( vX2.z));
#declare Angle2A = degrees (asin (-vZ2.x));
#declare Angle2D = degrees (acos ( vZ2.z));
#debug "2nd rotation about y in degrees \n"
#debug concat (vstr(3, Angle2A, ", ", 7, 3), "\n")
#debug concat (vstr(3, Angle2B, ", ", 7, 3), "\n")
#debug concat (vstr(3, Angle2C, ", ", 7, 3), "\n")
#debug concat (vstr(3, Angle2D, ", ", 7, 3), "\n")
//rotate -y * Angle1A
transform {
matrix <
vX1.x, vY.x, vZ1.x,
vX1.y, vY.y, vZ1.y,
vX1.z, vY.z, vZ1.z,
0,0,0 >
}
//rotate -y * Angle1A
transform {
matrix <
vX2.x, vX2.y, vX2.z,
vY.x, vY.y, vY.z,
vZ2.x, vZ2.y, vZ2.z,
0,0,0 >
}
#else
#if (vlength(vX1-vX2)=0)
transform {}
#else
#local vZ = VPerp_To_Vector(vX2);
transform { Axis_Rotate_Trans(vZ,180) }
#end
#end
#end
See:
https://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|