POV-Ray : Newsgroups : povray.general : Spring is sprung. Server Time
4 Aug 2024 02:21:33 EDT (-0400)
  Spring is sprung. (Message 8 to 17 of 17)  
<<< Previous 7 Messages Goto Initial 10 Messages
From: Tom Melly
Subject: Re: Spring is sprung.
Date: 23 Sep 2003 11:09:03
Message: <3f70620f$1@news.povray.org>
"Stephen McAvoy" <McA### [at] aolcom> wrote in message
news:c1j0nvccpb4or0qvk6kcm10o73j08mfikq@4ax.com...
> Does any one have ideas for a compressible spring for an animation. I've tried
a
> sphere_sweep but the rendering times are too long for me?

Hmm, well I googled for helix function
which got me http://www.ric.edu/mrodrigues/math411/TheHelix.doc
which got me
#declare fn_X = function(x,y,z) {(x-cos(3*z))*(x-cos(3*z)) + (y -
sin(2*z))*(y-sin(2*z)) - 0.5}

which is fine if you want to model a slinky after a 4yr old with tourette's has
got hold of it.... :(


Post a reply to this message

From: Warp
Subject: Re: Spring is sprung.
Date: 23 Sep 2003 11:09:40
Message: <3f706234@news.povray.org>
Stephen McAvoy <McA### [at] aolcom> wrote:
> Does any one have ideas for a compressible spring for an animation. I've tried a
> sphere_sweep but the rendering times are too long for me?

  There are basically to ways of making this (so that it will render with
an acceptable speed):

  1. Construct the spring with cylinders joined by spheres. Here is an
example of how it can be done:

camera { location -z*20 look_at 0 angle 35 }
light_source { -z*10, 1 }

#declare SpringHeight = 8;
#declare SpringMajorRadius = 1;
#declare SpringMinorRadius = .1;
#declare SpringRevolutions = 10;
#declare SpringSegments = 1000;

union
{
  #declare Ind = 0;
  #while(Ind <= SpringSegments)
    #declare Pos2 =
      vrotate(<SpringMajorRadius, SpringHeight*Ind/SpringSegments, 0>,
              y*360*SpringRevolutions*Ind/SpringSegments);
    #if(Ind > 0)
      cylinder { Pos1, Pos2, SpringMinorRadius }
      sphere { Pos2, SpringMinorRadius }
    #end
    #declare Pos1 = Pos2;
    #declare Ind = Ind+1;
  #end

  pigment { rgb 1 } finish { specular .5 }
  translate -y*4
}

box { <-2,-4,-2><2,-4.1,2> pigment { rgb <.8,.4,.2> } }


     The main problem is that you need a lot of segments to get a smooth
look.

  2. Construct the spring as a mesh. The advantage is that it renders
fast and it will look smooth even with fewer segments (because of
smooth triangles). The problem is that constructing it is a lot
more complicated (so complicated I'm not bothering doing it right now).

-- 
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}//  - Warp -


Post a reply to this message

From: ABX
Subject: Re: Spring is sprung.
Date: 23 Sep 2003 11:18:37
Message: <pjo0nvo1atu096nttqfn2tvgtusd7qcfg7@4ax.com>
On 23 Sep 2003 10:50:22 -0400, "Rafal 'Raf256' Maj" <spa### [at] raf256com> wrote:
> > Have a look at the f_helix* functions in functions.inc:
> > http://www.povray.org/documentation/view/244/
> > Christoph
>
> Hmm is this isosurface actualy *faster* then spheresweep ;) ?

Why do you think it is not ? Not that I think it is faster or slower but I'm
sure there are reasons why Gilles Tran used so many isosurfaces instead of
rounded boxes in http://www.irtc.org/ftp/pub/stills/2001-12-31/gt_asia.jpg .
Internal functions are not that slow.

ABX


Post a reply to this message

From: Stephen McAvoy
Subject: Re: Spring is sprung.
Date: 23 Sep 2003 11:39:14
Message: <p8q0nv4g2h2eifr0peeg0to949059ju33i@4ax.com>
Thanks all. Warp's example is just what I want. That's not to say ABX's and
Christoph's aren't good suggestions. But the example is just at my level of
understanding I will learn as well as have the code.
Regards
        Stephen


Post a reply to this message

