POV-Ray : Newsgroups : povray.general : inside_vector ??? : Re: inside_vector ??? Server Time
5 Aug 2024 20:22:42 EDT (-0400)
  Re: inside_vector ???  
From: ezfzx
Date: 20 Jan 2013 17:45:00
Message: <web.50fc730410f4d924132b49cc0@news.povray.org>
Let's see if this example clears things up.

Let's pretend we've created a simple mesh, a single triangle which lies in the
y-z plane.

There is no obvious inside or outside.

Subtract a sphere and you see a circular hole, as if a circle had been cut out
of paper.

difference{
  #local txtr = texture{pigment{rgb x}}
  mesh{
    triangle{ <0,+2,0>, <0,-1,+1>, <0,-1,-1> texture{txtr} }
  }
  sphere{0,0.5 texture{pigment{rgb z}}}
}

No surprise.  Now, add an inside_vector that is parallel to the surface, say,
pointing in the +z direction:

difference{
  #local txtr = texture{pigment{rgb x}}
  mesh{
    triangle{ <0,+2,0>, <0,-1,+1>, <0,-1,-1> texture{txtr} }
    inside_vector +z
  }
  sphere{0,0.5 texture{pigment{rgb z}}}
}

And you STILL see just a hole.

If this were a 3D object, subtracting a sphere would result in a spherical dent.

So why don't see now see a spherical dent?

Because POV-Ray will test every point in the volume space to see if it's inside
or outside the object.

It will run an imaginary line from each point and if that line crosses an odd
number of surfaces, it will decide that point is inside the object.

If that line crosses an even number of surfaces, it will decide that point is
outside the object.

If you are outside the object when the sphere is subtracted, you'd see a
spherical hole.

If you are inside the object when the sphere is subtracted, you'd see a
spherical bump.

But when the inside_vector is parallel to the surface, the imaginary lines from
all of the points in the volume never cross a surface, and so they are all
"outside".

NOW, add an inside_vector that is perpendicular to the surface pointing in the
+x direction:

difference{
  #local txtr = texture{pigment{rgb x}}
  mesh{
    triangle{ <0,+2,0>, <0,-1,+1>, <0,-1,-1> texture{txtr} }
    inside_vector +x
  }
  sphere{0,0.5 texture{pigment{rgb z}}}
}

All points immediately in the -x side of the surface will draw lines pointing +x
and pass through the one surface, so they are considered "inside".

So, now, the spherical bump appears on the -x side, while the +x side sees a
spherical hole.

If we reverse the inside_vector:

difference{
  #local txtr = texture{pigment{rgb x}}
  mesh{
    triangle{ <0,+2,0>, <0,-1,+1>, <0,-1,-1> texture{txtr} }
    inside_vector -x
  }
  sphere{0,0.5 texture{pigment{rgb z}}}
}

The bump/hole switch sides, because now everything on the +x side is "inside".

Hope that clear it all up, ten years after the fact. :)


Post a reply to this message

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