POV-Ray : Newsgroups : povray.general : rounded_objects: a new feature? Server Time
3 May 2024 00:54:51 EDT (-0400)
  rounded_objects: a new feature? (Message 11 to 20 of 24)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 4 Messages >>>
From: John Greenwood
Subject: Re: rounded_objects: a new feature?
Date: 18 Sep 2016 07:00:01
Message: <web.57de7375696ad3a7cafab50@news.povray.org>
"John Greenwood" <nomail@nomail> wrote:
> And here it is:

> // Demonstration of plane elements for rounded objects

And now spheres:

// This work is licensed under the Creative Commons Attribution 3.0 Unported
License.
// To view a copy of this license, visit
http://creativecommons.org/licenses/by/3.0/
// or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain
View,
// California, 94041, USA.

// Demonstration of Sphere elements for rounded objects

// Vers: 1.00
// Date: 18 Sept 2016
// Auth: John Greenwood

#version 3.7 ;

#include "colors.inc"

camera {location <0,0,22> angle 30 look_at <0,0,0> }

  background { color rgb<0.2, 0.4, 0.8>  }
  light_source {<5,20,10> color White}
  global_settings {assumed_gamma 1.0 }


  #declare R_function = function( F,q,s){

select((F>q)-(F<-q),2*(q<0)-1,s*pow(F/q,5)-(2*s+.5)*pow(F/q,3)+(1.5+s)*F/q,1-2*(q<0))
                                        }


  isosurface {
     function    {
               R_function(-sqrt(pow(x-1,2)+pow(y,2)+pow(z,2))+1,-1,0)
               +R_function(-sqrt(pow(x+1,2)+pow(y,2)+pow(z,2))+1 ,-.5,0)
                 }
     threshold  1
      max_gradient 4
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}}
            translate < 3,3,0>  }

  isosurface {
     function    {
               R_function(-sqrt(pow(x-1,2)+pow(y,2)+pow(z,2))+1,-.5,.3)
               +R_function(-sqrt(pow(x+1,2)+pow(y,2)+pow(z,2))+1 ,-.5,-.4)
                 }
     threshold  1
      max_gradient 3
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}  }
      translate <-3,3,0>        }

  isosurface {
     function     {

R_function(-sqrt(pow(x-1,2)+pow(y,2)+pow(z,2))+1,min(-.3,-.5-.4*-y),0)

+R_function(-sqrt(pow(x+1,2)+pow(y,2)+pow(z,2))+1,min(-.3,-.5-.4*+y),0)
                 }
     threshold  1
      max_gradient 5
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}  }
     translate <3,-0,0>         }

  isosurface {
     function    {
                R_function(-sqrt(pow(x-1,2)+pow(y,2)+pow(z,2))+1,-.5,y)
               +R_function(-sqrt(pow(x+1,2)+pow(y,2)+pow(z,2))+1,-.5,-y)
                 }
     threshold  1
      max_gradient 4
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}  }
      translate <-3,-0,0>        }

  isosurface {
     function     {
                R_function(-sqrt(pow(x-1,2)+pow(y,2)+pow(z,2))+.5,-2,-.5)
               +R_function(-sqrt(pow(x+1,2)+pow(y,2)+pow(z,2))+1,-1,0)
                 }
     threshold  1
      max_gradient 3
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}  }
     translate <3,-3,0>         }

  isosurface {
     function    {
                R_function(-sqrt(pow(x-1,2)+pow(y,2)+pow(z,2))+.5,-1,0)
               +R_function(-sqrt(pow(x+1,2)+pow(y,2)+pow(z,2))+1,-1.5,0)
                 }
     threshold  1
      max_gradient 4
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}  }
      translate <-3,-3,0>        }


Post a reply to this message

From: scott
Subject: Re: rounded_objects: a new feature?
Date: 19 Sep 2016 03:20:15
Message: <57df91af$1@news.povray.org>
>>> If you're on to something then some working
>>> example code will go *far* further than just a text description.
>>
>> Totally agree, I am working on it.
>
> And here it is:

A good start!

How would you go about doing the union (or difference) of two rounded 
cubes? I tried to modify the code to do this but couldn't get it to 
work. If that works nicely then I think you're on to something...

BTW you could always use a macro for each element, that depending on 
some global switch, either used the standard POV non-rounded primitive 
(for speed of setting up the scene) or the isosurface variant (for final 
render).


Post a reply to this message

