POV-Ray : Newsgroups : povray.advanced-users : Beeing stupid... y=x*sin(1/x), how to? Server Time
26 Dec 2024 14:13:40 EST (-0500)
  Beeing stupid... y=x*sin(1/x), how to? (Message 1 to 6 of 6)  
From: Mario Splivalo
Subject: Beeing stupid... y=x*sin(1/x), how to?
Date: 15 Dec 1999 12:38:00
Message: <MPG.12c18e98202e9328989683@news.povray.org>
Anyone, please, i'd love to plot a graph of the function, well, it's like 
this:

I have y = x * sin(1/x), and its some graph in 2D, Well, now i want to 
rotate that graph around the z-axe (one pointing up/down), and represent 
that in POV. Is that possible withouht 3rd party programs/utils?
	
	Mike


Post a reply to this message

From: Chris Huff
Subject: Re: Beeing stupid... y=x*sin(1/x), how to?
Date: 15 Dec 1999 15:30:54
Message: <chrishuff_99-E0211D.15312415121999@news.povray.org>
In article <MPG.12c18e98202e9328989683@news.povray.org>, Mario Splivalo 
<msp### [at] jagorsrcehr> wrote:

> Anyone, please, i'd love to plot a graph of the function, well, it's like 
> this:
> 
> I have y = x * sin(1/x), and its some graph in 2D, Well, now i want to 
> rotate that graph around the z-axe (one pointing up/down), and represent 
> that in POV. Is that possible withouht 3rd party programs/utils?

If you mean you want to make a kind of lathe, swept around the z axis, 
it would be pretty simple to do. One way would be to use an isosurface, 
with a function like:
function {z - sqrt(x^2 + y^2)*sin(1/sqrt(x^2 + y^2))}
replacing x with sqrt(x^2 + y^2), which is the distance from the z axis.

Another way would be to use an actual lathe object, and use a #while 
loop to calculate the position of each control point.

Or if you want to represent the actual graph in POV, not making a 3D 
graph, you can use an image_map to use a picture of the graph for the 
texture, or you can create it out of objects, something like 
this(untested!):

#macro GetValAt(V)
    (V*sin(1/V))
#end
#macro MakeGraph(Elems, XSize, graphRadius, graphTexture)
    #local stPos = < 0, 0, 0>;
    sphere {stPos, graphRadius
        texture {graphTexture}
    }
    #local K=0;
    #while(K<Elems)
        #local endPos = <(K/(Elems - 1))*XSize, GetValAt((K/(Elems - 
1))*XSize), 0>;
        cylinder {stPos, endPos, graphRadius
            texture {graphTexture}
        }
        sphere {endPos, graphRadius
            texture {graphTexture}
        }
        #local stPos = endPos;
        #local K=K+1;
    #end
#end

This macro would be used like this:
MakeGraph(50, 5, 0.05, MyTexture)

Where:
Elems = the number of elements in the graph
XSize = the distance along the x axis the graph extends
graphRadius = the radius of the graph elements
graphTexture = the texture of the graph elements

-- 
Chris Huff
e-mail: chr### [at] yahoocom
Web page: http://chrishuff.dhs.org/


Post a reply to this message

From: Matt Giwer
Subject: Re: Beeing stupid... y=x*sin(1/x), how to?
Date: 15 Dec 1999 17:53:49
Message: <385845FC.F5F68C0E@ij.net>
Mario Splivalo wrote:

> Anyone, please, i'd love to plot a graph of the function, well, it's like
> this:
>
> I have y = x * sin(1/x), and its some graph in 2D, Well, now i want to
> rotate that graph around the z-axe (one pointing up/down), and represent
> that in POV. Is that possible withouht 3rd party programs/utils?

    2D plot

#declare i = .001 ;
#declare inc = 10 ;

#while (i<inc)
sphere { 0.0, .005 translate <i,i*sin(2*pi/i),0>
texture{pigment {radial frequency 8} finish{specular 1}} }

#declare i = i + 1/1000 ;
#end

And a 3D version if interested

#declare i = .001 ;
#declare inc = 10 ;

#while (i<inc)
sphere { 0.0, .005 translate <i,i*sin(2*pi/i),i*cos(2*pi/i)>
texture{pigment {radial frequency 8} finish{specular 1}} }

#declare i = i + 1/1000 ;
#end

    Take the 2D version out to some value of x and then bring it back to zero
along i*sin(2*pi/i)+.00001 or a larger number if you want a noticable
thickness.

    But instead of plotting it, write the x and y values to a file, search on
File I/O to learn that. Then import the file and tag it as a surface of
rotation, SOR.

    Should work.


Post a reply to this message

