POV-Ray : Newsgroups : povray.general : how to make a revolution plot from a parametric function? Server Time
24 Dec 2024 20:44:53 EST (-0500)
  how to make a revolution plot from a parametric function? (Message 1 to 8 of 8)  
From: xslittlegrass
Subject: how to make a revolution plot from a parametric function?
Date: 2 Jun 2014 18:10:01
Message: <web.538cf5fb7c057d0c1e36f4d20@news.povray.org>
Is it possible to create a revolution plot directly from a parametric function?

For example, I have a 2d parametric function

x[u]=Cos[u]*(1 + 2 Cos[2 u])
y[u]=Sin[u]*(1+2Cos[2 u])

and the function looks like this when plot of u from 0 to pi

http://imgur.com/nfEAOs8

how can we rotate it around the x axis and make it into a revolution plot like
this

http://imgur.com/7MWbnT2

Thanks for the help in advance.


Post a reply to this message

From: JimT
Subject: Re: how to make a revolution plot from a parametric function?
Date: 5 Jun 2014 03:40:00
Message: <web.53901d8135ccce6fbe7517870@news.povray.org>
> Is it possible to create a revolution plot directly from a parametric function?
>
> For example, I have a 2d parametric function
>
> x[u]=Cos[u]*(1 + 2 Cos[2 u])
> y[u]=Sin[u]*(1+2Cos[2 u])
>
In this case, yes.

Since x = rcos(theta) and y = rsin(theta) in standard polars, your parametric
equations are just saying
r   = 1+2cos(2theta)
    = 1+2cos^2(theta)-2sin^2(2theta)
    = 3cos^2(theta) - sin^2(2theta)
    = (3x^2 - y^2)/r^2
r^3 = (3x^2 - y^2)
Square to pick up the negative r lobes
r^6 = (3x^2 - y^2)^2
In 2D
(x^2+y^2)^3 = (3x^2 - y^2)^2
To go to 3D, to be axi-symmetric around the x axis, replace y^2 with y^2+z^2.
Replacing x^2 by x^2+z^2 would be axi-symmetric around the y axis. A similar
shape, but the large lobe rotates to a "disk".

#include "colors.inc"

#declare surftest =
isosurface {
 function { pow(x*x+y*y+z*z,3)-pow(3*x*x-y*y-z*z,2)}
// evaluate 356*Min_factor,  sqrt(356/(356*Min_factor)),  0.7
 max_gradient 1500
 all_intersections
 contained_by { sphere { 0 3}}
 clipped_by {box {-3 3}}
 pigment {Red}
 finish { phong 0.6 reflection 0.2 }
}
object{surftest }
background{White}
light_source { <20,20,20> color 1}
camera{location <0, 0, 20> look_at <0, 0, 0> angle 40}

Produces the surface.Note the rather large max_gradient. For a while, with
smaller max_gradient, I wasn't getting anything.

Thanks,

JimT


Post a reply to this message

From: Alain
Subject: Re: how to make a revolution plot from a parametric function?
Date: 5 Jun 2014 12:50:15
Message: <53909fc7$1@news.povray.org>


> #declare surftest =
> isosurface {
>   function { pow(x*x+y*y+z*z,3)-pow(3*x*x-y*y-z*z,2)}
> // evaluate 356*Min_factor,  sqrt(356/(356*Min_factor)),  0.7
>   max_gradient 1500
>   all_intersections
>   contained_by { sphere { 0 3}}
>   clipped_by {box {-3 3}}
>   pigment {Red}
>   finish { phong 0.6 reflection 0.2 }
> }


>
> JimT
>

A simplification when using evaluate:

sqrt(356/(356*Min_factor)) = sqrt(1/Min_factor)

In this case, the following should work correctly and should be faster:

#declare Min_factor = 0.6;
evaluate 1500*Min_factor,  sqrt(1/1Min_factor),  0.7


Alain


