POV-Ray : Newsgroups : povray.general : How to draw a curve on a surface? Server Time
31 Oct 2024 06:14:45 EDT (-0400)
  How to draw a curve on a surface? (Message 1 to 6 of 6)  
From: Alfred Knudson
Subject: How to draw a curve on a surface?
Date: 28 Sep 2024 15:40:00
Message: <web.66f85a9d9afc2c8b9aee7de5fd8c677b@news.povray.org>
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.


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: How to draw a curve on a surface?
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

From: Tor Olav Kristensen
Subject: Re: How to draw a curve on a surface?
Date: 28 Sep 2024 20:15:00
Message: <web.66f89b42bd22d553737cc36e89db30a9@news.povray.org>
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> "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.
>...

This may be a better example for you.

You can also replace the cylinder and the spiral objects with isosurfaces.

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


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

Cylinder with parametric spiral pigment

By Tor Olav Kristensen, 2024-09-29

*/
// ===== 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 Radius = 1.5;

// Fn(s): <Radius*cos(s), Radius*sin(s), s>

#declare Helix_FnX = function(s) { Radius*cos(s) };
#declare Helix_FnY = function(s) { Radius*sin(s) };
#declare Helix_FnZ = function(s) { s };

#declare N = 1000;

#declare MinT = -2.5*Tau;
#declare MaxT = +2.5*Tau;
#declare dT = (MaxT - MinT)/N;

#declare R = 0.4;
#declare Spiral =
    union {
        #declare T_Previous = MinT;
        #declare pPrevious =
            <
                Helix_FnX(T_Previous),
                Helix_FnY(T_Previous),
                Helix_FnZ(T_Previous)
            >
        ;
        sphere { pPrevious, R }
        #for (I, 0, N - 1)
            #declare T_Next = T_Previous + dT;
            #declare pNext =
                <
                    Helix_FnX(T_Next),
                    Helix_FnY(T_Next),
                    Helix_FnZ(T_Next)
                >
            ;
            cylinder { pPrevious, pNext, R }
            sphere { pNext, R }
            #declare T_Previous = T_Next;
            #declare pPrevious = pNext;
        #end // for
    }

cylinder {
    MinT*z, MaxT*z, Radius
    pigment {
        object {
            Spiral
            color rgb <0.0, 0.3, 1.0> // Outside
            color rgb <1.0, 0.7, 0.0> // Inside
        }
    }
}

/*
object {
    Spiral
    pigment { color rgb <1.0, 1.0, 1.0> }
}
*/

// ===== 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, +3, -8>*2
    look_at <0, 0, 0>
}

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


Post a reply to this message

From: Alfred Knudson
Subject: Re: How to draw a curve on a surface?
Date: 29 Sep 2024 23:35:00
Message: <web.66fa1bc8bd22d5539aee7de5fd8c677b@news.povray.org>
So, it is really true that there is no framework to "draw" on a surface? And one
has to mimic it with pigmentation, sequence of cylindes, ....


Post a reply to this message

From: ingo
Subject: Re: How to draw a curve on a surface?
Date: 30 Sep 2024 01:25:00
Message: <web.66fa3518bd22d55317bac71e8ffb8ce3@news.povray.org>
"Alfred Knudson" <nomail@nomail> wrote:
> So, it is really true that there is no framework to "draw" on a surface? And one
> has to mimic it with pigmentation, sequence of cylindes, ....

There are a few spline based shapes, spheresweep, sor and prism. But with these
you are bound to the spline options they provide.

An alternative is to loft along a spline or curve and thus create a mesh, then
you have full freedom. Look at meshmaker.inc in the distribution for some ideas.
curves.zip at https://ingoogni.nl/download/ has many curves and splines. One
could also loft one parametric along an other parametric, for example to create
a torus.

ingo


Post a reply to this message

From: Bald Eagle
Subject: Re: How to draw a curve on a surface?
Date: 30 Sep 2024 10:30:00
Message: <web.66fab550bd22d5536563700825979125@news.povray.org>
"Alfred Knudson" <nomail@nomail> wrote:
> So, it is really true that there is no framework to "draw" on a surface? And one
> has to mimic it with pigmentation, sequence of cylindes, ....

Well, the thing is - POV-Ray is a raytracer, and nearly everything that it deals
with is a 3D object.  There's no inherent way to "draw" infinitely thin 2D
lines.

Plus, there needs to be a way to determine where the surface is.

So, you can create some sort of visible 3D object such as a sphere-sweep, linked
cylinders and spheres, a parametric, and isosurface, etc to position a visible
object that follows the surface according to how you want to draw your line.

If you want the line to be flat and literally ON the surface, you could use the
object {} pattern, and color the surface on way where the line is, and another
way where the line is not.
https://wiki.povray.org/content/Reference:Object_Pattern

There are likely other somewhat functionally equivalent methods - but providing
a link as to exactly what you're looking to do would the most helpful in terms
of finding an answer.

- Bill


Post a reply to this message

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