From: Mario Splivalo
Subject: Re: Beeing stupid... y=x*sin(1/x), how to?
Date: 19 Dec 1999 19:26:19
Message: <MPG.12c7343caf4ca57d989687@news.povray.org>
In article <chrishuff_99-E0211D.15312415121999@news.povray.org>, 
chr### [at] yahoocom says...
> In article <MPG.12c18e98202e9328989683@news.povray.org>, Mario Splivalo 
> <msp### [at] jagorsrcehr> wrote:
> 
> > Anyone, please, i'd love to plot a graph of the function, well, it's like 
> > this:
> > 
> > I have y = x * sin(1/x), and its some graph in 2D, Well, now i want to 
> > rotate that graph around the z-axe (one pointing up/down), and represent 
> > that in POV. Is that possible withouht 3rd party programs/utils?
> 
> If you mean you want to make a kind of lathe, swept around the z axis, 
> it would be pretty simple to do. One way would be to use an isosurface, 
> with a function like:
> function {z - sqrt(x^2 + y^2)*sin(1/sqrt(x^2 + y^2))}
> replacing x with sqrt(x^2 + y^2), which is the distance from the z axis.

Yes, and I get nothing... Or I am doing something wrong ;(

> 
> Another way would be to use an actual lathe object, and use a #while 
> loop to calculate the position of each control point.

Yes, that, i think, will be the only way....

> Or if you want to represent the actual graph in POV, not making a 3D 
> graph, you can use an image_map to use a picture of the graph for the 
> texture, or you can create it out of objects, something like 
> this(untested!):
> 

I need a 3D :)

	MIke


Post a reply to this message

From: Mario Splivalo
Subject: Re: Beeing stupid... y=x*sin(1/x), how to?
Date: 19 Dec 1999 19:27:36
Message: <MPG.12c73490f3b14807989688@news.povray.org>
In article <385845FC.F5F68C0E@ij.net>, jul### [at] ijnet says...
> Mario Splivalo wrote:
> 
> > Anyone, please, i'd love to plot a graph of the function, well, it's like
> > this:
> >
> > I have y = x * sin(1/x), and its some graph in 2D, Well, now i want to
> > rotate that graph around the z-axe (one pointing up/down), and represent
> > that in POV. Is that possible withouht 3rd party programs/utils?
> 
>     2D plot
> 
> #declare i = .001 ;
> #declare inc = 10 ;
> 
> #while (i<inc)
> sphere { 0.0, .005 translate <i,i*sin(2*pi/i),0>
> texture{pigment {radial frequency 8} finish{specular 1}} }
> 
> #declare i = i + 1/1000 ;
> #end
> 
> And a 3D version if interested
> 
> #declare i = .001 ;
> #declare inc = 10 ;
> 
> #while (i<inc)
> sphere { 0.0, .005 translate <i,i*sin(2*pi/i),i*cos(2*pi/i)>
> texture{pigment {radial frequency 8} finish{specular 1}} }
> 
> #declare i = i + 1/1000 ;
> #end
> 
>     Take the 2D version out to some value of x and then bring it back to zero
> along i*sin(2*pi/i)+.00001 or a larger number if you want a noticable
> thickness.
> 
>     But instead of plotting it, write the x and y values to a file, search on
> File I/O to learn that. Then import the file and tag it as a surface of
> rotation, SOR.

Hm, yes, it does, but, when making an fly-trough animation, it looks 
ditch....

Can it be done using cubic, quadric, or quatric, or matrix, or something/

	Mike


Post a reply to this message

From: Chris Huff
Subject: Re: Beeing stupid... y=x*sin(1/x), how to?
Date: 19 Dec 1999 19:51:17
Message: <chrishuff_99-2E2D41.19515619121999@news.povray.org>
In article <MPG.12c7343caf4ca57d989687@news.povray.org>, Mario Splivalo 
<msp### [at] jagorsrcehr> wrote:

> > If you mean you want to make a kind of lathe, swept around the z axis, 
> > it would be pretty simple to do. One way would be to use an isosurface, 
> > with a function like:
> > function {z - sqrt(x^2 + y^2)*sin(1/sqrt(x^2 + y^2))}
> > replacing x with sqrt(x^2 + y^2), which is the distance from the z 
> > axis.
> 
> Yes, and I get nothing... Or I am doing something wrong ;(

What is the isosurface you are using? Try something like this:

#include "colors.inc"

camera {
   location <0, 3.5, -10>
   look_at <0, 0, 0>
   angle 35
}

isosurface {
   function {y - sqrt(x^2 + z^2)*sin(1/sqrt(x^2 + z^2))}
   eval                       
// max_gradient 1.1
   threshold 0
   bounded_by {box {<-2,-2, 0>, < 2, 2, 2>}}
   //Make a cross-section of the surface
   //use clipped_by to make just the surface visible
   accuracy 0.001
   texture {
      pigment {color rgb < 0.095, 0.44, 0.2 >}
      finish {ambient 0.35}
   }
   scale 2 rotate y*45
}

light_source {< -40, 75, -40> color White}

-- 
Chris Huff
e-mail: chr### [at] yahoocom
Web page: http://chrishuff.dhs.org/


Post a reply to this message

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