Post a reply to this message

From: xslittlegrass
Subject: Re: how to make a revolution plot from a parametric function?
Date: 6 Jun 2014 10:40:01
Message: <web.5391d25035ccce6f1e36f4d20@news.povray.org>
"JimT" <nomail@nomail> wrote:
> > Is it possible to create a revolution plot directly from a parametric function?
> >
> > For example, I have a 2d parametric function
> >
> > x[u]=Cos[u]*(1 + 2 Cos[2 u])
> > y[u]=Sin[u]*(1+2Cos[2 u])
> >
> In this case, yes.
>
> Since x = rcos(theta) and y = rsin(theta) in standard polars, your parametric
> equations are just saying
> r   = 1+2cos(2theta)
>     = 1+2cos^2(theta)-2sin^2(2theta)
>     = 3cos^2(theta) - sin^2(2theta)
>     = (3x^2 - y^2)/r^2
> r^3 = (3x^2 - y^2)
> Square to pick up the negative r lobes
> r^6 = (3x^2 - y^2)^2
> In 2D
> (x^2+y^2)^3 = (3x^2 - y^2)^2
> To go to 3D, to be axi-symmetric around the x axis, replace y^2 with y^2+z^2.
> Replacing x^2 by x^2+z^2 would be axi-symmetric around the y axis. A similar
> shape, but the large lobe rotates to a "disk".
>
> #include "colors.inc"
>
> #declare surftest =
> isosurface {
>  function { pow(x*x+y*y+z*z,3)-pow(3*x*x-y*y-z*z,2)}
> // evaluate 356*Min_factor,  sqrt(356/(356*Min_factor)),  0.7
>  max_gradient 1500
>  all_intersections
>  contained_by { sphere { 0 3}}
>  clipped_by {box {-3 3}}
>  pigment {Red}
>  finish { phong 0.6 reflection 0.2 }
> }
> object{surftest }
> background{White}
> light_source { <20,20,20> color 1}
> camera{location <0, 0, 20> look_at <0, 0, 0> angle 40}
>
> Produces the surface.Note the rather large max_gradient. For a while, with
> smaller max_gradient, I wasn't getting anything.
>
> Thanks,
>
> JimT

Thanks. That's very helpful.
But can we get the most outer surface of the plot? I mean can we make the
surface into a single solid object without all the internal structures?
And what does this line mean "evaluate 356*Min_factor,
sqrt(356/(356*Min_factor)),  0.7" ?


Post a reply to this message

From: Alain
Subject: Re: how to make a revolution plot from a parametric function?
Date: 8 Jun 2014 18:24:19
Message: <5394e293$1@news.povray.org>

> "JimT" <nomail@nomail> wrote:
>>> Is it possible to create a revolution plot directly from a parametric function?
>>>
>>> For example, I have a 2d parametric function
>>>
>>> x[u]=Cos[u]*(1 + 2 Cos[2 u])
>>> y[u]=Sin[u]*(1+2Cos[2 u])
>>>
>> In this case, yes.
>>
>> Since x = rcos(theta) and y = rsin(theta) in standard polars, your parametric
>> equations are just saying
>> r   = 1+2cos(2theta)
>>      = 1+2cos^2(theta)-2sin^2(2theta)
>>      = 3cos^2(theta) - sin^2(2theta)
>>      = (3x^2 - y^2)/r^2
>> r^3 = (3x^2 - y^2)
>> Square to pick up the negative r lobes
>> r^6 = (3x^2 - y^2)^2
>> In 2D
>> (x^2+y^2)^3 = (3x^2 - y^2)^2
>> To go to 3D, to be axi-symmetric around the x axis, replace y^2 with y^2+z^2.
>> Replacing x^2 by x^2+z^2 would be axi-symmetric around the y axis. A similar
>> shape, but the large lobe rotates to a "disk".
>>
>> #include "colors.inc"
>>
>> #declare surftest =
>> isosurface {
>>   function { pow(x*x+y*y+z*z,3)-pow(3*x*x-y*y-z*z,2)}
>> // evaluate 356*Min_factor,  sqrt(356/(356*Min_factor)),  0.7
>>   max_gradient 1500
>>   all_intersections
>>   contained_by { sphere { 0 3}}
>>   clipped_by {box {-3 3}}
>>   pigment {Red}
>>   finish { phong 0.6 reflection 0.2 }
>> }
>> object{surftest }
>> background{White}
>> light_source { <20,20,20> color 1}
>> camera{location <0, 0, 20> look_at <0, 0, 0> angle 40}
>>
>> Produces the surface.Note the rather large max_gradient. For a while, with
>> smaller max_gradient, I wasn't getting anything.
>>
>> Thanks,
>>
>> JimT
>
> Thanks. That's very helpful.
> But can we get the most outer surface of the plot? I mean can we make the
> surface into a single solid object without all the internal structures?
> And what does this line mean "evaluate 356*Min_factor,
> sqrt(356/(356*Min_factor)),  0.7" ?
>
>

