POV-Ray : Newsgroups : povray.general : Plot 3d surface for math funtion Server Time
31 Oct 2024 23:30:35 EDT (-0400)
  Plot 3d surface for math funtion (Message 1 to 5 of 5)  
From: xslittlegrass
Subject: Plot 3d surface for math funtion
Date: 2 Jun 2014 00:00:01
Message: <web.538bf59667911eab4277cb5c0@news.povray.org>
I'm trying to use POV-Ray to plot some mathematical 3d functions, and I can make
a simple plot of the function, but I don't know how to make it look beautiful.

For example, I'm trying to plot this function

y=Sin(x)*Cos(z)

using this code:

isosurface {
function { sin(x)*sin(z)-y }
        accuracy 0.001
        contained_by{box{-2*pi,2*pi}} open
        max_gradient 5
        pigment {rgb .9}
}
camera {
  location <10,10,10>
  look_at   <0.0, 0.0,  0.0>
}

light_source { <50,50,50> 1 }
background { rgb <0,.25,.5> }

and I can get a result look like this
http://imgur.com/jxElYiI

but how can we make it look like this

http://www.mitchr.me/SS/mjrcalc/lispy/exPovWaveGraph-ART_p.png

Any suggestions and comments are appreciated.


Post a reply to this message

From: MichaelJF
Subject: Re: Plot 3d surface for math funtion
Date: 2 Jun 2014 02:10:00
Message: <web.538c149abb296cda8ae775cb0@news.povray.org>
"xslittlegrass" <nomail@nomail> wrote:
> I'm trying to use POV-Ray to plot some mathematical 3d functions, and I can make
> a simple plot of the function, but I don't know how to make it look beautiful.
>
> For example, I'm trying to plot this function
>
> y=Sin(x)*Cos(z)
>
> using this code:
>
> isosurface {
> function { sin(x)*sin(z)-y }
>         accuracy 0.001
>         contained_by{box{-2*pi,2*pi}} open
>         max_gradient 5
>         pigment {rgb .9}
> }
> camera {
>   location <10,10,10>
>   look_at   <0.0, 0.0,  0.0>
> }
>
> light_source { <50,50,50> 1 }
> background { rgb <0,.25,.5> }
>
> and I can get a result look like this
> http://imgur.com/jxElYiI
>
> but how can we make it look like this
>
> http://www.mitchr.me/SS/mjrcalc/lispy/exPovWaveGraph-ART_p.png
>
> Any suggestions and comments are appreciated.

You can use a scaled and translated gradient Pigment with a Color_map. Something
like this

#include "colors.inc"

isosurface {
function { sin(x)*sin(z)-y }
        accuracy 0.001
        contained_by{box{-2*pi,2*pi}} open
        max_gradient 5
        pigment {
           gradient y
           color_map {
              [ 0 Blue ]
              [ 0.5 Green ]
              [ 1 Red ]
           }
           scale 2.02 // a Little bit larger than the object
           translate <0,-1.01,0>
        }
}
camera {
  location <10,10,10>
  look_at   <0.0, 0.0,  0.0>
}

light_source { <50,50,50> 1 }
background { rgb <0,.25,.5> }

May be you will add additional entries to the Color_map.

Best regards,
Michael


Post a reply to this message

From: xslittlegrass
Subject: Re: Plot 3d surface for math funtion
Date: 2 Jun 2014 18:00:06
Message: <web.538cf39cbb296cda1e36f4d20@news.povray.org>
Thanks, that's very helpful.
Does Povray have predefined color functions so that we can use them instead of
manually set the color function every time? for example, commonly used color
function such as
hue, temperature map, jet, etc?

Best,
xslittlegrass