From: John Greenwood
Subject: Re: rounded_objects: a new feature?
Date: 19 Sep 2016 05:05:01
Message: <web.57dfaa2e696ad3a7cafab50@news.povray.org>
scott <sco### [at] scottcom> wrote:
> >>> If you're on to something then some working
> >>> example code will go *far* further than just a text description.
> >>
> >> Totally agree, I am working on it.
> >
> > And here it is:
>
> A good start!
>
> How would you go about doing the union (or difference) of two rounded
> cubes? I tried to modify the code to do this but couldn't get it to
> work. If that works nicely then I think you're on to something...
>
> BTW you could always use a macro for each element, that depending on
> some global switch, either used the standard POV non-rounded primitive
> (for speed of setting up the scene) or the isosurface variant (for final
> render).

I think I have a plan!

Meanwhile here are some cylinders:

// This work is licensed under the Creative Commons Attribution 3.0 Unported
License.
// To view a copy of this license, visit
http://creativecommons.org/licenses/by/3.0/
// or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain
View,
// California, 94041, USA.

// Demonstration of Cylinder elements for rounded objects

// Vers: 1.00
// Date: 18 Sept 2016
// Auth: John Greenwood

#version 3.7 ;

#include "colors.inc"

camera {location <0,0,17> angle 25 look_at <0,-.30,0> }

  background { color rgb<0.2, 0.4, 0.8>  }
  light_source {<5,10,20> color White}
  global_settings {assumed_gamma 1.0 }


  #declare R_function = function( F,q,p,n){

select((F>q)-(F<-q),2*(q<0)-1,p*pow(F/q,5)-(2*p+.5)*pow(F/q,3)+(1.5+p)*F/q,1-2*(q<0))+n
                                        }


  isosurface {
     function    {
               R_function(-sqrt(pow(y-1,2)+pow(z,2))+.4-.1*x,-.5,0,-1)
              +R_function(-sqrt(pow(y+1.5,2)+pow(z,2))+1.9,-.3,0,-1)
              +R_function(x+1.5,-.3,0,1)
              +R_function(x-1.5,+.3,0,1)
              +R_function(y,-.3,0,1)
                }
     threshold -1
      max_gradient 6
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}}
            translate < 0,.7,0>  }


  isosurface {
     function    {
               R_function(-sqrt(pow(y-1,  2)+pow(z,2))+ .5,-.3,.2+.5*x,-1)
              +R_function(-sqrt(pow(y+1.5,2)+pow(z,2))+1.9,-.3,.2+.5*x,-1)
              +R_function(x+1.5,-.3,0,1)
              +R_function(x-1.5,+.3,0,1)
              +R_function(y    ,-.5,0,1)
                }
     threshold -1
      max_gradient 6
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}}
            translate < 0,-1,0>  }

  isosurface {
     function    {
               R_function(-sqrt(pow(y-1  ,2)+pow(z,2))+ .4,-.5+.2*x,0,-1)
              +R_function(-sqrt(pow(y+1.5,2)+pow(z,2))+1.9,-.5+.2*x,0,-1)
              +R_function(x+1.5,-.3,0,1)
              +R_function(x-1.5,+.3,0,1)
              +R_function(y+1    ,-.5,0,1)
                }
     threshold -1
      max_gradient 6
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}}
            translate < 0,-2.7,0>  }


Post a reply to this message

From: John Greenwood
Subject: Re: rounded_objects: a new feature?
Date: 19 Sep 2016 07:15:00
Message: <web.57dfc85c696ad3a7cafab50@news.povray.org>
"John Greenwood" <nomail@nomail> wrote:
> scott <sco### [at] scottcom> wrote:
> >
> > How would you go about doing the union (or difference) of two rounded
> > cubes? I tried to modify the code to do this but couldn't get it to
> > work. If that works nicely then I think you're on to something...
> >
> > BTW you could always use a macro for each element, that depending on
> > some global switch, either used the standard POV non-rounded primitive
> > (for speed of setting up the scene) or the isosurface variant (for final
> > render).
>
> I think I have a plan!
>
> Meanwhile here are some cylinders:

And, more exciting, bendy cylinders!

// This work is licensed under the Creative Commons Attribution 3.0 Unported
License.
// To view a copy of this license, visit
http://creativecommons.org/licenses/by/3.0/
// or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain
View,
// California, 94041, USA.

// Demonstration of Bendy Cylinder elements for rounded objects

// Vers: 1.00
// Date: 19 Sept 2016
// Auth: John Greenwood

#version 3.7 ;

#include "colors.inc"

camera {location <5,10,17> angle 10 look_at <0,0,0> }

  background { color rgb<0.2, 0.4, 0.8>  }
  light_source {<5,10,20> color White}
  global_settings {assumed_gamma 1.0 }


  #declare R_function = function( F,q,p,n){