"evaluate 356*Min_factor, sqrt(356/(356*Min_factor)),  0.7" is an 
alternate manner to account for the max_gradient value of your function.
In effect, it allow the used max_gradient do dynamicaly change during 
the trace within some limits.

The first value is a starting gradient value. It should be somewhat 
smaller than the found max_gradient.
The second value is a ovder-evaluation factor. It controll how fast the 
gradient used is allowed to increase. This value must be larger than 1. 
It can be simplified as sqrt(1/Min_factor)
Lastly, is the under-evaluation factor controlling how fast the gradient 
is allowed to fall. "0.7" is a good starting value.

After rendering without setting max_gradient, you take note of the found 
max_gradient from the message window (for the Windows and Mac versions, 
messages stream on Linux).
You use that value in place of the "356" of that example.

It's very usefull when you have several isosurfaces placed with a #while 
loop, using slight variations, variously scalled, rotated and translated 
and you have messages for both to large AND to small max_gradient values 
at the same time...



Alain


Post a reply to this message

From: xslittlegrass
Subject: Re: how to make a revolution plot from a parametric function?
Date: 8 Jun 2014 21:50:02
Message: <web.5395121035ccce6f1e36f4d20@news.povray.org>
Alain <kua### [at] videotronca> wrote:

> > "JimT" <nomail@nomail> wrote:
> >>> Is it possible to create a revolution plot directly from a parametric function?
> >>>
> >>> For example, I have a 2d parametric function
> >>>
> >>> x[u]=Cos[u]*(1 + 2 Cos[2 u])
> >>> y[u]=Sin[u]*(1+2Cos[2 u])
> >>>
> >> In this case, yes.
> >>
> >> Since x = rcos(theta) and y = rsin(theta) in standard polars, your parametric
> >> equations are just saying
> >> r   = 1+2cos(2theta)
> >>      = 1+2cos^2(theta)-2sin^2(2theta)
> >>      = 3cos^2(theta) - sin^2(2theta)
> >>      = (3x^2 - y^2)/r^2
> >> r^3 = (3x^2 - y^2)
> >> Square to pick up the negative r lobes
> >> r^6 = (3x^2 - y^2)^2
> >> In 2D
> >> (x^2+y^2)^3 = (3x^2 - y^2)^2
> >> To go to 3D, to be axi-symmetric around the x axis, replace y^2 with y^2+z^2.
> >> Replacing x^2 by x^2+z^2 would be axi-symmetric around the y axis. A similar
> >> shape, but the large lobe rotates to a "disk".
> >>
> >> #include "colors.inc"
> >>
> >> #declare surftest =
> >> isosurface {
> >>   function { pow(x*x+y*y+z*z,3)-pow(3*x*x-y*y-z*z,2)}
> >> // evaluate 356*Min_factor,  sqrt(356/(356*Min_factor)),  0.7
> >>   max_gradient 1500
> >>   all_intersections
> >>   contained_by { sphere { 0 3}}
> >>   clipped_by {box {-3 3}}
> >>   pigment {Red}
> >>   finish { phong 0.6 reflection 0.2 }
> >> }
> >> object{surftest }
> >> background{White}
> >> light_source { <20,20,20> color 1}
> >> camera{location <0, 0, 20> look_at <0, 0, 0> angle 40}
> >>
> >> Produces the surface.Note the rather large max_gradient. For a while, with
> >> smaller max_gradient, I wasn't getting anything.
> >>
> >> Thanks,
> >>
> >> JimT
> >
> > Thanks. That's very helpful.
> > But can we get the most outer surface of the plot? I mean can we make the
> > surface into a single solid object without all the internal structures?
> > And what does this line mean "evaluate 356*Min_factor,
> > sqrt(356/(356*Min_factor)),  0.7" ?
> >
> >
>
> "evaluate 356*Min_factor, sqrt(356/(356*Min_factor)),  0.7" is an
> alternate manner to account for the max_gradient value of your function.
> In effect, it allow the used max_gradient do dynamicaly change during
> the trace within some limits.
>
> The first value is a starting gradient value. It should be somewhat
> smaller than the found max_gradient.
> The second value is a ovder-evaluation factor. It controll how fast the
> gradient used is allowed to increase. This value must be larger than 1.
> It can be simplified as sqrt(1/Min_factor)
> Lastly, is the under-evaluation factor controlling how fast the gradient
> is allowed to fall. "0.7" is a good starting value.
>
> After rendering without setting max_gradient, you take note of the found
> max_gradient from the message window (for the Windows and Mac versions,
> messages stream on Linux).
> You use that value in place of the "356" of that example.
>
> It's very usefull when you have several isosurfaces placed with a #while
> loop, using slight variations, variously scalled, rotated and translated
> and you have messages for both to large AND to small max_gradient values
> at the same time...
>
>
>
> Alain

