POV-Ray : Newsgroups : povray.newusers : 2D Sin curve Server Time
13 Nov 2024 17:47:12 EST (-0500)
  2D Sin curve (Message 1 to 5 of 5)  
From: Ulrik
Subject: 2D Sin curve
Date: 1 Sep 2000 03:03:12
Message: <39af54b0$1@news.povray.org>
Hi!

I'm just wondering if it's possible to use POV to help me draw 2D sin curves
or if anyone here knows of such a program. I don't want a plotter program
though.

Ulrik


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: 2D Sin curve
Date: 1 Sep 2000 09:50:03
Message: <39AFB2CC.6AC77CE5@online.no>
Ulrik wrote:

> Hi!
>
> I'm just wondering if it's possible to use POV to help me draw 2D sin curves
> or if anyone here knows of such a program. I don't want a plotter program
> though.

It could probably be done much better
(E.g.. better scaling of the axes and showing them),
but below is one possible solution.

I can try to explain if you need more help.


Tor Olav
--
mailto:tor### [at] hotmailcom
http://www.crosswinds.net/~tok/tokrays.html


#version 3.1;
#include "colors.inc"


camera {
   location -16*z
   look_at  <0, 0, 0>
}


light_source { <5000, 1000, -20000> color White }


plane {
  -z, 0
  pigment {
    checker color White color White + Blue
  }
}


#macro PlotFunction(MinAngle, MaxAngle, NrOfSteps,
                    SphereRadius, AngleAxisLength)

  #local RangeSize = MaxAngle - MinAngle;
  #local StepSize = RangeSize/NrOfSteps;
  #local Angle = MinAngle;
  #while (Angle < MaxAngle)
    #local xPos =  Angle*AngleAxisLength/RangeSize;
    #local yPos = MyFunction(radians(Angle));
    sphere { <xPos, yPos, 0>, SphereRadius }
    #local Angle = Angle + StepSize;
  #end // while

#end // macro PlotFunction


#macro MyFunction(Angle)

  4*sin(Angle)

#end // MyFunction


union {
  PlotFunction(-360, 360, 200, 0.1, 20)
  pigment { color Red }
}


/*
#macro MyFunction(Angle)

  (4.2*sin(2*Angle) + 1.8*cos(8*Angle))

#end // MyFunction


union {
  PlotFunction(-180, 360, 800, 0.1, 15)
  pigment { color Green }
}
*/

sphere { <0, 0, 0>, 0.2 pigment { color 2*Yellow } }


Post a reply to this message

From: Warp
Subject: Re: 2D Sin curve
Date: 1 Sep 2000 09:53:14
Message: <39afb4ca@news.povray.org>
Ulrik <ulr### [at] hempassagense> wrote:
: I'm just wondering if it's possible to use POV to help me draw 2D sin curves

  Of course.


#macro Function(X)
  sin(X)
#end

#declare Step=.1;
#declare CurveThickness=.03;

#declare GridSize=10;
#declare GridThickness=.025;

//----------------------------------------------------------------------------
#default { finish { ambient 1 } }
camera { location -z*10 look_at 0 angle 45 orthographic }


#declare Ind=-GridSize/2;
#while(Ind<=GridSize/2)
  #declare Col=(Ind=0?y:z);
  cylinder
  { <Ind,-GridSize/2,GridThickness><Ind,GridSize/2,GridThickness>,GridThickness
    pigment { rgb Col }
  }
  cylinder
  { <-GridSize/2,Ind,GridThickness><GridSize/2,Ind,GridThickness>,GridThickness
    pigment { rgb Col }
  }
  #declare Ind=Ind+1;
#end

union
{ #declare X=-GridSize/2;
  #declare oPos=<X,Function(X),0>;
  #declare X=X+Step;
  #while(X<=GridSize/2)
    #declare Pos=<X,Function(X),0>;
    cylinder { oPos, Pos, CurveThickness }
    sphere { Pos, CurveThickness }
    #declare oPos=Pos;
    #declare X=X+Step;
  #end
  pigment { rgb 1 }
}


-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Mike Williams
Subject: Re: 2D Sin curve
Date: 1 Sep 2000 15:05:37
Message: <Z4rNDDAFV6r5EwFj@econym.demon.co.uk>
Wasn't it Ulrik who wrote:
>
>I'm just wondering if it's possible to use POV to help me draw 2D sin curves
>or if anyone here knows of such a program. I don't want a plotter program
>though.

Do you mean something like this?

#version unofficial MegaPov 0.4;
camera { location  <0, 0, -3> look_at <0, 0, 0>}
background {rgb 1}
light_source {<-100,200,-100> colour rgb 1}

#declare Amplitude = 0.3;
#declare Frequency = 5;
#declare F = function {sin(Frequency*x)*Amplitude}

#declare Thickness = 0.02;
isosurface {
   function {(y-F(x,0,0))^2 + z^2 -Thickness^2}
   accuracy 0.00001
   contained_by {sphere 0,2}
   method 1
}


It produces a thread with cross section of the specified thickness that
follows the 2D shape specified by the function y=F(x). 

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Warp
Subject: Re: 2D Sin curve
Date: 3 Sep 2000 13:43:42
Message: <39b28dce@news.povray.org>
This thread has converted into a "who makes the best povray script to
draw a sine curve" competition :)

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

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