select((F>q)-(F<-q),2*(q<0)-1,p*pow(F/q,5)-(2*p+.5)*pow(F/q,3)+(1.5+p)*F/q,1-2*(q<0))+n
                                        }


  isosurface {
     function    {
               R_function(-sqrt(pow(y-.6+.1*x-.1*pow(x,3),  2)+pow(z,2))+
..2,-.1,0,-1)
              +R_function(-sqrt(pow(y+1.5,2)+pow(z,2))+1.9,-.1,0,-1)
              +R_function(x+1.5,-.1,0,1)
              +R_function(x-1.5,+.1,0,1)
              +R_function(y    ,-.5,0,1)
                }
     threshold -1
      max_gradient 20
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}}
            translate < 0,-.5,0>  }

// note that the cross section is a vertical circle, which means that it will be
elliptical on a plane perpendicular to the cuved axis.
// I think this can be compensated for by taking the slope of the curve into
account.

// I have not worked out the details but I think this is a route to sphere
sweeps.


Post a reply to this message

From: Bald Eagle
Subject: Re: rounded_objects: a new feature?
Date: 19 Sep 2016 12:40:01
Message: <web.57e013ea696ad3b488d9aa0@news.povray.org>
These are very good  :)

I was unsure this would get any farther than speculation, but these scenes are a
very nice prototypical realization of your ideas.


I have to ask:

Could you explain some of the notation that you have in your select() directive?

For example: 2*(q<0)-1   ....   I had no idea one could do this type of thing
:O

Hardly a day goes by that I learn something new here!


Post a reply to this message

From: John Greenwood
Subject: Re: rounded_objects: a new feature?
Date: 20 Sep 2016 04:15:00
Message: <web.57e0ee71696ad3a7cafab50@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> These are very good  :)

Thanks

> I was unsure this would get any farther than speculation, but these scenes are a
very nice prototypical realization o
f your ideas.
>
>
> I have to ask:
>
> Could you explain some of the notation that you have in your select() directive?
>
> For example: 2*(q<0)-1   ....   I had no idea one could do this type of thing
> :O
>
> Hardly a day goes by that I learn something new here!

select((F>q)-(F<-q),2*(q<0)-1,p*pow(F/q,5)-(2*p+.5)*pow(F/q,3)+(1.5+p)*F/q,1-2*(q<0))+n

In words this select directive says:

If F is more than q return a value of 1 but with the same sign as q
If F is less than -q return a value of 1 but with the opposite sign to q
In between return a value according to the polynomial which has turning points
at +/- q

The parameter p (profile) controls the contribution of the 5th power term in the
polynomial and changes the coefficients of the the two terms so as make the
turning points stay in the same position.

I am farly sure that, if a sine curve were to be used, the corner would be a
true circle. With a cubic, ie p = 0, it is within 2% of a circle.


Post a reply to this message

From: John Greenwood
Subject: Re: rounded_objects: a new feature?
Date: 20 Sep 2016 05:10:01
Message: <web.57e0fbb0696ad3a7cafab50@news.povray.org>
scott <sco### [at] scottcom> wrote:
> >>> If you're on to something then some working
> >>> example code will go *far* further than just a text description.
> >>
> >> Totally agree, I am working on it.
> >
> > And here it is:
>
> A good start!
>
> How would you go about doing the union (or difference) of two rounded
> cubes? I tried to modify the code to do this but couldn't get it to
> work. If that works nicely then I think you're on to something...
>
> BTW you could always use a macro for each element, that depending on
> some global switch, either used the standard POV non-rounded primitive
> (for speed of setting up the scene) or the isosurface variant (for final
> render).

Excellent idea.

And here are unions:

// This work is licensed under the Creative Commons Attribution 3.0 Unported
License.
// To view a copy of this license, visit
http://creativecommons.org/licenses/by/3.0/
// or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain
View,
// California, 94041, USA.

// Demonstration of nion for rounded objects

// Vers: 1.00
// Date: 20 Sept 2016
// Auth: John Greenwood

#version 3.7 ;

#include "colors.inc"

camera {location <10,7,30> angle 12 look_at <0,0,0> }

  background { color rgb<0.2, 0.4, 0.8>  }
  light_source {<10,5,10> color White}
  global_settings {assumed_gamma 1.0 }


  #declare R_function = function( F,q,p,n){

