POV-Ray : Newsgroups : povray.newusers : difference, plane Server Time
24 Nov 2024 12:47:48 EST (-0500)
  difference, plane (Message 1 to 8 of 8)  
From: stevenvh
Subject: difference, plane
Date: 12 Apr 2008 13:35:01
Message: <web.4800f205f926b0c95245d3740@news.povray.org>
In the past I always "differenced" objects, never a plane, and maybe that's why
I never noticed this before. Say I want a sphere with the top cut off:

difference {
    sphere { 0 1  }
    plane { y 0.8 }
    texture { T_Brass_1D }
}

Not what I want; only the top segment is kept. Logic holds that

    plane { -y -0.8 }

should do the trick, cutting away the stuff above the (inversed) plane instead
of below it. But POV-Ray doesn't seem to accept negative distances here!
How do I do this?
TIA


Post a reply to this message

From: Jan Dvorak
Subject: Re: difference, plane
Date: 12 Apr 2008 14:03:48
Message: <4800f984@news.povray.org>
stevenvh napsal(a):
> In the past I always "differenced" objects, never a plane, and maybe that's why
> I never noticed this before. Say I want a sphere with the top cut off:
> 
> difference {
>     sphere { 0 1  }
>     plane { y 0.8 }
>     texture { T_Brass_1D }
> }
> 
> Not what I want; only the top segment is kept. Logic holds that
> 
>     plane { -y -0.8 }
> 
> should do the trick, cutting away the stuff above the (inversed) plane instead
> of below it. But POV-Ray doesn't seem to accept negative distances here!
> How do I do this?
> TIA
> 
> 
It does support negative distances here. What happens here is that it 
understands -y-0.8 as a single expression. You should type 
plane{-y,-0.8} instead.
-- 
You know you've been raytracing too long when...
you ever saw a beautiful scenery and regretted not to take your 6" 
reflective ball and a digital camera, thinking "this would have been a 
perfect light probe"
-Johnny D


Post a reply to this message

From: Warp
Subject: Re: difference, plane
Date: 12 Apr 2008 14:26:57
Message: <4800fef1@news.povray.org>
stevenvh <nomail@nomail> wrote:
>     plane { -y -0.8 }

  -y -0.8 = <0, -1, 0> - <0.8, 0.8, 0.8> = <-0.8, -1.8, -0.8>

  Expressions are evaluated first, after that the optional commas.
In this case the comma is not all that optional because without it
the expression takes precedence.

-- 
                                                          - Warp


Post a reply to this message

From: stevenvh
Subject: Re: difference, plane
Date: 12 Apr 2008 15:45:00
Message: <web.480110733b1714c75245d3740@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> stevenvh <nomail@nomail> wrote:
> >     plane { -y -0.8 }
>
>   -y -0.8 = <0, -1, 0> - <0.8, 0.8, 0.8> = <-0.8, -1.8, -0.8>
>
>   Expressions are evaluated first, after that the optional commas.
> In this case the comma is not all that optional because without it
> the expression takes precedence.
>
> --
>                                                           - Warp

Thanks Warp & Jan.
My problem is with the "optional". I'm used to work with programming languages,
and parameter separators are mandatory in every language I know. I wish they
were in POV-Ray too.
(You may argument that I'm free to write the commas, but you know how it goes:
you learn POV-Ray by reading existing code...)


Post a reply to this message

From: Warp
Subject: Re: difference, plane
Date: 12 Apr 2008 16:19:17
Message: <48011945@news.povray.org>
stevenvh <nomail@nomail> wrote:
> I'm used to work with programming languages,
> and parameter separators are mandatory in every language I know. I wish they
> were in POV-Ray too.

  The problem with that would be that if they were mandatory you wouldn't
be able to do things like this:

#declare Spline =
  spline
  { cubic_spline
    #declare Ind = 0;
    #while(Ind < Amount)
      Ind/(Amount-1), Point[Ind]
      #declare Ind = Ind+1;
    #end
  };

-- 
                                                          - Warp


Post a reply to this message

From: Slime
Subject: Re: difference, plane
Date: 12 Apr 2008 17:23:15
Message: <48012843$1@news.povray.org>
>  The problem with that would be that if they were mandatory you wouldn't
> be able to do things like this:

A common solution is to allow an extra comma at the end of lists, so you 
could do:

> #declare Spline =
>  spline
>  { cubic_spline
>    #declare Ind = 0;
>    #while(Ind < Amount)
>      Ind/(Amount-1), Point[Ind],
>      #declare Ind = Ind+1;
>    #end
>  };

I know C allows this in some cases and it's very convenient. (Maybe POV-Ray 
does too, but my point is that it works well when commas are required, which 
is good for avoiding problems like steven's.)

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: Larry Hudson
Subject: Re: difference, plane
Date: 12 Apr 2008 20:45:59
Message: <480157c7@news.povray.org>
stevenvh wrote:
> In the past I always "differenced" objects, never a plane, and maybe that's why
> I never noticed this before. Say I want a sphere with the top cut off:
> 
> difference {
>     sphere { 0 1  }
>     plane { y 0.8 }
>     texture { T_Brass_1D }
> }
> 
> Not what I want; only the top segment is kept. Logic holds that
> 
>     plane { -y -0.8 }
> 
> should do the trick, cutting away the stuff above the (inversed) plane instead
> of below it. But POV-Ray doesn't seem to accept negative distances here!
> How do I do this?
> TIA
> 

The key here is that, for CSG, the "inside" of a plane is the side 
_opposite_ the normal.  Also, the second parameter in the plane is the 
distance from the origin _in the direction of_ the normal.  (Plus, as 
others here have pointed out, be sure to use the commas in these 
expressions.)  IOW:

      difference {
         sphere { 0, 1 }
         plane { y, 0.8 }
         texture { Whatever }
      }

gives you the top "cap" of the sphere, and plane { -y, 0.8 } gives the 
same "cap" but from the bottom of the sphere.  What you're looking for 
is plane { -y, -0.8 }.  See the attached illustration.

Hope this clarifies things.    :-)

      -=- Larry -=-


Post a reply to this message


Attachments:
Download 'diff.png' (19 KB)

Preview of image 'diff.png'
diff.png


 

From: Alain
Subject: Re: difference, plane
Date: 14 Apr 2008 17:41:24
Message: <4803cf84$1@news.povray.org>
en ce 2008/04/12 13:31 :)   ->
> In the past I always "differenced" objects, never a plane, and maybe that's why
> I never noticed this before. Say I want a sphere with the top cut off:
> 
> difference {
>     sphere { 0 1  }
>     plane { y 0.8 }
>     texture { T_Brass_1D }
> }
> 
> Not what I want; only the top segment is kept. Logic holds that
> 
>     plane { -y -0.8 }
> 
> should do the trick, cutting away the stuff above the (inversed) plane instead
> of below it. But POV-Ray doesn't seem to accept negative distances here!
> How do I do this?
> TIA
> 
> 
While all the others is correct, in your case you can replace "difference" by 
"intersection". That way, instead of keeping what NOT in the plane, you keep the 
part that is COMMON to both the sphere and the plane.

You can also use the "inverse" keyword.

-- 
Alain
-------------------------------------------------
I hope our wisdom will grow with our power, and teach us, that the less we
use our power the greater it will be.
Thomas Jefferson


Post a reply to this message

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