POV-Ray : Newsgroups : povray.newusers : traditional math : traditional math Server Time
29 Jul 2024 06:23:09 EDT (-0400)
  traditional math  
From: stefan berke
Date: 7 Jun 2006 06:31:54
Message: <4486ab1a$1@news.povray.org>
hi there,
i recently started to write a macro which constructs a cylinder or cone out
of triangles, so if one designes an object out of maaany cylinders they
get converted to a mesh for better memory management. however. i can not
get behind the math need to calc the rotation angles for the axis for any
given points A,B of the cyl. it should work like: tcylinder(A,B,r) where
A,B ofcorse are the two vectors, r is radius. now i calc one cap of the
cylinder
<sin(t),0,cos(t)>*r, having a circle lying on X/Z, the same for the other
cap.
putting this together with triangles isnt hardly the problem. what i don't
get is
how to exactly rotate the caps so that their orientation is perpendicular to
the
axis of the cylinder. according to the rules in a right-angled triangle,
alpha,
wich could be of good use for it, i determine by degrees(asin(a/c))--where
c is the length of the cyl (by sqrt(a*a+b*b)) and a and b are the remaining
sides.

          //|
x    c //  | b
      //    |
    //___|
alph.  a         y
i guess i am right so far, because it works in some cases. but if the
cylinder's
second vector is in the second quadrant, or if vec2.y < vec1.y one has to
tweak the resulting angle, it seems. ok, i solved this somehow for the
example above, where i determine the rotation about the Z axis, but then it
doesnt work
for the other axises. well, ok, here the precise questions: 1. is there any
pure
formula for the needed rotationangles (away from any #if statements)? 2.
how to apply it to all three axises? and 3. in which order do i have to
rotate the
cap-vecs around the axises. and maybe 4. is this the best
procedure--anyway---
for designing objects with lots cylinders which then can be copied without
much memory overhead? (in any case it would be neat to have a cylinder/cone
macro
which can then produce some non-uniform cylinders or some deforming).
well, i hope i made my point, thanks for reading.


Post a reply to this message

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