select((F>q)-(F<-q),2*(q<0)-1,p*pow(F/q,5)-(2*p+.5)*pow(F/q,3)+(1.5+p)*F/q,1-2*(q<0))+n

                                        }

  #declare Vo =1;
    #declare R_limit = function(V){select((V+1>Vo)-(V+1<-Vo),
-1,-.5*pow((V+1)/Vo,3)+1.5*(V+1)/Vo,+1)-1}


  #declare Corner_Profile = -0;   // -.5 gives rounded bevel, 0 almost round,
+.5 Not noticebly sharper
  #declare Corner_round = .3;

  isosurface {
     function    {

               R_function(-sqrt(pow(x-1,2)+pow(y,2)+pow(z,2))+1,-1,0,-1)

  +R_limit(
                 R_function(x+1.5,-Corner_round,Corner_Profile,1)
              +R_function(x-.5,+Corner_round,Corner_Profile,1)
              +R_function(y-.5, Corner_round,Corner_Profile,1)
              +R_function(y+1.5,-Corner_round,Corner_Profile,1)
              +R_function(z-1.5,+Corner_round,Corner_Profile,1)
              +R_function(z+.5,-Corner_round,Corner_Profile,1)-2 )


             +1
                 }
     threshold 0
      max_gradient 20
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}}
      translate < 0,1.4,0>
               }


  isosurface {
     function    {

         R_limit( R_function(-sqrt(pow(y-.5,2)+pow(z,2))+.5,-.3,0,-1)
                 +R_function(x+.5 ,-.3,0,1)
                 +R_function(x-1.5,+.3,0,1))

       +R_limit( R_function(-sqrt(pow(y+.5,2)+pow(z,2))+.5,-.3,0,-1)
                +R_function(x+1.5,-.3,0,1)
                +R_function(x-.5,+.3,0,1))
                +1
                 }
     threshold 0
      max_gradient 20
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}}
      translate < 0,-1.5,0>

               }


Post a reply to this message

From: John Greenwood
Subject: Re: rounded_objects: a new feature?
Date: 20 Sep 2016 06:25:01
Message: <web.57e10dd0696ad3a7cafab50@news.povray.org>
scott <sco### [at] scottcom> wrote:
> >>> If you're on to something then some working
> >>> example code will go *far* further than just a text description.
> >>
> >> Totally agree, I am working on it.
> >
> > And here it is:
>
> A good start!
>
> How would you go about doing the union (or difference) of two rounded
> cubes? I tried to modify the code to do this but couldn't get it to
> work. If that works nicely then I think you're on to something...

Like this:

// This work is licensed under the Creative Commons Attribution 3.0 Unported
License.
// To view a copy of this license, visit
http://creativecommons.org/licenses/by/3.0/
// or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain
View,
// California, 94041, USA.

// Demonstration of subtraction for rounded objects

// Vers: 1.00
// Date: 20 Sept 2016
// Auth: John Greenwood

#version 3.7 ;

#include "colors.inc"

camera {location <10,7,30> angle 15 look_at <0,0,0> }

  background { color rgb<0.2, 0.4, 0.8>  }
  light_source {<10,5,10> color White}
  global_settings {assumed_gamma 1.0 }


  #declare R_function = function( F,q,p,n){

select((F>q)-(F<-q),2*(q<0)-1,p*pow(F/q,5)-(2*p+.5)*pow(F/q,3)+(1.5+p)*F/q,1-2*(q<0))+n

                                        }

  #declare Vo =1;
    #declare R_limit = function(V){select((V+1>Vo)-(V+1<-Vo),
-1,-.5*pow((V+1)/Vo,3)+1.5*(V+1)/Vo,+1)-1}


  #declare Corner_Profile = -0;   // -.5 gives rounded bevel, 0 almost round,
