POV-Ray : Newsgroups : moray.win : Simple question Server Time
29 Jul 2024 06:14:18 EDT (-0400)
  Simple question (Message 1 to 2 of 2)  
From: Walters
Subject: Simple question
Date: 16 May 1999 12:25:28
Message: <373EE362.3C9D283E@wxs.nl>
I'm just a beginner in Moray so once in
a while I'll ask some questions here.
Here's my my question:
Let's assume there are 3 spheres; A, B
and C. They are placed in a line but
they overlap a little. Now B should be
the difference from A but B also has to
make a intersection with C. Is there a
simple way to let B be a part of two
CSG's or should I make 2 B's at the same
position?

Johan Walters


Post a reply to this message

From: Ken
Subject: Re: Simple question
Date: 16 May 1999 13:03:15
Message: <373EEC07.8A0E3C5A@pacbell.net>
Walters wrote:
> 
> I'm just a beginner in Moray so once in
> a while I'll ask some questions here.
> Here's my my question:
> Let's assume there are 3 spheres; A, B
> and C. They are placed in a line but
> they overlap a little. Now B should be
> the difference from A but B also has to
> make a intersection with C. Is there a
> simple way to let B be a part of two
> CSG's or should I make 2 B's at the same
> position?
> 
> Johan Walters


You are correct in the way you are solving the problem. There is one trap
that Pov will let you fall into. If you look at the two Pov script examples
below you will see in the first basicaly what you propose with two copies
of B doing it's job on two different objects in two seperate operations.


This is what you are proposing with two operations and two B's:

#declare A = sphere {x*-0.5, 1 }
#declare B = sphere {x* 0.0, 1 }
#declare C = sphere {x* 0.5, 1 }

   difference {
       object { A }
       object { B }
              }

 intersection {
       object { C }
       object { B }
              }


OR...

This is still two operations but uses only one copy of B to do so.

#declare A = sphere {x*-0.5, 1 }
#declare B = sphere {x* 0.0, 1 }
#declare C = sphere {x* 0.5, 1 }

 intersection {

   difference {
       object { A }
       object { B }
              }     // end difference

       object { C }
              }     // end intersection


  This last example on the surface looks like it will work but
there is a problem with it. By wrapping A and B in one CSG operation,
then placing them inside a nested CSG operation, C actualy becomes
the active intersecting object as opposed to being intersected by B.
  This is one of the important issues with CSG operations and that
is the order in which the program will procees an object. The first
object in a CSG is the object being acted upon while the second is
the one taking the active role.
  If we take a closer look it now becomes obvious that C is trying
to intersect both A and B and that is not what we want to happen.
This leaves us with your original suggestion as the correct way to
proceed.

-- 
Ken Tyler

mailto://tylereng@pacbell.net


Post a reply to this message

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