POV-Ray : Newsgroups : povray.newusers : Laying cables : Re: Laying cables Server Time
3 Sep 2024 08:16:11 EDT (-0400)
  Re: Laying cables  
From: Mike Williams
Date: 4 Feb 2005 21:32:10
Message: <+FU8eEAo+CBCFwdX@econym.demon.co.uk>
Wasn't it Ekki Plicht who wrote:
>Hi,
>not exactly new to povray, but not very much experience...
>
>I have a scene where I have two points in space which I want to connect with
>a cable. The points are (can be) absolute random in space, the orientation
>from which direction the cable enters the point is also random.
>
>The cable should follow a gentle, elegant curve from one point to the other,
>giving it a natural look of a quite rigid, not very supple cable. (As a
>matter of fact it's a coaxial cable, abt. 10mm thick in reality).
>
>I know I can use a sphere_sweep in general, but how do I calculate the
>points to follow from one point to another?

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.


#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}

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

#declare Start=<1,2,3>; // Start point
#declare End=<3,1,2>;   // End Point
#declare Steps=50;      // Number of sphere_swwp points
#declare Slack=5;       // Slackness of the cable
#declare R=0.05;        // Radius of the cable

sphere_sweep {
  linear_spline
  Steps+1,
  #declare N=0;
  #declare X=Start.x;
  #while (N<=Steps)
    #declare Z = Start.z*(1-N/Steps) + End.z*(N/Steps);
    #declare Y1 = Start.y*(1-N/Steps) + End.y*(N/Steps);
    #declare Y2 = cosh(N/Steps - 0.5)-cosh(0.5);
    #declare Y=Y1+Y2*Slack;
    <X, Y, Z>,R
    #declare X=X+(End.x-Start.x)/Steps;
    #declare N=N+1;
  #end
  pigment {rgb x}
}

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



-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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