+.5 Not noticebly sharper
  #declare Corner_round = .3;

  isosurface {
     function    {

            +   R_function(-sqrt(pow(x-1,2)+pow(y,2)+pow(z,2))+1.5,-.3,0,-1)

  +R_limit(
                 R_function(x-1,+Corner_round,Corner_Profile,1)
              +R_function(x+1,-Corner_round,Corner_Profile,1)
              +R_function(y-1, Corner_round,Corner_Profile,1)
              +R_function(y+1,-Corner_round,Corner_Profile,1)
              +R_function(z-1,+Corner_round,Corner_Profile,1)
              +R_function(z+1,-Corner_round,Corner_Profile,1)-2 )


             +3      //Increasing this by two gives the intersection
                 }
     threshold 0
      max_gradient 20
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}}
      translate < -2.5,1.5,0>
               }


  isosurface {
     function    {

            +
R_function(-sqrt(pow(x+.8,2)+pow(y+.5,2)+pow(z+1,2))+1.5,-.3,0,-1)

  -R_limit(
                 R_function(x-1.5,+Corner_round,Corner_Profile,1)
              +R_function(x+1,-Corner_round,Corner_Profile,1)
              +R_function(y-1.5, Corner_round,Corner_Profile,1)
              +R_function(y+1,-Corner_round,Corner_Profile,1)
              +R_function(z-1.5,+Corner_round,Corner_Profile,1)
              +R_function(z+1,-Corner_round,Corner_Profile,1)-2 )


             +1
                 }
     threshold 0
      max_gradient 20
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}}
      translate < 2.5,-1.5,0>
               }


  isosurface {
     function    {

            -   R_function(-sqrt(pow(x-1,2)+pow(y-.5,2)+pow(z-1,2))+1,-.3,0,-1)

  +R_limit(
                 R_function(x+1.5,-Corner_round,Corner_Profile,1)
              +R_function(x-1,+Corner_round,Corner_Profile,1)
              +R_function(y-1.5, Corner_round,Corner_Profile,1)
              +R_function(y+1,-Corner_round,Corner_Profile,1)
              +R_function(z-1.5,+Corner_round,Corner_Profile,1)
              +R_function(z+1,-Corner_round,Corner_Profile,1)-2 )


             +1
                 }
     threshold 0
      max_gradient 20
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}}
      translate < 2.5,1.3,0>
               }


  isosurface {
     function    {

        - R_limit(
                 R_function(-sqrt(pow(x-.5,2)+pow(z,2))+1,-.3,0,-1)
                +R_function(y-1 ,+.3,0,1)
                +R_function(y+1,-.3,0,1))

       +R_limit( R_function(-sqrt(pow(x+.5,2)+pow(z,2))+1,-.3,0,-1)
                +R_function(y-1.5,+.3,0,1)
                +R_function(y+1.5,-.3,0,1))
                +1
                 }
     threshold 0
      max_gradient 20
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}}
      translate < -2.5,-1.5,0>

               }


Post a reply to this message

From: scott
Subject: Re: rounded_objects: a new feature?
Date: 20 Sep 2016 06:27:17
Message: <57e10f05$1@news.povray.org>
On 20/09/2016 10:04, John Greenwood wrote:
> scott <sco### [at] scottcom> wrote:
>>>>> If you're on to something then some working
>>>>> example code will go *far* further than just a text description.
>>>>
>>>> Totally agree, I am working on it.
>>>
>>> And here it is:
>>
>> A good start!
>>
>> How would you go about doing the union (or difference) of two rounded
>> cubes? I tried to modify the code to do this but couldn't get it to
>> work. If that works nicely then I think you're on to something...
>>
>> BTW you could always use a macro for each element, that depending on
>> some global switch, either used the standard POV non-rounded primitive
>> (for speed of setting up the scene) or the isosurface variant (for final
>> render).
>
> Excellent idea.
>
> And here are unions:

Looks good.

Just one small thing though, it looks like something odd is going on 
with the top (+y) face of the cube and also the join with that face and 
the sphere (maybe related). There is a "ridge" of some kind along the 
join, and the entire top face of the cube bends upwards way before the 
round should start (see attached).


Post a reply to this message


Attachments:
Download 'union.png' (37 KB)

Preview of image 'union.png'
union.png


 

From: John Greenwood
Subject: Re: rounded_objects: a new feature?
Date: 20 Sep 2016 08:15:01
Message: <web.57e12820696ad3a7cafab50@news.povray.org>
scott <sco### [at] scottcom> wrote:
> On 20/09/2016 10:04, John Greenwood wrote:
> > scott <sco### [at] scottcom> wrote:

> >> How would you go about doing the union (or difference) of two rounded
> >> cubes? I tried to modify the code to do this but couldn't get it to
> >> work. If that works nicely then I think you're on to something...

> >
> > And here are unions:
>
> Looks good.
>
> Just one small thing though, it looks like something odd is going on
> with the top (+y) face of the cube and also the join with that face and
> the sphere (maybe related). There is a "ridge" of some kind along the
> join, and the entire top face of the cube bends upwards way before the
> round should start (see attached).

The radius of the round at the junction between the two objects is a function of
the radii of the two contributing faces and will be sharper. I think what you
are seeing is just a very sharp corner. The rising of the top face of the cube
is due to the field from the sphere.

There are going to be limitations!

I am looking at a way to specify a larger radius at the intersection of the two
objects.


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 4 Messages >>>

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