POV-Ray : Newsgroups : povray.newusers : 2D Sin curve : Re: 2D Sin curve Server Time
5 Nov 2024 05:26:28 EST (-0500)
  Re: 2D Sin curve  
From: Tor Olav Kristensen
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

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