POV-Ray : Newsgroups : povray.general : How to draw a curve on a surface? : Re: How to draw a curve on a surface? Server Time
5 Oct 2024 14:47:12 EDT (-0400)
  Re: How to draw a curve on a surface?  
From: Tor Olav Kristensen
Date: 28 Sep 2024 19:25:00
Message: <web.66f88fb1bd22d553737cc36e89db30a9@news.povray.org>
"Alfred Knudson" <nomail@nomail> wrote:
> How does one draw a parametric curve on a surface, for example the helyx:
>
>     f(t) - (cos t, sin t, t)
>
> on the surface of a cone x^2 + y^2 = 1?
>
> I can't seem to find anything about plotting cusrves on the manual.

Hi Alfred

The code below might give you a hint of one way to achieve this.

--
Tor Olav
http://subcube.com
https://github.com/t-o-k


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
/*

Cylinders with spiral pigment

By Tor Olav Kristensen, 2024-09-29

https://www.povray.org/documentation/view/3.7.1/395/
https://www.povray.org/documentation/view/3.7.1/448/

*/
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version 3.7;

global_settings { assumed_gamma 1.0 }

#include "functions.inc"

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare Tau = 2*pi;

#declare Cylinder_R = 1.0;
#declare Spiral_R = 0.08;
#declare NoOfHelixes = 1;
#declare NoOfTurns = 1.0; // Per y unit
#declare Shape = 1.0;
#declare CrossSectionType = 1.0; // Circle
#declare CrossSectionRotationAngle = 0.0;

#declare HelixFn =
    function {
        f_helix1(
            x, y, z,
            NoOfHelixes,
            NoOfTurns*Tau,
            Spiral_R,
            Cylinder_R,
            Shape,
            CrossSectionType,
            CrossSectionRotationAngle
        )
    }

#declare HelixIsosurface =
    isosurface {
        function { HelixFn(x, y, z) }
        threshold 0.0
        max_gradient 4.0
        accuracy 0.0001
        contained_by {
            box {
                -2*<1, 1, 1>,
                +2*<1, 1, 1>
            }
        }
        pigment { color rgb <1.0, 1.0, 1.0> }
    }

#declare ColorMap =
    color_map {
        [ 0.5 color rgb <1.0, 0.0, 0.8> ]
        [ 0.5 color rgb <0.0, 0.8, 1.0> ]
    }

#declare CylinderIsosurface =
    isosurface {
        function { f_sphere(x, 0, z, Cylinder_R) }
        threshold 0.0
        max_gradient 4.0
        accuracy 0.0001
        contained_by {
            box {
                -2*<1, 1, 1>,
                +2*<1, 1, 1>
            }
        }
        pigment {
            function { HelixFn(x, y, z) - 0.17 }
            color_map { ColorMap }
        }
    }

#declare Cylinder =
    cylinder {
        -2*y, +2*y, Cylinder_R
        pigment {
            spiral1 1
            color_map { ColorMap }
            rotate +90*x
            scale <1, 1, -1>
            rotate +90*y
        }
    }

union {
    object { CylinderIsosurface }
    object { HelixIsosurface  }
    translate -1.8*x
}

union {
    object { Cylinder }
    object { HelixIsosurface  }
    translate +1.8*x
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

background { color rgb 0.2*<1, 1, 1> }

light_source {
    100*<+1, +3, -1>
    color rgb <1, 1, 1>
    shadowless
}

camera {
    orthographic
    location < 0, +1, -2>*3
    look_at <0, 0, 0>
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

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