In the rendered plot, we can see through the object and see multiple surfaces.
Can we make the iosurface into a solid object? I mean can we plot the out most
surface only?

Thanks.

Best,
xslittlegrass


Post a reply to this message

From: Alain
Subject: Re: how to make a revolution plot from a parametric function?
Date: 9 Jun 2014 19:58:08
Message: <53964a10@news.povray.org>


> In the rendered plot, we can see through the object and see multiple surfaces.
> Can we make the iosurface into a solid object? I mean can we plot the out most
> surface only?
>
> Thanks.
>
> Best,
> xslittlegrass
>
>

If you want to see any internal surfaces or structure you need to use a 
transparent texture.
Unless the surface have any transparency, you'll only see the very first 
surface that the tracing ray encounter. In this case, any internal 
structure won't be computed as no ray ever reatches them.

In the provided example, the center lobe will be visible if you apply a 
rotation around the X axis because it's effectively located outside of 
the space defined by the rotation of the end lobes.



Alain


Post a reply to this message

From: JimT
Subject: Re: how to make a revolution plot from a parametric function?
Date: 13 Jun 2014 09:00:01
Message: <web.539af54735ccce6fbe7517870@news.povray.org>
>
> In the rendered plot, we can see through the object and see multiple surfaces.
> Can we make the iosurface into a solid object? I mean can we plot the out most
> surface only?
>
As Alain says, unless you make the object transparent in some way, you are
seeing only the outer surface. The statement

pigment{Red}

uses a simple solid red colour.

If you are asking to get rid of the central 'disk' which comes from a negative
value for r in the polar plot, you can use

function { pow(x*x+y*y+z*z,3/2)-(3*x*x-y*y-z*z)}

in the isosurface block. This renders slightly quicker.

Thanks,

JimT


Post a reply to this message

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