POV-Ray : Newsgroups : povray.newusers : Rotations not working as expected : Re: Rotations not working as expected Server Time
30 Jul 2024 10:18:07 EDT (-0400)
  Re: Rotations not working as expected  
From: Marvin T
Date: 20 May 2004 14:03:51
Message: <40acf307$1@news.povray.org>
Mike Williams 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"
> 

Pretty similar to what I came up with, but I used macros in case the 
rods moved independently.  Okay, so it's not in the original 
description, but ... doh.

Anyway, try animating this w/clock [0...1].   BTW, can someone clue me 
in to why the springs seem to be too long?  I'm not seeing it...

M

--------
#include "colors.inc"
#include "metals.inc"
#include "functions.inc"
#include "transforms.inc"

#declare cyl_radius=0.07;
#declare spr_maj_radius=0.05;
#declare spr_min_radius=0.01;

camera {
    location <2, 1.25, -2.5>
    look_at <0, 1.25, 0>
}

// Make it move:
#macro theta(n) (pi*(2+sin((n)*2*pi))/8) #end
#declare phi = 0.0;

//
// Create a rod of length 2 that is rotated by ANG1 and ANG2 (radians)
// And set CPT to be the centerpoint of this rod.
//
#macro Rod(ang1, ang2, cpt)
    #local   _xx = cos(ang1)*sin(ang2);
    #local   _yy = sin(ang1);
    #local   _zz = cos(ang1)*cos(ang2);
    #declare cpt = <_xx,_yy,_zz>;

cylinder {
    0, 2*cpt, cyl_radius
    texture {
       T_Chrome_3A // Pre-defined texture
       scale 4     // Scale by the same ammount in all directions
    }
}
#end

#macro Spring( pt1, pt2 )
#local _leng = vlength(pt2-pt1);
#local _cpt  = (pt2-pt1)/2;

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
       scale 4
    }
    transform {Point_At_Trans (pt2-pt1)}
    translate (pt2+pt1)/2
}
#end

// The center points.
#declare cpt0 = <0,0,0>;
#declare cpt1 = <0,0,0>;
#declare cpt2 = <0,0,0>;
#declare cpt3 = <0,0,0>;

// Declare the rods and get their center points.
Rod( theta(clock+0.0), phi+pi*0.0, cpt0 )
Rod( theta(clock+0.2), phi+pi*0.5, cpt1 )
Rod( theta(clock+0.4), phi+pi*1.0, cpt2 )
Rod( theta(clock+0.6), phi+pi*1.5, cpt3 )

// Stretch a string between adjacent centers:
Spring( cpt0, cpt1 )
Spring( cpt1, cpt2 )
Spring( cpt2, cpt3 )
Spring( cpt3, cpt0 )

light_source { <2, 4, -3> color White }
light_source { <-2, -4, -3> color White }


Post a reply to this message

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