POV-Ray : Newsgroups : povray.general : Cylinder with origin, point_to and length Server Time
2 Aug 2024 18:10:29 EDT (-0400)
  Cylinder with origin, point_to and length (Message 1 to 3 of 3)  
From: Rick Measham
Subject: Cylinder with origin, point_to and length
Date: 31 Jul 2004 01:45:00
Message: <web.410b30ae7ef9b5f8ddeed8210@news.povray.org>
I'm trying to work out how to create a cylinder that points at a particular
point. I have an origin and a length (and radius of course).

Given these, I'm sure it must be possible to calculate the other end of the
cylinder (one end is the origin). The unknown end will fall upon the
imaginary line between the origin and the point_to and will be length units
from the origin.

My 2D trig doesn't work here. I can put it on the XY axis in the correct
position and I can put it on the YZ axis in the correct position (thus the
XZ is also easy). However getting onto an XYZ axis is proving impossible.

It's occurred to me after several hours of playing around that this problem
must have been solved thousands of times already. If not for POV-Ray then
for someone's math class sometime.

Thanks!
Rick


Post a reply to this message

From: KalleK
Subject: Re: Cylinder with origin, point_to and length
Date: 31 Jul 2004 03:53:48
Message: <410b500c$1@news.povray.org>
Hi!

Not tested, but what about this:

#declare StartPoint = YourOrigin;
#declare Direction = (ParticularPoint - StartPoint);

#declare EndPoint = StartPoint + Direction *
(CylinderLength/vlength(Direction));
or
#declare EndPoint = StartPoint + vnormalize(Direction)*CylinderLength;

cylinder {StartPoint, EndPoint, Radius ... }

cukk


Post a reply to this message

From: Mike Williams
Subject: Re: Cylinder with origin, point_to and length
Date: 31 Jul 2004 05:29:10
Message: <ugpHGAARS2CBFwI1@econym.demon.co.uk>
Wasn't it Rick Measham who wrote:
>I'm trying to work out how to create a cylinder that points at a particular
>point. I have an origin and a length (and radius of course).
>
>Given these, I'm sure it must be possible to calculate the other end of the
>cylinder (one end is the origin). The unknown end will fall upon the
>imaginary line between the origin and the point_to and will be length units
>from the origin.
>
>My 2D trig doesn't work here. I can put it on the XY axis in the correct
>position and I can put it on the YZ axis in the correct position (thus the
>XZ is also easy). However getting onto an XYZ axis is proving impossible.
>
>It's occurred to me after several hours of playing around that this problem
>must have been solved thousands of times already. If not for POV-Ray then
>for someone's math class sometime.

"vnormalize(point_to)" gives you a point that's in that direction and
unit distance from the origin. So "length*vnormalize(point_to)" gives a
point in that direction that is "length" units away.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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