POV-Ray : Newsgroups : povray.binaries.images : True catenary : Re: True catenary Server Time
5 Nov 2024 12:36:24 EST (-0500)
  Re: True catenary  
From: PM 2Ring
Date: 1 Aug 2005 09:50:00
Message: <web.42ee24d35de03cff1befe64a0@news.povray.org>
Here are a few positioning macros (and an iron link I borrowed from Chris
Colefax's Link.inc). The attached image is from a slightly different view
location & probably using links of a different size.

//-------------------------------------------------------------------------

// Persistence of Vision Ray Tracer Scene Description File
// File: Catenary.pov
// Vers: 3.6
// Desc: Catenaries between multiple poles arranged in polygons
// Date: 2005.07.30
// Auth: PM 2Ring
//
// -f +A0.4 +AM2 +R1
// -d +A0.2 +AM2 +R4
// -d +A0.1 +AM2 +R3
// -d +A0.05 +AM2 +R3
//

//Chain making macro
#include "Catenary.inc"

global_settings {
  assumed_gamma 1.0
  max_trace_level 25
}

//Textures ----------------------------------------

#declare Shiny =
finish{
  phong .35 phong_size 320
  ambient 0.1 diffuse 0.85 reflection 0.15
}

#declare TChain =
texture{
  //pigment{rgb 1}
  pigment{rgb <1, .8, .15>}
  finish{Shiny metallic
  diffuse 0.25 brilliance 7 reflection {0.55, .65 metallic}
  }
}

#declare TTerminal =
texture{
  //pigment{rgb 1}
  pigment{rgb <.2, .5, 1>}
  finish{
    Shiny
    reflection {0.35,.45 metallic} diffuse 0.4 brilliance 5
  }
}

//-------------------------------------------------------------------------

//Link objects
#declare Torus1 = torus {.75, .175 scale 0.05*<1, 1, .65> texture{TChain}}

//From LinkObjs.inc by Chris Colefax
#declare Iron_Chain =
union {
  torus {.7, .3 clipped_by {box {<-1, -.3, -1>, <0, .3, 1>}} translate -x *
.....6}
  torus {.7, .3 clipped_by {box {<-1, -.3, -1>, <0, .3, 1>}} translate -x *
.....6 scale <-1, 1, 1>}
  cylinder {-x*.6, x*.6, .3 translate z * .7}
  cylinder {-x*.6, x*.6, .3 translate -z * .7}
  pigment {rgb <.4, .4, .45>} normal {dents .6 scale .3} finish {phong .3
phong_size 10 metallic}
  scale .035
}

//-------------------------------------------------------------------------

//Simple chain macro. Parameters: Start point,End Point. Make sure other
items are declared before calling!
#macro ChainQ(Start, End) Chain(Link, Start, End, Slack, Overlap, Twist)
#end
//#macro ChainQ(Start, End)#end  //No Chains!

//Chain terminal post
#macro Terminal(Pos)
union{
  sphere{Pos, PostRad*1.6}
  cylinder{Pos*<1,0,1>, Pos-0.35*PostRad*y, PostRad}

  pigment{rgb <.2, .5, 1>}
  texture{TTerminal}
}
#end

//Chain, with terminal at start
#macro TermChain(Start, End)
  Terminal(Start)
  ChainQ(Start, End)
#end

//-Positioning
macros--------------------------------------------------------

//Connect all points in PosList with chain. Terminate if not a ring.
#macro MultiChain(PosList)
  #local N=dimension_size(PosList,1);
  #local I=0;
  #while(I<N-1)
    #local Start = PosList[I];
    #local End = PosList[I+1];
      TermChain(Start, End)
    #local I=I+1;
  #end

  #if(vlength(End-PosList[0]))
    Terminal(End)
  #end
#end

//Connect all points in PosList to a centre post
#macro CenterChain(PosList)
  #local N=dimension_size(PosList,1);
  #local I=0;
  #local End = <0, 1.25*Rad, 0>;
  #while(I<N-1)
    #local Start = PosList[I];
    ChainQ(Start, End)
    #local I=I+1;
  #end

  Terminal(End)
#end

//Connect all points in PosList0 to Poslist1, like threading shoelaces. No
error checking!
#macro ThreadChain(PosList0, PosList1)
  #local N=dimension_size(PosList0,1);
  #local I=0;
  #while(I<N)
    #local Start = PosList0[I];
    #local End = PosList1[I];
    ChainQ(Start, End)

    #local Start = PosList0[mod(I+1,N)];
    ChainQ(Start, End)

    #local I=I+1;
  #end
#end

// The scene ----------------------------------------

#declare Rad = 2.25;

//Link object
#declare Link = Torus1;
//#declare Link = Iron_Chain;

#declare Slack=1.35;       // Slackness of the chain
#declare Overlap=1.60;     //Link overlap
#declare Twist = 0;               //Chain twist (in cycles)

#declare PostRad=.05;      //Post radius
#declare MI = 5;           //Polygon sides
#declare InRing = array[MI+1];
#declare OutRing = array[MI+1];

#declare I=0;
#declare DT=pi/MI;
#while (I<=MI)
  #declare T = 2 * pi * I/MI;
  #declare InRing[I] = Rad*<cos(T), 0.75, sin(T)>;
  #declare OutRing[I] = 1.5*Rad*<cos(T+DT), .35, sin(T+DT)>;
  #declare I=I+1;
#end
MultiChain(InRing)

#declare Slack = Slack / 1.1;
CenterChain(InRing)

#declare Slack = Slack / 1.1;
MultiChain(OutRing)
ThreadChain(InRing, OutRing)

//Simple room with checkered floor
#declare WS = 4*Rad;
box{<-1, -2/WS, -2>, <1, 3, 2> scale WS inverse pigment{gradient y scale
3.001*WS}}
box{<-1, -1/WS, -2>, <1, 0, 2> scale WS pigment{checker rgb 1,rgb
...05}finish{Shiny}}

camera {
  location <1, 4.5, -10> * 1.25
  look_at  y*0.50
  angle 30
}

light_source {<-2, 8, -3>*2 rgb 1}

// ----------------------------------------


Post a reply to this message


Attachments:
Download 'catenaryd1.jpg' (170 KB)

Preview of image 'catenaryd1.jpg'
catenaryd1.jpg


 

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