POV-Ray : Newsgroups : povray.newusers : Laying cables : Re: Laying cables Server Time
3 Sep 2024 08:17:29 EDT (-0400)
  Re: Laying cables  
From: Bernard Hatt
Date: 4 Feb 2005 22:56:39
Message: <420443FC.D5EE6851@arkady.demon.co.uk>
Mike Williams wrote:
> A cable suspended between two points should follow a catenary curve. The
> following code draws such a curve between two arbitrary points.
> 
> What it doesn't handle is the requirement that the cable ends are in a
> random direction.

I had a similar macro which uses a cubic spline, you could modify the
1st and last vectors for the spline to change the directions of the end.

#version 3.6;
global_settings {assumed_gamma 1.0}
camera {location  <2,1.5,-10> look_at <2,1.5,2.5> angle 20}
background {rgb 1}
light_source {<-30, 100, -30> color rgb 1}

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

#macro rope(rstart,rend,rdrop,rad)
sphere_sweep
{
    cubic_spline,
    5,
    (rstart*2-rend)+<0,rdrop*4,0>, rad
    rstart, rad
    (rstart+rend)/2-<0,rdrop,0>, rad
    rend, rad
    (rend*2-rstart)+<0,rdrop*4,0>, rad
    pigment {rgb x+y}
}
#end

#declare Start=<1,2,3>; // Start point
#declare End=<3,1,2>;   // End Point
#declare Steps=50;      // Number of sphere_swwp points
#declare Drop=0.666;    // Drop at center of span
#declare R=0.05;        // Radius of the cable

rope(Start,End,Drop,R)

sphere{Start,0.1 pigment {rgb y}}
sphere{End,0.1 pigment {rgb y}}

---

Regards,

Bernard


Post a reply to this message

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