"MichaelJF" <mi-### [at] t-onlinede> wrote:
> "xslittlegrass" <nomail@nomail> wrote:
> > I'm trying to use POV-Ray to plot some mathematical 3d functions, and I can make
> > a simple plot of the function, but I don't know how to make it look beautiful.
> >
> > For example, I'm trying to plot this function
> >
> > y=Sin(x)*Cos(z)
> >
> > using this code:
> >
> > isosurface {
> > function { sin(x)*sin(z)-y }
> >         accuracy 0.001
> >         contained_by{box{-2*pi,2*pi}} open
> >         max_gradient 5
> >         pigment {rgb .9}
> > }
> > camera {
> >   location <10,10,10>
> >   look_at   <0.0, 0.0,  0.0>
> > }
> >
> > light_source { <50,50,50> 1 }
> > background { rgb <0,.25,.5> }
> >
> > and I can get a result look like this
> > http://imgur.com/jxElYiI
> >
> > but how can we make it look like this
> >
> > http://www.mitchr.me/SS/mjrcalc/lispy/exPovWaveGraph-ART_p.png
> >
> > Any suggestions and comments are appreciated.
>
> You can use a scaled and translated gradient Pigment with a Color_map. Something
> like this
>
> #include "colors.inc"
>
> isosurface {
> function { sin(x)*sin(z)-y }
>         accuracy 0.001
>         contained_by{box{-2*pi,2*pi}} open
>         max_gradient 5
>         pigment {
>            gradient y
>            color_map {
>               [ 0 Blue ]
>               [ 0.5 Green ]
>               [ 1 Red ]
>            }
>            scale 2.02 // a Little bit larger than the object
>            translate <0,-1.01,0>
>         }
> }
> camera {
>   location <10,10,10>
>   look_at   <0.0, 0.0,  0.0>
> }
>
> light_source { <50,50,50> 1 }
> background { rgb <0,.25,.5> }
>
> May be you will add additional entries to the Color_map.
>
> Best regards,
> Michael


Post a reply to this message

From: Alain
Subject: Re: Plot 3d surface for math funtion
Date: 4 Jun 2014 21:59:15
Message: <538fcef3@news.povray.org>

> Thanks, that's very helpful.
> Does Povray have predefined color functions so that we can use them instead of
> manually set the color function every time? for example, commonly used color
> function such as
> hue, temperature map, jet, etc?
>
> Best,
> xslittlegrass
>
>

Some patterns do have default colour palletes, those are: bozo, agate, 
wood, checkers (block pattern yellow and green) and hexagon (block 
pattern red, green and blue). All other patterns return a gray gradient 
going from black to white if you don't provide any colour_map.
The thing is that, most of the time, using a user defined map gives 
beter results.

If you find yourself using the same colour map again and again in many 
scenes, you can create an .INC file containing the definition of your 
favourite maps. It's then a simple thing of adding:
#include "My_colour_maps.inc"
to your file and using one of your user colour_map.

An INC file is the same thing as a POV file, it's only the extention 
that is different.


Alain


Post a reply to this message

From: xslittlegrass
Subject: Re: Plot 3d surface for math funtion
Date: 6 Jun 2014 10:35:01
Message: <web.5391d0c6bb296cda1e36f4d20@news.povray.org>
Alain <kua### [at] videotronca> wrote:

> > Thanks, that's very helpful.
> > Does Povray have predefined color functions so that we can use them instead of
> > manually set the color function every time? for example, commonly used color
> > function such as
> > hue, temperature map, jet, etc?
> >
> > Best,
> > xslittlegrass
> >
> >
>
> Some patterns do have default colour palletes, those are: bozo, agate,
> wood, checkers (block pattern yellow and green) and hexagon (block
> pattern red, green and blue). All other patterns return a gray gradient
> going from black to white if you don't provide any colour_map.
> The thing is that, most of the time, using a user defined map gives
> beter results.
>
> If you find yourself using the same colour map again and again in many
> scenes, you can create an .INC file containing the definition of your
> favourite maps. It's then a simple thing of adding:
> #include "My_colour_maps.inc"
> to your file and using one of your user colour_map.
>
> An INC file is the same thing as a POV file, it's only the extention
> that is different.
>
>
> Alain

Thanks a lot! That's very helpful.


Post a reply to this message

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