POV-Ray : Newsgroups : povray.binaries.utilities : Q: Cylinder calculus? Server Time
8 Jul 2024 18:27:34 EDT (-0400)
  Q: Cylinder calculus? (Message 1 to 6 of 6)  
From: Vidar Madsen
Subject: Q: Cylinder calculus?
Date: 19 Oct 1998 05:21:59
Message: <362af6a7.0@news.povray.org>
Hi all. C'est moi, again. ;-)

Just a little quickie: (Please pardon my cluelessness.)

How do I calculate the vertices of a cylinder, given the coordinates
of the (center) end-points? I need to draw a disc, and "point it" towards
the other end-point, but I'm totally stuck. The net offers plenty of
information on how to calculate the normal vector from a surface, but
I need the other way around (i.e. a surface on which <0,0,0> points
towards <x,y,z>) .. :-/

You see, I'm hacking together a "tubeify spline" function for the
(Linux/X-Win) bezier patch modeller I've been working on lately,
which (at least I think) would be neat. It could be used to create
toothpaste for Simon's bathroom, maybe? ;-)

Also, I'm looking for a neat name for the program ("SplineDesign" is a
bit too hip, right?), as well as suggestions for other effects /
transformations.

I'll put up a web page for it soon, with a "ultra-pre-alpha-alpha"
version to play with. Hopefully within the week.. (It needs the GTK
widget set for X, though.)


Post a reply to this message

From: Roland Mas
Subject: Re: Q: Cylinder calculus?
Date: 19 Oct 1998 05:42:42
Message: <m3hfx1hrft.fsf@rpc66.acr.atr.co.jp>
Vidar Madsen <vid### [at] prosalgno> writes:

> Hi all. C'est moi, again. ;-)

  C'est moi aussi...

> How do I calculate the vertices of a cylinder, given the coordinates
> of the (center) end-points? I need to draw a disc, and "point it" towards
> the other end-point, but I'm totally stuck. The net offers plenty of
> information on how to calculate the normal vector from a surface, but
> I need the other way around (i.e. a surface on which <0,0,0> points
> towards <x,y,z>) .. :-/

  Well...  If you want your disc to be oriented such as its normal points
to D from its position P, you just have to have its normal colinear to the
PD vector.  For instance, use the PD = D - P vector.

  If it's about a cylinder...  I don't understand the question.

Roland.
-- 
Les francophones m'appellent Roland Mas,
English speakers call me Rowlannd' Mass,
Nihongode hanasu hitoha [Lolando Masu] to iimasu.
Choisissez ! Take your pick ! Erande kudasai !


Post a reply to this message

From: Vidar Madsen
Subject: Re: Q: Cylinder calculus?
Date: 19 Oct 1998 07:55:00
Message: <362B19D3.C3BC239E@prosalg.no>
> > How do I calculate the vertices of a cylinder, given the coordinates
> > of the (center) end-points? I need to draw a disc, and "point it" towards
> > the other end-point, but I'm totally stuck. The net offers plenty of
> > information on how to calculate the normal vector from a surface, but
> > I need the other way around (i.e. a surface on which <0,0,0> points
> > towards <x,y,z>) .. :-/
> 
>   Well...  If you want your disc to be oriented such as its normal points
> to D from its position P, you just have to have its normal colinear to the
> PD vector.  For instance, use the PD = D - P vector.
> 
>   If it's about a cylinder...  I don't understand the question.

Hmm, after reading through my post again, I admit it's a bit unclear.
I'll
try again;

- I have two end-points point1=<0,0,0> and point2=<x,y,z>
- I create four vertices around each end-point. For the first, this
  would be:
  <-thickness,0,0>,<+thickness,0,0>,<0,0,-thickness>,<0,0,+thickness>
- Now I need to rotate these four, so that they are planar (?) to the
  second end-point. This is where my math skills fail me miserably..

I tried this approach:
  1. rotate vertices atan2(point2.y, point2.z) around the Z axis
  2. rotate vertices atan2(point2.z, point2.x) around Y
and it seems to work if both the endpoints all have Z = 0, but that
wont do in the long run.. :-/

It's pretty basic math, but I never got that far in my studies. ;-)

Any help appreciated. Thanks.

Vidar


Post a reply to this message

From: Roland Mas
Subject: Re: Q: Cylinder calculus?
Date: 19 Oct 1998 08:27:40
Message: <m3btn8iydb.fsf@rpc66.acr.atr.co.jp>
Vidar Madsen <vid### [at] prosalgno> writes:

> - I have two end-points point1=<0,0,0> and point2=<x,y,z>
> - I create four vertices around each end-point. For the first, this
>   would be:
>   <-thickness,0,0>,<+thickness,0,0>,<0,0,-thickness>,<0,0,+thickness>
> - Now I need to rotate these four, so that they are planar (?) to the
>   second end-point. This is where my math skills fail me miserably..

Well.  I guess all you need is that your four vectors (say, two of them and
their opposites) are orthogonal to the N=<x,y,z> vector.  In that case, I
suggest using vector cross-products.

  Take a vector V, any vector V at all.  Just make it non-colinear with
<x,y,z>.  Take its vcross with N, you'll get a vector V1.  This one is
orthogonal to N.  You can then use it, after vnormalize-ing it and
multiplying it by thickness and -thickness, as two of your, er, vertices.
Then, take its vcross with N again.  You'll get V2, orthogonal to N *and*
to V1.  Same as above: vnormalize it, multiply it by thickness and


> It's pretty basic math, but I never got that far in my studies. ;-)

  Don't worry...  You'll regret the good ol'times when you'll have to cope
with cross-products.  Then you'll regret not to have listened to your
teachers when it was still time for it :-)

Roland.
-- 
Les francophones m'appellent Roland Mas,
English speakers call me Rowlannd' Mass,
Nihongode hanasu hitoha [Lolando Masu] to iimasu.
Choisissez ! Take your pick ! Erande kudasai !


Post a reply to this message

From: Peter Popov
Subject: Re: Q: Cylinder calculus?
Date: 19 Oct 1998 22:50:46
Message: <362bec76.0@news.povray.org>
I would suggest that you address your prayers to the local laag god - Mr.
van Sickle (tada!) Try http://www.erols.com/vansickl/matrix.htm , I think it
will help you. Matrices are also faster than sin  & cos, esp. on MMX

Peter


Post a reply to this message

From: Vidar Madsen
Subject: Re: Q: Cylinder calculus?
Date: 20 Oct 1998 03:55:45
Message: <362C3333.7CE7F090@prosalg.no>
OK, thanks a lot guys (Roland and Peter), I got it to work! :-)

At least as far as I expected it to do. Another problem is that
occationally (when Nx or Nz change from positive to negative,
it seems), the "tube" will twist itself 180 degrees, leaving a
segment that (remotely) resembles an hourglass.. :-/

The strange thing is, if I draw the curve in the Y window (i.e. all
points on the curve have Y=0) no twisting occurs.. Hrm...

Vidar


Post a reply to this message

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