POV-Ray : Newsgroups : povray.general : Most efficient way to code a hemisphere (lathe.inc) Server Time
1 Nov 2024 17:19:18 EDT (-0400)
  Most efficient way to code a hemisphere (lathe.inc) (Message 1 to 9 of 9)  
From: gregjohn
Subject: Most efficient way to code a hemisphere (lathe.inc)
Date: 26 Feb 2011 21:10:00
Message: <web.4d69b2033996fba34d207310@news.povray.org>
Hi. I was trying to find the most efficient way to code a mesh for a perfect
hemisphere.  I could probably do it if I were to break out a while loop with a
couple thousand entries in the spline based on trig functions.  But it would
really help to know the simplest way to define one.  So far I haven't hit on it
with quadratic spline, supposed I will next try cubic.

TIA for any help.


#version 3.5;
#include "lathe.inc"

global_settings {assumed_gamma 1.0}
camera {location <0,2,-5.5> look_at <0,0,0>}
light_source {<500,500,-500> rgb <0.8,0.9,1>}
light_source {<-10,3,0> rgb <1,1,0.8>}


#declare bd=2;

#declare S1=spline{
   quadratic_spline
  -1.00,<-2,0,0>
   0.00,< 0,2,0>
   1.00,< 2,0,0>
   2.00,< 0,-2,0>
}

object {
   Lathe(S1, 100, 360, 50, "")
   uv_mapping
   pigment{checker color rgb <0,0,0.2> color rgb <1,0.85,0.85> scale 0.05}
   finish{specular 0.4}
}


Post a reply to this message

From: clipka
Subject: Re: Most efficient way to code a hemisphere (lathe.inc)
Date: 26 Feb 2011 23:08:02
Message: <4d69ce22$1@news.povray.org>
Am 27.02.2011 03:08, schrieb gregjohn:
> Hi. I was trying to find the most efficient way to code a mesh for a perfect
> hemisphere.  I could probably do it if I were to break out a while loop with a
> couple thousand entries in the spline based on trig functions.  But it would
> really help to know the simplest way to define one.  So far I haven't hit on it
> with quadratic spline, supposed I will next try cubic.
>
> TIA for any help.

Forget it - you can't get a perfect arc section from cubic (or 
lower-order) splines. As for the other fancy splines in POV-Ray, they're 
actually just cubic splines in disguise.


Post a reply to this message

From: Trevor G Quayle
Subject: Re: Most efficient way to code a hemisphere (lathe.inc)
Date: 26 Feb 2011 23:25:00
Message: <web.4d69d15336e168b6b05ef170@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 27.02.2011 03:08, schrieb gregjohn:
> > Hi. I was trying to find the most efficient way to code a mesh for a perfect
> > hemisphere.  I could probably do it if I were to break out a while loop with a
> > couple thousand entries in the spline based on trig functions.  But it would
> > really help to know the simplest way to define one.  So far I haven't hit on it
> > with quadratic spline, supposed I will next try cubic.
> >
> > TIA for any help.
>
> Forget it - you can't get a perfect arc section from cubic (or
> lower-order) splines. As for the other fancy splines in POV-Ray, they're
> actually just cubic splines in disguise.



The best way (outside of just using a sphere object) would be a rationally built
and calculated mesh.  The basic math for a hemisphere is simple, the most
difficult part is organizing the points into faces.

-tgq


Post a reply to this message

From: clipka
Subject: Re: Most efficient way to code a hemisphere (lathe.inc)
Date: 26 Feb 2011 23:33:32
Message: <4d69d41c$1@news.povray.org>
Am 27.02.2011 05:21, schrieb Trevor G Quayle:

> The best way (outside of just using a sphere object) would be a rationally built
> and calculated mesh.  The basic math for a hemisphere is simple, the most
> difficult part is organizing the points into faces.

Even that is pretty simple, unless you insist on using a mesh2, 
optimizing the computations, and/or going for an optimal distribution of 
vertices.


Post a reply to this message

From: gregjohn
Subject: Re: Most efficient way to code a hemisphere (lathe.inc)
Date: 27 Feb 2011 07:15:00
Message: <web.4d6a3f3736e168b634d207310@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 27.02.2011 03:08, schrieb gregjohn:
> > Hi. I was trying to find the most efficient way to code a mesh for a perfect
> > hemisphere.  I could probably do it if I were to break out a while loop with a
> > couple thousand entries in the spline based on trig functions.  But it would
> > really help to know the simplest way to define one.  So far I haven't hit on it
> > with quadratic spline, supposed I will next try cubic.
> >
> > TIA for any help.
>
> Forget it - you can't get a perfect arc section from cubic (or
> lower-order) splines. As for the other fancy splines in POV-Ray, they're
> actually just cubic splines in disguise.


Wow.  Your claim is compatible with my extensive experimentation, but it blows
my mind that splines cannot do this. Aside from hand-calc-ing the trig.
thanks.

Aside: who's gotten the furthest with elegant solutions to hand-typed (er,
procedurally generated) bicubic meshes?