From: Stephen McAvoy
Subject: Re: Spring is sprung.
Date: 23 Sep 2003 11:41:53
Message: <h9q0nv0jdkb1c3fgb8gt7sadf8e7ikq83h@4ax.com>
On 23 Sep 2003 11:09:40 -0400, Warp <war### [at] tagpovrayorg> wrote:

>  2. Construct the spring as a mesh. The advantage is that it renders
>fast and it will look smooth even with fewer segments (because of
>smooth triangles). The problem is that constructing it is a lot
>more complicated (so complicated I'm not bothering doing it right now).

Don't even think about it.
If I were to use a mesh I would make it with Helixir 
http://www.evolve.co.uk/helixir/

Regards
        Stephen


Post a reply to this message

From: John VanSickle
Subject: Re: Spring is sprung.
Date: 23 Sep 2003 13:44:09
Message: <3F70865F.5A0CA7EA@hotmail.com>
Warp wrote:
> 
>   2. Construct the spring as a mesh. The advantage is that it renders
> fast and it will look smooth even with fewer segments (because of
> smooth triangles). The problem is that constructing it is a lot
> more complicated (so complicated I'm not bothering doing it right
> now).

I feel another Thoroughly Useful Macro coming on...


Post a reply to this message

From:
Subject: Re: Spring is sprung.
Date: 24 Sep 2003 04:05:47
Message: <3f71505b@news.povray.org>
/*

Hi Stephen!

Here is a macro for springs made of torus-segments: fast, smooth, easy to
use. Copy this whole post to POV-Ray and play with the parameters. I've
included Warp's cylinder-spring for comparison, set UseSpiralMacro to
false to see it.

Spiral with 50 SpringSegments is approximately as fast as 1200 of Warp's
cylinders, but *much* smoother: compare them at a camera angle of 3.5!

If you want to see the borders between the tori, change the 0 in one of the
plane objects to -0.02.

Ideally the spiral should touch a cylinder from inside that has a radius of
SpringMajorRadius+SpringMinorRadius. With the torus method there is a very
small (unavoidable) bulge. This can be seen by setting ShowBulgeError to
true. The value of this error is written to the debug stream.

   Sputnik

*/


// Spiral

// +SP8 +EP8 -FN +A0.1 +AM2 +R3



camera { location -z*20 look_at 0 angle 35 }
light_source { -z*10, 1 }


#declare SpringHeight = 8;
#declare SpringMajorRadius = 1;
#declare SpringMinorRadius = .1;
#declare SpringRevolutions = 10;
#declare SpringSegments = 50; // 5*SpringRevolutions is
                              // enough for #macro Spiral
#declare UseSpiralMacro = true; //
#declare ShowBulgeError = false; // true: shows the Spiral's bulge


// SPIRAL ///////////////////////////////////////////////////////////////////

#macro Spiral ( Radius1, Radius0, Rise, Turns, Segments )

  // Radius1 : major radius
  // Radius1 : minor radius
  // Rise    : height of a single turn
  // Turns   : number of turns (may be non-integer)
  // Segments: number of tori in spiral
  //           (>= 2*Turns; usually 5*Turns ... 10*Turns is enough)

  // some calculations ...
  #local Ang= Turns*360/Segments;
  #local Ri = Rise/2 * Turns/Segments;
  #local Sin= sin(radians(Ang/2));
  #local A  = Radius1*Sin;
  #local B  = sqrt(Radius1*Radius1-A*A);
  #local C  = A*A/B;
  #local DD = Ri*Ri+A*A;
  #local E  = DD/C;
  #local W  = degrees(atan2(C,sqrt(DD)));
  #local R  = sqrt(E*(E+C));

  // single torus-segment
  #declare T =
    intersection {
      torus { R, Radius0 }
      plane { -x, 0 rotate  W*y }
      plane {  x, 0 rotate -W*y }
      bounded_by { box {
        1.001*<-(R+Radius0)*Sin, -Radius0, -(R+Radius0)>,
        1.001*< (R+Radius0)*Sin,  Radius0, -(R-Radius0)*(1-Sin*Sin)>
        } }
      rotate -degrees(atan2(Ri,A))*z
      translate <0, Ri, E-B>
      rotate Ang/2*y
      }

  // the torus-segments have a small bulge
  #local Err = R-Radius1-E+B;
  #debug concat (
    "\nMaximum radius error in 'Spiral' = ", str(Err,0,5),
    " = ", str(Err/Radius1*100,0,3), " %\n"
    )

  // stack the segments
  union {
    #local N = 0;
    #while (N<Segments)
      object { T rotate N*Ang*y translate N*2*Ri*y }
      #local N = N+1;
      #end//while
    // no "}" to allow modifiers

  #end//macro Spiral


/////////////////////////////////////////////////////////////////////////////

#if (UseSpiralMacro)

  // spring consisting of torus-segments
  #declare Spring =
    Spiral (
      SpringMajorRadius,
      SpringMinorRadius,
      SpringHeight/SpringRevolutions,
      SpringRevolutions,
      SpringSegments // 5*SpringRevolutions usually is enough
      ) /* { */ rotate -90*y /* same orientation as Warp's spring */ }

  #if (ShowBulgeError)
      difference {
        object { Spring }
        cylinder { 0, SpringHeight*y, SpringMajorRadius+SpringMinorRadius }
        pigment { rgb 1 } finish { specular .5 }
        translate -4*y
        }
      #else
        object { Spring
          translate -4*y
          pigment { rgb 1 } finish { specular .5 }
          }
    #end//if ShowBulgeError

  #else

    // spring consisting of cylinders as suggested by Warp
    union
    {
      #declare Ind = 0;
      #while(Ind <= SpringSegments)
        #declare Pos2 =
          vrotate(<SpringMajorRadius, SpringHeight*Ind/SpringSegments, 0>,
                  y*360*SpringRevolutions*Ind/SpringSegments);
        #if(Ind > 0)
          cylinder { Pos1, Pos2, SpringMinorRadius }
          sphere { Pos2, SpringMinorRadius }
        #end
        #declare Pos1 = Pos2;
        #declare Ind = Ind+1;
      #end

      pigment { rgb 1 } finish { specular .5 }
      translate -y*4
    }

  #end//if UseSpiralMacro


