POV-Ray : Newsgroups : povray.general : Help with plotting a parametric equation Server Time
27 Nov 2024 20:38:41 EST (-0500)
  Help with plotting a parametric equation (Message 1 to 10 of 13)  
Goto Latest 10 Messages Next 3 Messages >>>
From: SharkD
Subject: Help with plotting a parametric equation
Date: 16 Jan 2008 02:45:00
Message: <web.478db59093155640368884fc0@news.povray.org>
I have gotten in a dispute at Wikipedia
(http://en.wikipedia.org/wiki/Talk:HSL_and_HSV#Sphere). I'm trying to plot the
following parametric formula:

http://img252.imageshack.us/img252/1194/parametricformulaqy3.png

Here's what I've got so far:

#local cone_count_h = 0;
#local cone_count_s = 0;
#local cone_count_l = 0;
#local cone_max_h = 12;
#local cone_max_s = 6;
#local cone_max_l = 6;
#local cone_interval_h = 360/cone_max_h;
#local cone_interval_s =   1/cone_max_s;
#local cone_interval_l =   1/cone_max_l;
#local cone_max_i = 1000;

#while (cone_count_h < cone_max_h)
 #local cone_h = cone_count_h * cone_interval_h;
 #while (cone_count_s < cone_max_s)
  #local cone_s = cone_count_s * cone_interval_s;
  #while (cone_count_l < cone_max_l)
   #local cone_l = cone_count_l * cone_interval_l;
   #local new_var = 2 * cone_l - 1;
   #local f_of_new_var = sqrt(1 - pow(new_var, 2));
   #local x_coo = f_of_new_var * cone_s * cosd(cone_h);
   #local y_coo = f_of_new_var * cone_s * sind(cone_h);
   #local z_coo = new_var;
   sphere
   {
    < x_coo, z_coo, y_coo>, 0.05
    texture
    {
     pigment {rgb <1,0,0>}
     pigment {rgb CHSL2RGB(<cone_h/360, cone_s, cone_l>)}
    }
   }
   #local cone_count_l = cone_count_l + 1;
  #end
  #local cone_count_s = cone_count_s + 1;
 #end
 #local cone_count_h = cone_count_h + 1;
#end

What am I doing wrong?


Post a reply to this message

From: Tim Attwood
Subject: Re: Help with plotting a parametric equation
Date: 16 Jan 2008 06:58:16
Message: <478df158$1@news.povray.org>
>I have gotten in a dispute at Wikipedia
> (http://en.wikipedia.org/wiki/Talk:HSL_and_HSV#Sphere). I'm trying to plot 
> the
> following parametric formula:
>
> http://img252.imageshack.us/img252/1194/parametricformulaqy3.png
>
> Here's what I've got so far:
>
> #local cone_count_h = 0;
> #local cone_count_s = 0;
> #local cone_count_l = 0;
> #local cone_max_h = 12;
> #local cone_max_s = 6;
> #local cone_max_l = 6;
> #local cone_interval_h = 360/cone_max_h;
> #local cone_interval_s =   1/cone_max_s;
> #local cone_interval_l =   1/cone_max_l;
> #local cone_max_i = 1000;
>
> #while (cone_count_h < cone_max_h)
> #local cone_h = cone_count_h * cone_interval_h;
> #while (cone_count_s < cone_max_s)
>  #local cone_s = cone_count_s * cone_interval_s;
>  #while (cone_count_l < cone_max_l)
>   #local cone_l = cone_count_l * cone_interval_l;
>   #local new_var = 2 * cone_l - 1;
>   #local f_of_new_var = sqrt(1 - pow(new_var, 2));
>   #local x_coo = f_of_new_var * cone_s * cosd(cone_h);
>   #local y_coo = f_of_new_var * cone_s * sind(cone_h);
>   #local z_coo = new_var;
>   sphere
>   {
>    < x_coo, z_coo, y_coo>, 0.05
>    texture
>    {
>     pigment {rgb <1,0,0>}
>     pigment {rgb CHSL2RGB(<cone_h/360, cone_s, cone_l>)}
>    }
>   }
>   #local cone_count_l = cone_count_l + 1;
>  #end
>  #local cone_count_s = cone_count_s + 1;
> #end
> #local cone_count_h = cone_count_h + 1;
> #end
>
> What am I doing wrong?
>
The z coordinates are just sqrt(1 - pow(new_var, 2))...
as stated by the parametric you linked, but that is just a
single cone, not a double cone.


Post a reply to this message

From: SharkD
Subject: Re: Help with plotting a parametric equation
Date: 16 Jan 2008 13:40:00
Message: <web.478e4f713284050c368884fc0@news.povray.org>
"Tim Attwood" <tim### [at] comcastnet> wrote:
> The z coordinates are just sqrt(1 - pow(new_var, 2))...
> as stated by the parametric you linked, but that is just a
> single cone, not a double cone.

I've replaced the z coordinate of the parametric equation with sqrt(1 -
pow(new_var, 2)) in place of new_var as you said, and I can't perceive an
improvement. Maybe I'm misunderstanding the instructions you gave me. Would you
mind posting a fixed version of the code, instead? Thank you very much.


Post a reply to this message

From: SharkD
Subject: Re: Help with plotting a parametric equation
Date: 16 Jan 2008 13:45:00
Message: <web.478e4fc03284050c368884fc0@news.povray.org>
"SharkD" <nomail@nomail> wrote:
> "Tim Attwood" <tim### [at] comcastnet> wrote:
> > The z coordinates are just sqrt(1 - pow(new_var, 2))...
> > as stated by the parametric you linked, but that is just a
> > single cone, not a double cone.
>
> I've replaced the z coordinate of the parametric equation with sqrt(1 -
> pow(new_var, 2)) in place of new_var as you said, and I can't perceive an
> improvement. Maybe I'm misunderstanding the instructions you gave me. Would you
> mind posting a fixed version of the code, instead? Thank you very much.