Post a reply to this message

From: gregjohn
Subject: Re: Most efficient way to code a hemisphere (lathe.inc)
Date: 27 Feb 2011 16:30:00
Message: <web.4d6ac17836e168b634d207310@news.povray.org>
On second thought, my real goal is to have two different mesh2's, in this case
created by Ingo's macros,  to have a perfectly smooth transition between them.
As you point out it ultimately becomes a question of splines.

Q: What is the most simplistic way to guarantee that two splines will have a
perfectly smooth transition, say one defined  A to B, and another B to C?

That is, If I have the "extra point" in a quadratic spline overlap, or the "two
extra points" in a cubic_spline overlap?  Or again, would one have to "hard
code" them as in the example of the trig functions for spheres.


Post a reply to this message

From: Alain
Subject: Re: Most efficient way to code a hemisphere (lathe.inc)
Date: 28 Feb 2011 16:15:22
Message: <4d6c106a@news.povray.org>

> On second thought, my real goal is to have two different mesh2's, in this case
> created by Ingo's macros,  to have a perfectly smooth transition between them.
> As you point out it ultimately becomes a question of splines.
>
> Q: What is the most simplistic way to guarantee that two splines will have a
> perfectly smooth transition, say one defined  A to B, and another B to C?
>
> That is, If I have the "extra point" in a quadratic spline overlap, or the "two
> extra points" in a cubic_spline overlap?  Or again, would one have to "hard
> code" them as in the example of the trig functions for spheres.
>
>
>
>

The end point of the firts spline must coincide with the first point of 
the second one. The last control point of the first spline must coinside 
with the secont point of the second spline. The first control point of 
the second spline must coinside with the second to last point of the 
first spline.

That way, the slope and curvature will continue smoothly across the seam.

For the spline to closely follow the path of a circle, you need to 
increase the number of points. You can place them evenly at constant 
angle using sin and cos.
You'll probably need at least 10 points in a quarter circle, plus the 
control points.



Alain


Post a reply to this message

From: gregjohn
Subject: Re: Most efficient way to code a hemisphere (lathe.inc)
Date: 1 Mar 2011 07:25:00
Message: <web.4d6ce4c336e168b634d207310@news.povray.org>
Alain <aze### [at] qwertyorg> wrote:

>
> The end point of the firts spline must coincide with the first point of
> the second one. The last control point of the first spline must coinside
> with the secont point of the second spline. The first control point of
> the second spline must coinside with the second to last point of the
> first spline.
>
> That way, the slope and curvature will continue smoothly across the seam.
>
> For the spline to closely follow the path of a circle, you need to
> increase the number of points. You can place them evenly at constant
> angle using sin and cos.
> You'll probably need at least 10 points in a quarter circle, plus the
> control points.
>
>


Thanks. Ultimately, I'm trying to hand-roll procedurally generated heads. I'd
use a lathe for the cap and then MSM's or COON's for "strips" around the head.
Knowing I could put in arbitrary values and keep them smooth in this way will be
of great help.  Didn't explicitly need spheres, per se.  thanks.


Post a reply to this message

From: W0RLDBUILDER
Subject: Re: Most efficient way to code a hemisphere (lathe.inc)
Date: 29 Apr 2011 15:20:01
Message: <web.4dbb0e4a36e168b6b8f6b920@news.povray.org>
"gregjohn" <pte### [at] yahoocom> wrote:
> Hi. I was trying to find the most efficient way to code a mesh for a perfect
> hemisphere.  I could probably do it if I were to break out a while loop with a
> couple thousand entries in the spline based on trig functions.  But it would
> really help to know the simplest way to define one.  So far I haven't hit on it
> with quadratic spline, supposed I will next try cubic.
>
> TIA for any help.
>
>
> #version 3.5;
> #include "lathe.inc"
>
> global_settings {assumed_gamma 1.0}
> camera {location <0,2,-5.5> look_at <0,0,0>}
> light_source {<500,500,-500> rgb <0.8,0.9,1>}
> light_source {<-10,3,0> rgb <1,1,0.8>}
>
>
> #declare bd=2;
>
> #declare S1=spline{
>    quadratic_spline
>   -1.00,<-2,0,0>
>    0.00,< 0,2,0>
>    1.00,< 2,0,0>
>    2.00,< 0,-2,0>
> }
>
> object {
>    Lathe(S1, 100, 360, 50, "")
>    uv_mapping
>    pigment{checker color rgb <0,0,0.2> color rgb <1,0.85,0.85> scale 0.05}
>    finish{specular 0.4}
> }

It's not a mesh, but try a CSG with a plane and a sphere.
difference {
  sphere { <1, 0, 0>, 1 pigment { rgb 1 } }
  plane { y, 0 pigment { rgb 1 } }
}

Invert it by adding rotate x*180.
difference {
  sphere { <1, 0, 0>, 1 pigment { rgb 1 } }
  plane { y, 0 pigment { rgb 1 } rotate x*180 }
}


Post a reply to this message

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