POV-Ray : Newsgroups : povray.newusers : traditional math Server Time
1 Nov 2024 03:14:28 EDT (-0400)
  traditional math (Message 1 to 6 of 6)  
From: stefan berke
Subject: traditional math
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

From: Roman Reiner
Subject: Re: traditional math
Date: 7 Jun 2006 08:55:01
Message: <web.4486cbd0fbe97056fd656ec90@news.povray.org>
You might want to look up (or simply use) the Reorient_Trans(Axis1, Axis2)
or the Point_At_Trans(YAxis) macro in transforms.inc
(http://www.povray.org/documentation/view/3.6.1/488/). They should do the
job.

Hope that helps
Regards Roman


Post a reply to this message

From: Trevor G Quayle
Subject: Re: traditional math
Date: 7 Jun 2006 09:10:00
Message: <web.4486cf17fbe97056c150d4c10@news.povray.org>
"Roman Reiner" <lim### [at] gmxde> wrote:
> You might want to look up (or simply use) the Reorient_Trans(Axis1, Axis2)
> or the Point_At_Trans(YAxis) macro in transforms.inc
> (http://www.povray.org/documentation/view/3.6.1/488/). They should do the
> job.
>
> Hope that helps
> Regards Roman


vrotate() is a good internal function to look into as well.


-tgq


Post a reply to this message

From: stefan berke
Subject: Re: traditional math
Date: 7 Jun 2006 18:10:59
Message: <44874ef3$1@news.povray.org>
ok, thanks roman.
the Reorient_Trans does everything well with
settings like R_T(y*1,vec2-vec1) which should somehow
respond to the things i read in the doc about it, when i want
to align an circle on X/Z perp. to the axis of vec1/vec2.
ok, what i don't see is the math thats behind it. i can't figure
it out from the macro in transforms.inc, mainly because i don't
know what parameters the matrix transform uses. in the docs i only
found a helpscreen saying matrix takes 12 parameters, that's what
i can see from the macro. but i don't see what they mean.
    obviously the Reorient_Trans can only be used inside an object
statement and not for vectors because of the transform {} block.
im still wondering what the macro really does--mathematically, or
how this is called in general.
thanks a lot anyway. wouldnt had found this step.


Post a reply to this message

From: stefan berke
Subject: Re: traditional math
Date: 7 Jun 2006 18:24:21
Message: <44875215@news.povray.org>
ok,i found the vtransform macro myself, nobody has to point me to the
obvious.
but im still intereseted in the math-stuff. at least, some name for it i can
look for.
thx


Post a reply to this message

From: Leroy
Subject: Re: traditional math
Date: 9 Jun 2006 23:48:34
Message: <448A40BE.9070700@joplin.com>
Here is a macro to make a mesh cone I use it as part of making trees.
It's a good example of the math you need.
I use a macro made by Paul T Dawson and modified some.
I hope this helps...

// From meshcone.inc
//
// Macro for one "cone" made from triangles.
//
// By: Paul T. Dawson
// edited for Winter 3/30/02 by Leroy

#macro MeshCone ( StartPoint, Endpoint, Rd1, Rd2)
// If INCREMENT is lower, there will be more triangles!

         #local INCREMENT = 30;// <=120 in degrees
         #local VL = StartPoint- Endpoint;
         #local VP = VPerp_To_Vector(VL);

// Go around the edges of the cone, do one section at a time.

         #local A = 0; #while ( A < 360 )

             //Starting locations
          #local Corner1 = vaxis_rotate(VL+VP*Rd1,VL,A+INCREMENT)+Endpoint;
          #local Corner2 = 
vaxis_rotate(VL+VP*Rd2,VL,A+INCREMENT)+Endpoint-VL;
          #local Corner3 = vaxis_rotate(VL+VP*Rd2,VL,A)+Endpoint-VL;
          #local Corner4 = vaxis_rotate(VL+VP*Rd1,VL,A)+Endpoint;

             // Make the triangles.
          triangle { Corner1 Corner2 Corner3 }
          triangle { Corner1 Corner3 Corner4 }

          #declare COUNT_TRIANGLES = COUNT_TRIANGLES + 2;
  #local A = A + INCREMENT; #end

#end


Post a reply to this message

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