POV-Ray : Newsgroups : povray.advanced-users : Shape Server Time
24 Nov 2024 23:57:17 EST (-0500)
  Shape (Message 1 to 5 of 5)  
From: Andrew C on Mozilla
Subject: Shape
Date: 24 Aug 2004 15:47:03
Message: <412b9b37$1@news.povray.org>
OK, I was about to post a question... but then I realised, I'm not sure 
if the shape I'm looking for is a parabola or a hyperbola...

Anyway, I was going to ask how I get POV-Ray to draw that shape. (The 
one with two lobes that don't quite meet.) I thought it was in 
shapes.inc somewhere, but I can't seem to find it...

Andrew @ home.


Post a reply to this message

From: Thies Heidecke
Subject: Re: Shape
Date: 25 Aug 2004 10:07:57
Message: <412c9d3d$1@news.povray.org>
"Andrew C on Mozilla" <voi### [at] devnull> schrieb im Newsbeitrag
news:412b9b37$1@news.povray.org...
> OK, I was about to post a question... but then I realised, I'm not sure
> if the shape I'm looking for is a parabola or a hyperbola...
>
> Anyway, I was going to ask how I get POV-Ray to draw that shape. (The
> one with two lobes that don't quite meet.) I thought it was in
> shapes.inc somewhere, but I can't seem to find it...

Hi,
it's a hyperboloid
the equation which describes it is:


where a,b,c determine the length/scaling of the axes.
the axis with the plus-sign is at the same time the rotational axis

in SDL you can make this with a quadric:
#declare a=1;
#declare b=2;
#declare c=1;

quadric {
  <-1/(a*a), 1/(b*b), -1/(c*c)>, //  A x^2  + B y^2  + C z^2  +
  <0, 0, 0>,                     //  D xy   + E xz   + F yz   +
  <0, 0, 0>,                     //  G x    + H y    + I z    +
  -1                             //  J
  texture {
    pigment { color rgb 1 }
    finish { diffuse 1 ambient 0 phong 0.5 }
  }
}

In this example the shape is symmetric about the y-axis
and scaled by a factor of two.

> Andrew @ home.
Thies


Post a reply to this message

From: Andrew C on Mozilla
Subject: Re: Shape
Date: 27 Aug 2004 16:30:06
Message: <412f99ce$1@news.povray.org>
>>OK, I was about to post a question... but then I realised, I'm not sure
>>if the shape I'm looking for is a parabola or a hyperbola...
>>
>>Anyway, I was going to ask how I get POV-Ray to draw that shape. (The
>>one with two lobes that don't quite meet.) I thought it was in
>>shapes.inc somewhere, but I can't seem to find it...
> 
> 
> Hi,
> it's a hyperboloid

Ah, ok.

> the equation which describes it is:

> 
> where a,b,c determine the length/scaling of the axes.
> the axis with the plus-sign is at the same time the rotational axis

Excellent.

> in SDL you can make this with a quadric:
> #declare a=1;
> #declare b=2;
> #declare c=1;
> 
> quadric {
>   <-1/(a*a), 1/(b*b), -1/(c*c)>, //  A x^2  + B y^2  + C z^2  +
>   <0, 0, 0>,                     //  D xy   + E xz   + F yz   +
>   <0, 0, 0>,                     //  G x    + H y    + I z    +
>   -1                             //  J
>   texture {
>     pigment { color rgb 1 }
>     finish { diffuse 1 ambient 0 phong 0.5 }
>   }
> }
> 
> In this example the shape is symmetric about the y-axis
> and scaled by a factor of two.

I wanna use this to make the bottom of a glass. (That is, the glass is a 
cylinder, hollowed out with a hyperboliod.) Does the quadric primitive 
give an infinite shape? How would I position the "tip" of the shape at a 
particular point in space? (Say... where I want the inside of my glass 
to stop! ;-) )

Thanks for the info.
Andrew @ home.


Post a reply to this message

From: Thies Heidecke
Subject: Re: Shape
Date: 31 Aug 2004 12:43:38
Message: <4134aaba$1@news.povray.org>
> I wanna use this to make the bottom of a glass. (That is, the glass is a
> cylinder, hollowed out with a hyperboliod.) Does the quadric primitive
> give an infinite shape?
Yep, it's infinite in both directions.

> How would I position the "tip" of the shape at a
> particular point in space? (Say... where I want the inside of my glass
> to stop! ;-) )
You have three possibilities.
Either you scale it from it's orginal position, since the tip starts at
a distance from the origin, thereby scaling the distance.
Or you can first translate the tip to the origin and scale it, then
translate it back. This is bit easier (for me at least) because you can
seperate the positioning of the tip from the scaling of the shape.
Or you can do it in the mathematical way and tailor the equation for
your purpose, so you don't have to scale or translate at all afterwards.

I like the third way :)

