POV-Ray : Newsgroups : povray.general : Graininess : Re: Graininess Server Time
31 Jul 2024 02:28:35 EDT (-0400)
  Re: Graininess  
From: Trevor G Quayle
Date: 11 Jan 2008 22:35:00
Message: <web.478834e022fbe8cf2ae8612c0@news.povray.org>
"SharkD" <nomail@nomail> wrote:
> "SharkD" <nomail@nomail> wrote:
> > Here's the scene. It uses two include files available from the Object
> > Collection.
>
> Woops. Just noticed all the junk comments. Hopefully you can weed them out.

Yeah, I did.

The error is in your SphereGrid macro when you are making the cones for the
latitude grids.  You set the radius of the cone to be 1/tan(value), which is
fine, except when you have one that is completely flat (i.e. the equator).
Here, value=0, therefore tan(0)=0 which leaves a division by 0 error.  I don't
know exactly how POV is handling this, but it is creating something similar to
a coincident surface problem.

Two other problems that I noticed as well:
You are cycling from 0deg up to 180deg, with the angle being the angle from the
equator.
1) This means that you are going through angle=90, which is a vertical cone of 0
thickness, that is, unnecessary.
2)  above 90, you are creating the cones using angles greater than 90deg.
1/cos(value) for these angles is <0, therefore you are using a negative radius
which can cause problems.

You would be better to iterate from the top down to the equator, with the angle
being the angle from the pole instead.  That gives you a few advantages:
a) you can create 2 identical cones at once and just -y mirror one for the grids
below the equator (this will avoid problem 2) above.
b) You can skip angle=0, the vertical one from item 1) above
c) Then you just make sure you have a special case for angle=90.  I would
suggest using a cylinder.

Speaking of item c).  For the Longitudinal lines, you are using the intersection
of 2 planes, which work fine, but you would be better to use a cylinder or box
instead.  It is best to avoid differences and intersections as much as possible
if you can, as they can creat bounding_box difficulties which con slow down
rendering quite a bit.

Hope this helps.  Keep up the good work though.

PS, When writing macros like these, I like to create a spreadsheet that mimics
my loops so I can see the trig in action and catch the errors, especially
division by zero errors.

-tgq


Post a reply to this message

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