POV-Ray : Newsgroups : povray.animations : Rotating and moving a cyl to AB : Re: Rotating and moving a cyl to AB Server Time
19 May 2024 10:50:04 EDT (-0400)
  Re: Rotating and moving a cyl to AB  
From: Charles C
Date: 21 Dec 2006 03:05:05
Message: <web.458a3fd429efe2719992c0d0@news.povray.org>
Look up VAngle() in the docs.  Just handle the axis separately.  Let's look
at the XZ angle, i.e. Y rotation first.  It's late and it's been a long day
so this is not guaranteed mistake free but... If AB is a vector idenifier
then:

#local Swing_angle =  VAngleD( x, <AB.x, 0,AB.z>);
#if (AB.z > 0)
  #local Swing_angle = Swing_angle * -1;
#end

//eliminate the Swing_angle so we can soon look at the Tilt_angle:
#local AB_tmp = vaxis_rotate(AB,y, -1*Swing_angle);

#local Tilt_angle =  VAngleD( x, AB_tmp);
#if (AB_tmp.y < 0)
  #local Tilt_angle = Tilt_angle * -1;
#end

//ok now add rotate commands to your cylinder:
//rotate z by Tilt_angle and then rotate y by Swing_angle





"MichaelC" <nomail@nomail> wrote:
> Hello everyone,
>
> I've got 2 changing points in space, A and B.  I want to construct and
> texture a cylindrical type object at 0 and then move it between A and B
> (using A and B as its endpoints).   Point A will never equal point B but
> their relation to each other can be anything.  Either point can be in any
> quadrant.  Later A and B could even swap positions.
>
> I can already determine the length of AB and construct my cylinder at
> y*-Len/2 to y*Len/2. I can translate it to the correct location using the
> midpoint of my cyl (0) to the midpoint of AB. I have graphed the normal of
> AB at the origin which seems to match a dummy cylinder drawn at AB. I
> cannot however get the correct rotation at the origin before my translation
>
> I've spent hours reviewing Calc, Trig and Vectors but was never an Ace at
> any of them.  I've attempted calculating "theta and phi" then later "pitch
> and yaw" using a different method and have applied multiple combinations of
> rotate commands using their values.  I have then tried using vcross, vdot
> and then vaxis-rotate but to no avail .... I've tried to compensate for the
> difference in the y and z axis from my old math books but may have missed
> something there.  I'm beginning to feel ... well ... discouraged.
>
> Is there an easy trick to this?
>
> Thanks in advance,
> Michael


Post a reply to this message

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