POV-Ray : Newsgroups : povray.animations : Rotating and moving a cyl to AB Server Time
23 Nov 2024 14:33:00 EST (-0500)
  Rotating and moving a cyl to AB (Message 1 to 6 of 6)  
From: MichaelC
Subject: Rotating and moving a cyl to AB
Date: 20 Dec 2006 17:35:00
Message: <web.4589b8fc47905c5f4599c17c0@news.povray.org>
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

From: Charles C
Subject: Re: Rotating and moving a cyl to AB
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

From: Warp
Subject: Re: Rotating and moving a cyl to AB
Date: 21 Dec 2006 03:33:09
Message: <458a46c4@news.povray.org>
MichaelC <nomail@nomail> wrote:
> Is there an easy trick to this?

  Yes. Look at the functions at:
http://povray.org/documentation/view/3.6.1/488/

  Especially Reorient_Trans() or Point_At_Trans().

-- 
                                                          - Warp


Post a reply to this message

From: MichaelC
Subject: Re: Rotating and moving a cyl to AB
Date: 21 Dec 2006 09:35:01
Message: <web.458a9aa329efe2714599c17c0@news.povray.org>
"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.


Thanks for the responses Charles and Warp!!  I'll grind at it a little
longer.  Perhaps my little spider Triggy will walk some day thanks to you
guys!!  : )


Post a reply to this message

From: Charles C
Subject: Re: Rotating and moving a cyl to AB
Date: 21 Dec 2006 11:20:00
Message: <web.458ab32229efe2719926319c0@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
>   Especially Reorient_Trans()

I thought about this one after the fact, just as I was falling asleep last
night, but I couldn't quite remember the name of it.
Charles


Post a reply to this message

From: MichaelC
Subject: Re: Rotating and moving a cyl to AB
Date: 21 Dec 2006 13:50:00
Message: <web.458ad65e29efe27194b0bd780@news.povray.org>
WOW     Point_At_Trans(Normal) is a God Send

Thanks again Charles and Warp ... You can be the proud God Parents of
Triggy.

Triggy was born an hour ago.  His conceptual baby pictures can be found
here.

http://home.bluemarble.net/~mcoons/POVRay/POVRay.htm

Michael


Post a reply to this message

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