By the way, here's my camera code. Maybe that is the problem?

camera
{
 #local CameraDistance = 10;
 #local ScreenArea = 5;
 #local AspectRatio = image_width/image_height;
// orthographic
 location -z*CameraDistance
 direction z*CameraDistance
 right     x*ScreenArea*AspectRatio
 up        y*ScreenArea
// rotate x*asind(tand(30))
// rotate y*225
}


Post a reply to this message

From: Tim Attwood
Subject: Re: Help with plotting a parametric equation
Date: 16 Jan 2008 17:04:37
Message: <478e7f75$1@news.povray.org>
"SharkD" <nomail@nomail> wrote in message 
news:web.478e4fc03284050c368884fc0@news.povray.org...
> "SharkD" <nomail@nomail> wrote:
>> "Tim Attwood" <tim### [at] comcastnet> wrote:
>> > The z coordinates are just sqrt(1 - pow(new_var, 2))...
>> > as stated by the parametric you linked, but that is just a
>> > single cone, not a double cone.
>>
>> I've replaced the z coordinate of the parametric equation with sqrt(1 -
>> pow(new_var, 2)) in place of new_var as you said, and I can't perceive an
>> improvement. Maybe I'm misunderstanding the instructions you gave me. 
>> Would you
>> mind posting a fixed version of the code, instead? Thank you very much.
>
> By the way, here's my camera code. Maybe that is the problem?
>
> camera
> {
> #local CameraDistance = 10;
> #local ScreenArea = 5;
> #local AspectRatio = image_width/image_height;
> // orthographic
> location -z*CameraDistance
> direction z*CameraDistance
> right     x*ScreenArea*AspectRatio
> up        y*ScreenArea
> // rotate x*asind(tand(30))
> // rotate y*225
> }
>

This is a single cone, not a double one...

#include "colors.inc"
#include "math.inc"

camera {
   location  <0.5, 0.5, -4.0>
   direction 1.5*z
   right     x*image_width/image_height
   look_at   <0.5, 0.0,  0.0>
}

background {Gray50}

// helper function
#declare f_of_z = function(z) {sqrt(1-(z*z))};

// parametric functions as described in post
// x = hue [0..360), y = saturation [0..1], z = luminance [0..1]
#declare x_value = function(x,y,z) {f_of_z(z)*y*cosd(x)};
#declare y_value = function(x,y,z) {f_of_z(z)*y*sind(x)};
#declare z_value = function(x,y,z) {f_of_z(z)};

union {
#declare Hue_Count = 0;
#while (Hue_Count < 360)
   #declare Sat_Count = 0;
   #while (Sat_Count <= 1)
      #declare Lum_Count = 0;
      #while (Lum_Count <= 1)

         #local HSLLOC = <x_value(Hue_Count,Sat_Count,Lum_Count),
                          y_value(Hue_Count,Sat_Count,Lum_Count),
                          z_value(Hue_Count,Sat_Count,Lum_Count)>;

