POV-Ray : Newsgroups : povray.newusers : Rotations not working as expected : Re: Rotations not working as expected Server Time
30 Jul 2024 10:12:51 EDT (-0400)
  Re: Rotations not working as expected  
From: Alex Bame
Date: 20 May 2004 01:40:00
Message: <web.40ac439e225a08e5b4980b800@news.povray.org>
Mike Williams <nos### [at] econymdemoncouk> wrote:
> Imagine your mechanism as an inverted pyramid. The slope of the edges of
> the pyramid (theta) is not the same as the slope of a line running up
> the centre of one of the faces. Let's call the slope of the centre line
> "alpha". You need to rotate the centres of your springs upwards by
> alpha, not theta. The length of the spring also depends on alpha, not
> theta.
>
> My trig doesn't seem up to calculating alpha, so I got POV to do all the
> hard work for me. I calculated the points P1 and P2 that are half way up
> the first two rods and told POV to run the spring between those points.
>
> // Need this for Point_At_Trans
> #include "transforms.inc"
>
> // Calculate the endpoints of one spring
> #declare P1=<sin(theta)*sin(phi), cos(theta), sin(theta)*cos(phi)>;
> #declare P2=<sin(theta)*sin(phi+pi/2), cos(theta),
>         sin(theta)*cos(phi+pi/2)>;
>
> // Calculate its length
> #declare Length = vlength(P2-P1);
>
> // Declare the spring
> #declare Spring= isosurface {
>    function {
>       f_helix1(x, y, z, 1, 20*pi,
>          spr_min_radius, spr_maj_radius,
>          1, 1, 0)
>    }
>    max_gradient 3
>    contained_by{ box {-1/2,1/2} }
>    texture {T_Brass_3A}
>
>    translate <0,0.5,0>                // move one end point to <0,0,0>
>    scale <1, Length, 1>               // Set the correct length
>    transform {Point_At_Trans (P2-P1)} // point it in the P1-P2 direction
>    translate P1                       // move one end from <0,0,0> to P1
> }
>
> // Make four copies
> object {Spring}
> object {Spring rotate <0, (pi)*180/pi, 0>}
> object {Spring rotate <0, (pi/2)*180/pi, 0>}
> object {Spring rotate <0, (3*pi/2)*180/pi, 0>}
>
>
> --
> Mike Williams
> Gentleman of Leisure

That's excellent :)

I was thinking of it as a cone, not a pyramid.  I see now that you're right,
this is exactly what was causing my problem.  I also like your use of the
#define for Spring and the rotate when defining objects, it makes the scene
file much easier to read.  The more I see of POV-Ray the more I like it,
it's an elegant and artistic blend of vector mathematics with computer
programming :)

Thank you very much, and thanks to everyone else who gave it a look too.


Post a reply to this message

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