box { <-2,-4,-2><2,-4.1,2> pigment { rgb <.8,.4,.2> } }


// END //////////////////////////////////////////////////////////////////////


Post a reply to this message

From: Stephen McAvoy
Subject: Re: Spring is sprung.
Date: 24 Sep 2003 09:23:52
Message: <tf63nv02h88tkk0vtsjj9a25qu18vhurac@4ax.com>

<fr### [at] computermuseumfh-kielde> wrote:

>Hi Stephen!

Hi Sputnik,
	It works a treat, thanks for the time and effort. Very instructive using
Warp's as a comparison. 

Regards
        Stephen


Post a reply to this message

From: Steve Shelby
Subject: Re: Spring is sprung.
Date: 24 Sep 2003 09:57:37
Message: <3f71a2d1$1@news.povray.org>
Stephen,
I'm a little late coming to this thread, but I thought you might like to
check out a free program called "helixer", http://www.evolve.co.uk/helixir/
. You can easily make any kind of helix, and import it into Moray or Povray.
Steve Shelby

"Stephen McAvoy" <McA### [at] aolcom> wrote in message
news:p8q0nv4g2h2eifr0peeg0to949059ju33i@4ax.com...
> Thanks all. Warp's example is just what I want. That's not to say ABX's
and
> Christoph's aren't good suggestions. But the example is just at my level
of
> understanding I will learn as well as have the code.
> Regards
>         Stephen


Post a reply to this message

From: Stephen McAvoy
Subject: Re: Spring is sprung.
Date: 24 Sep 2003 11:37:59
Message: <o6e3nv00qpih95d8ivectq9bof3nhelufn@4ax.com>
On Wed, 24 Sep 2003 08:57:36 -0500, "Steve Shelby" <ssh### [at] rexnetnet> wrote:

>I'm a little late coming to this thread, but I thought you might like to
>check out a free program called "helixer", http://www.evolve.co.uk/helixir/
>. You can easily make any kind of helix, and import it into Moray or Povray.

Thanks Steve,
	I have a copy of "helixer" and it has served me well in Moray. I want to
use a couple of springs in an animation so with "helixer" I would need to work
out the intermediary positions as well as the start and end ones. Sputnik's
macro will do the job very well placed in the InsertCode plugin.



Regards
        Stephen


Post a reply to this message

<<< Previous 7 Messages Goto Initial 10 Messages

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