         #local C = CHSL2RGB(<Hue_Count,Sat_Count,Lum_Count>);

         sphere {HSLLOC,0.05
            pigment{color C}
            finish {ambient 1}
         }

         #declare Lum_Count=Lum_Count+0.05;
      #end
      #declare Sat_Count=Sat_Count+0.1;
   #end
   #declare Hue_Count=Hue_Count+6;
#end
  rotate <0,45,0>
}


Post a reply to this message

From: SharkD
Subject: Re: Help with plotting a parametric equation
Date: 16 Jan 2008 22:55:00
Message: <web.478ed1803284050c368884fc0@news.povray.org>
"Tim Attwood" <tim### [at] comcastnet> wrote:
> This is a single cone, not a double one...
>
> <code>

Your code results in a crash and the following error:
"POV-Ray dore rendering code threw an unhandled exception."

Anyway, nevermind. I was able to input the values into another software and plot
the points that way. I'll go back and check later to see what I did wrong when I
have the time.

Also, it's not a cone, it's a sphere.


Post a reply to this message

From: Tim Attwood
Subject: Re: Help with plotting a parametric equation
Date: 17 Jan 2008 05:36:58
Message: <478f2fca$1@news.povray.org>
> Your code results in a crash and the following error:
> "POV-Ray dore rendering code threw an unhandled exception."
>
> Anyway, nevermind. I was able to input the values into another software 
> and plot
> the points that way. I'll go back and check later to see what I did wrong 
> when I
> have the time.
>
> Also, it's not a cone, it's a sphere.

I didn't have any crashes... oddness....

It looks like a cone to me.
http://s201.photobucket.com/albums/aa280/Zakardis/?action=view&current=color_sphere3.jpg


Post a reply to this message

From: SharkD
Subject: Re: Help with plotting a parametric equation
Date: 17 Jan 2008 16:15:00
Message: <web.478fc4263284050c7ba03b340@news.povray.org>
"Tim Attwood" <tim### [at] comcastnet> wrote:
> I didn't have any crashes... oddness....
>
> It looks like a cone to me.
>
http://s201.photobucket.com/albums/aa280/Zakardis/?action=view&current=color_sphere3.jpg

You have to look at the *entire* area of text I circled in the image. Beneath
the big, bold parametric equation are variable definitions, where additional
equations are used.

As for the crashes, I don't know what is causing them. Usually, if there's a
typo or some error in copying and pasting text into the edit window, the
program will simply quit parsing and give a minor error in the status bar or
"Messages" tab.


Post a reply to this message

From: SharkD
Subject: Re: Help with plotting a parametric equation
Date: 17 Jan 2008 18:35:01
Message: <web.478fe5243284050c7ba03b340@news.povray.org>
"SharkD" <nomail@nomail> wrote:
> "Tim Attwood" <tim### [at] comcastnet> wrote:
> > I didn't have any crashes... oddness....
> >
> > It looks like a cone to me.
> >
http://s201.photobucket.com/albums/aa280/Zakardis/?action=view&current=color_sphere3.jpg
>
> You have to look at the *entire* area of text I circled in the image. Beneath
> the big, bold parametric equation are variable definitions, where additional
> equations are used.
>
> As for the crashes, I don't know what is causing them. Usually, if there's a
> typo or some error in copying and pasting text into the edit window, the
> program will simply quit parsing and give a minor error in the status bar or
> "Messages" tab.

Due to the server formatting news posts in the web interface of the newsgroup,
it appears as if I added the above URL to an image. Just to clear things up,
the image I am referring to is the image I linked to in my first post.


Post a reply to this message

From: SharkD
Subject: Re: Help with plotting a parametric equation
Date: 17 Jan 2008 20:05:01
Message: <web.478ffb303284050c7ba03b340@news.povray.org>
"SharkD" <nomail@nomail> wrote:
> You have to look at the *entire* area of text I circled in the image. Beneath
> the big, bold parametric equation are variable definitions, where additional
> equations are used.

Looking at your code again, I see that you did, in fact, notice this. I assumed
this was not the case since you said the shape was that of a cone (which the
bold lettering is the parametric formula of). However, in your equation you set
z to equal L instead of 2L - 1, resulting in the (rounded) conical shape.


Post a reply to this message

Goto Latest 10 Messages Next 3 Messages >>>

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