It's not so hard as it seems at first.
First we simplify our equation a bit. Since we want a round nonsquashed
glass, we can reduce the 3d-equation to a 2d-equation because the scaling
in x- and z-direction will be the same.
so we have:


Unfortunately i made an error in the equation in my last post. Though the
surface is right it's flipped inside out, so we have to change all signs
in the equation to get the right inside again:


We are interested in the scaling-parameters a and b to move our
hyperboloid in place. So we'll take two points in the xy-plane where
we want our surface to go through in any case and insert the
coordinates of the points in the equation thereby getting two
equations for a and b which we (hopefully) can solve.
One point could be the tip of the hyperboloid. Its x-value
will obviously be zero. Its y-value will be the thickness of the
bottom of our glass. So to remain general we have:
<0, b_th>    'b_th' = 'bottom-thickness'.

The second point could be the inner upper edge of the glass. we
can define it by the height, width and the thickness of the glass.
<g_w-e_th, g_h>

g_w  = glass-width
e_th = edge-thickness
g_h  = glass-height

Inserted in our equation we get:




(1) b = +-b_th
and since we want our glass extending in +y-direction
(1) b = b_th
we'll insert this in the 2nd eq.:





So now we have simple formulas for our scaling-parameters which
we can use for the quadric-parameters.

In SDL:
#declare g_h = 1.0;
#declare g_w = 1;
#declare e_th = 0.1;
#declare b_th = 0.1;

// create a quadratic (2nd order) infinite polynomial surface
#declare a=(g_w/2-e_th)/sqrt(pow((g_h/b_th),2) - 1);
#declare b=b_th;
#declare c=a;

difference {
  cylinder {
    0, g_h*y, g_w/2
    pigment{ transmit 0.5 }
  }
  quadric {
    <1/(a*a), -1/(b*b), 1/(c*c)>, //  A x^2  + B y^2  + C z^2  +
    <0, 0, 0>, //  D xy   + E xz   + F yz   +
    <0, 0, 0>, //  G x    + H y    + I z    +
    1         //  J
    bounded_by{ cylinder {0, 1.01*g_h*y, g_w/2} }
    pigment{red 1}
  }
}

Though it works, i wouldn't use it for normal cylinder-shaped glasses
because the hyperboloid is nearly a cone. Perhaps for sparkling wine
glasses... :)

Perhaps the third method wasn't the best idea. It's probably better
to scale it in the shape you want or use a different shape from the
start. Perhaps a x^(2*n) function with a higher n for more edginess
and x going from -1..1 and y from 0..1 ?

> Thanks for the info.
You're welcome
> Andrew @ home.
Thies


Post a reply to this message

From: jute
Subject: Re: Shape
Date: 30 Sep 2004 11:31:59
Message: <415c26ef$1@news.povray.org>
Thies Heidecke wrote:
> Perhaps the third method wasn't the best idea. 

Oh, THAT is just rich!  After a perfect explanation of non-layman 
mathematics, complete with a rock-solid SDL implementation he's ready to 
throw it all away!  How long did you spend verifying the post was 
correct? ;)  As a sign of appreciation, I'll promise to use your SDL 
snippet in my current project.

Seriously though, I'd normally go with (translate/)scale/translate in 
situations like these.  Nevertheless, your post was a beautiful example 
of the (good) quality of these newsgroups.  Do you teach somewhere?

 > Perhaps for sparkling wine glasses...  :)

With some small changes it looks to be a nice (post-modern) whiskey shot 
glass.

-- 
jussi.kantola


Post a reply to this message

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