POV-Ray : Newsgroups : povray.advanced-users : Shape : Re: Shape Server Time
28 Jul 2024 18:24:28 EDT (-0400)
  Re: Shape  
From: Thies Heidecke
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

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