POV-Ray : Newsgroups : povray.newusers : povray and 3D graphs : Re: povray and 3D graphs Server Time
28 Jul 2024 16:28:20 EDT (-0400)
  Re: povray and 3D graphs  
From: Daniel C  Bastos
Date: 17 Apr 2008 01:42:36
Message: <slrng0d6o7.fin.dbast0s@yahoo.com.br>
In article <4806a90b@news.povray.org>,
Warp wrote:

> Daniel C. Bastos <dba### [at] yahoocombr> wrote:
>> Hi there. I'm interested in plotting some graphs in povray. I have been
>> reading the documentation in the help file, but it is not going torwards
>> telling me how to plot, say, x = cos(t), y = cos(t), z = t. Could
>> someone point me in some direction where I can learn the basics of
>> getting some parametric equations plotted?
>
>   That depends a lot on what is it exactly that you want to plot.
> Eg. plotting a surface is completely different from plotting a curve.
> Your example seems to be a curve.

I see. As it is not obvious for a beginner how to plot, I'll stick to
curves for now. I already imagined that some construction would be
necessary and I'm okay with that. I think I even prefer it like that, so
that as I get to plot one curve, I get to plot any other one, I guess,
as the method seems to be similar.

My question for now would be how to figure out how to rotate the
picture. I can see the helix as if I'm looking at it from the top,
although I look at the plane as if I'm standing on it facing the helix. 

What I would like to do on your code is to keep the plane where it is
--- that would be my xy-plane --- and make the helix start from the
plane and spiral up, because that's how this helix should be as x varies
according to cos(t) and y to sin(t) and z = t. That is, while x and y
circle around, z keeps on going up (or down.)

So what I think it's happening here is that while I keep on thinking on
the xyz-axis as I do, the povray puts the z axis as going from outside
my screen into it. So if I swap y and z I should get what I'd like, and
apparently I do.

I also took your code and plotted it from -25pi to 25pi and it spirals
just right. Cool. I'm impressed. This is what I'm looking for. Thanks
for the introduction.

>   There is no direct support for curves per se, but you can approximate
> one by, for example, creating tiny cylinders along the curve, for example
> like this:
>
> #declare X = function(T) { sin(T) };
> #declare Y = function(T) { cos(T) };
> #declare Z = function(T) { T };
>
> #declare CylRadius = .05;
> #declare MinT = 0;
> #declare MaxT = 2*pi;
> #declare Steps = 100;
>
> union
> { #declare Ind = 0;
>   #while(Ind < Steps)
>     #declare T1 = MinT + (MaxT-MinT)*Ind/Steps;
>     #declare T2 = MinT + (MaxT-MinT)*(Ind+1)/Steps;
>     #declare P1 = <X(T1), Y(T1), Z(T1)>;
>     #declare P2 = <X(T2), Y(T2), Z(T2)>;
>     sphere { P1, CylRadius }
>     cylinder { P1, P2, CylRadius }
>     #declare Ind = Ind+1;
>   #end
>
>   pigment { rgb x } finish { specular .5 }
> }
>
> camera { location -z*5 look_at 0 angle 35 }
> light_source { <100, 200, -300>, 1 }
> plane { y, -1.5 pigment { checker rgb 1, rgb .5 scale 10 } }


Post a reply to this message

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