POV-Ray : Newsgroups : povray.general : How does bezier_spline work in prism? Server Time
29 Mar 2024 11:07:53 EDT (-0400)
  How does bezier_spline work in prism? (Message 3 to 12 of 12)  
<<< Previous 2 Messages Goto Initial 10 Messages
From: jr
Subject: Re: How does bezier_spline work in prism?
Date: 8 Sep 2019 17:30:04
Message: <web.5d757230cb41806efeeb22ff0@news.povray.org>
hi,

"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Kima" <nomail@nomail> wrote:
> > I tried to make a simple circle by bezier_spline,
>
> IIRC, you can't do it with a single spline, but can append 2 semicircle
> approximations.
> See if this helps any, and see if LeForgeron's wiki page helps any.

prisms with bezier_spline are also used in the distribution include file
'lemon.inc', under 'scenes/advanced/grenadine/'.


regards, jr.


Post a reply to this message

From: Kima
Subject: Re: How does bezier_spline work in prism?
Date: 8 Sep 2019 18:35:01
Message: <web.5d7581f3cb41806eecc0fada0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Kima" <nomail@nomail> wrote:
> > I tried to make a simple circle by bezier_spline,
>
> IIRC, you can't do it with a single spline, but can append 2 semicircle
> approximations.
>
> See if this helps any, and see if LeForgeron's wiki page helps any.
>
>
https://news.povray.org/povray.general/thread/%3Cweb.5c47356c36095c6fbe7517870%40news.povray.org%3E/
>
> http://wiki.povray.org/content/User:Le_Forgeron

I still don't understand why povray draws berzier curves this way.

Mathematically, the bezier curves of these points create a circle. See this
image
https://ibb.co/YykPGPM


Post a reply to this message

From: Bald Eagle
Subject: Re: How does bezier_spline work in prism?
Date: 8 Sep 2019 21:15:00
Message: <web.5d75a679cb41806e4eec112d0@news.povray.org>
"Kima" <nomail@nomail> wrote:

> I still don't understand why povray draws berzier curves this way.
>
> Mathematically, the bezier curves of these points create a circle. See this
> image
> https://ibb.co/YykPGPM

POV-Ray ought to draw Bezier curves the way all Bezier curves are drawn.
I'm not sure what your image is supposed to show, as there's no mathematical
data that relate it to Bezier curves.

Maybe try:
https://stackoverflow.com/questions/1734745/how-to-create-circle-with-b%C3%A9zier-curves

I've probably spent the last several years working on understanding Bezier
splines and patches.
Lods of mistakes and frustration and misconceptions, but eventually got it all
worked out in the end.
Tor Olav Kristensen (TOK) mentored me after I got my second wind and felt up to
attacking the topic again.



Cousin Ricky has a Bezier spline based sphere sweep in the object collection.
Jerome Grimbert (LeForgeron) likely also has some good Bezier spline/patch work
in his excellent collection of experiments.


Post a reply to this message

From: William F Pokorny
Subject: Re: How does bezier_spline work in prism?
Date: 8 Sep 2019 21:56:07
Message: <5d75b137$1@news.povray.org>
On 9/8/19 2:32 PM, Kima wrote:
> I tried to make a simple circle by bezier_spline,
> 
>      prism {
>        bezier_spline
>       0,-.3,32,
> <0.154,0.605>,<0.128,0.605>,<0.128,0.605>,<0.1105,0.6225>
> <0.1105,0.6225>,<0.093,0.64>,<0.093,0.64>,<0.093,0.666>
> <0.093,0.666>,<0.093,0.691>,<0.093,0.691>,<0.1105,0.709>
> <0.1105,0.709>,<0.128,0.727>,<0.128,0.727>,<0.154,0.727>
> <0.154,0.727>,<0.18,0.727>,<0.18,0.727>,<0.1975,0.709>
> <0.1975,0.709>,<0.215,0.691>,<0.215,0.691>,<0.215,0.666>
> <0.215,0.666>,<0.215,0.64>,<0.215,0.64>,<0.1975,0.6225>
> <0.1975,0.6225>,<0.18,0.605>,<0.18,0.605>,<0.154,0.605>
> 
>        pigment { color rgb<1,0,0>}
> 
> }
> 
> but instead of a circle, it gave me an octagon as it seems the control points
> are connected instead of start and end points.
> 
> What is wrong with my setting <start,control1,control2,end>?
> 
> Note that I want to understand bezier_spline rather than finding an alternative
> for creating a specific shape.
> 
Your control points in each segment are identical.

The usual way to do circles with Bezier curves is with 4 segments using 
the method from: Michael Goldapp, "Approximation of circular arcs by 
cubic polynomials" Computer Aided Geometric Design (#8 1991 pp.227-238).

I'm lazy and keep a point list created by this method for a circle at a 
radius of 1.0 at the origin laying around - which I can scale, move etc. 
So a circle within a circle to create a prism ring of sorts becomes:

#declare Cheese = srgb <1,0.65098,0>;
#declare Prism00 = prism {
     bezier_spline
     linear_sweep
     -0.2, 0.2, 32,
     <1,0>,<1,0.552285>,<0.552285,1>,<0,1>
     <0,1>,<-0.552285,1>,<-1,0.552285>,<-1,0>
     <-1,0>,<-1,-0.552285>,<-0.552285,-1>,<0,-1>
     <0,-1>,<0.552285,-1>,<1,-0.552285>,<1,0>
     <0.5,0>,<0.5,0.276143>,<0.276143,0.5>,<0,0.5>
     <0,0.5>,<-0.276143,0.5>,<-0.5,0.276143>,<-0.5,0>
     <-0.5,0>,<-0.5,-0.276143>,<-0.276143,-0.5>,<0,-0.5>
     <0,-0.5>,<0.276143,-0.5>,<0.5,-0.276143>,<0.5,0>
     pigment { color Cheese }
}

Bill P.


Post a reply to this message

From: Kima
Subject: Re: How does bezier_spline work in prism?
Date: 8 Sep 2019 23:05:00
Message: <web.5d75c126cb41806eecc0fada0@news.povray.org>
William F Pokorny <ano### [at] anonymousorg> wrote:
> On 9/8/19 2:32 PM, Kima wrote:
> > I tried to make a simple circle by bezier_spline,
> >
> >      prism {
> >        bezier_spline
> >       0,-.3,32,
> > <0.154,0.605>,<0.128,0.605>,<0.128,0.605>,<0.1105,0.6225>
> > <0.1105,0.6225>,<0.093,0.64>,<0.093,0.64>,<0.093,0.666>
> > <0.093,0.666>,<0.093,0.691>,<0.093,0.691>,<0.1105,0.709>
> > <0.1105,0.709>,<0.128,0.727>,<0.128,0.727>,<0.154,0.727>
> > <0.154,0.727>,<0.18,0.727>,<0.18,0.727>,<0.1975,0.709>
> > <0.1975,0.709>,<0.215,0.691>,<0.215,0.691>,<0.215,0.666>
> > <0.215,0.666>,<0.215,0.64>,<0.215,0.64>,<0.1975,0.6225>
> > <0.1975,0.6225>,<0.18,0.605>,<0.18,0.605>,<0.154,0.605>
> >
> >        pigment { color rgb<1,0,0>}
> >
> > }
> >
> > but instead of a circle, it gave me an octagon as it seems the control points
> > are connected instead of start and end points.
> >
> > What is wrong with my setting <start,control1,control2,end>?
> >
> > Note that I want to understand bezier_spline rather than finding an alternative
> > for creating a specific shape.
> >
> Your control points in each segment are identical.
>
> The usual way to do circles with Bezier curves is with 4 segments using
> the method from: Michael Goldapp, "Approximation of circular arcs by
> cubic polynomials" Computer Aided Geometric Design (#8 1991 pp.227-238).
>
> I'm lazy and keep a point list created by this method for a circle at a
> radius of 1.0 at the origin laying around - which I can scale, move etc.
> So a circle within a circle to create a prism ring of sorts becomes:
>
> #declare Cheese = srgb <1,0.65098,0>;
> #declare Prism00 = prism {
>      bezier_spline
>      linear_sweep
>      -0.2, 0.2, 32,
>      <1,0>,<1,0.552285>,<0.552285,1>,<0,1>
>      <0,1>,<-0.552285,1>,<-1,0.552285>,<-1,0>
>      <-1,0>,<-1,-0.552285>,<-0.552285,-1>,<0,-1>
>      <0,-1>,<0.552285,-1>,<1,-0.552285>,<1,0>
>      <0.5,0>,<0.5,0.276143>,<0.276143,0.5>,<0,0.5>
>      <0,0.5>,<-0.276143,0.5>,<-0.5,0.276143>,<-0.5,0>
>      <-0.5,0>,<-0.5,-0.276143>,<-0.276143,-0.5>,<0,-0.5>
>      <0,-0.5>,<0.276143,-0.5>,<0.5,-0.276143>,<0.5,0>
>      pigment { color Cheese }
> }
>
> Bill P.

Thanks, Bill. I got it that the problem is my points, but your answer came
before I correct myself. Like your set, the controls should have identical x OR
y, but mine has both together, and that was the problem.


Post a reply to this message

From: kurtz le pirate
Subject: Re: How does bezier_spline work in prism?
Date: 14 Sep 2019 11:27:37
Message: <5d7d06e9$1@news.povray.org>
On 08/09/2019 20:32, Kima wrote:

> but instead of a circle, it gave me an octagon as it seems the control points
> are connected instead of start and end points.
> 
> What is wrong with my setting <start,control1,control2,end>?
> 
> Note that I want to understand bezier_spline rather than finding an alternative
> for creating a specific shape.

A little reading there :
<https://stackoverflow.com/questions/1734745/how-to-create-circle-with-b%C3%A9zier-curves>



-- 
Kurtz le pirate
Compagnie de la Banquise


Post a reply to this message

From: Leroy
Subject: Re: How does bezier_spline work in prism?
Date: 18 Sep 2019 12:50:01
Message: <web.5d825f0dcb41806e610414250@news.povray.org>
This may be a little late to help you much.
So here it goes. A long ago I fell in love with Prisms and Polygons, or I should
say it was the shapes they created. I think one of my first POV files was a
snowflake maker using Polygons, then prisms. There are an infinite number of
shape s you can come up with. To keep up with all those shapes I came up with,
and make new ones I wrote a windows program.
You can find it at  http://leroyw.byethost15.com/

 But you where asking about a circle(really a cylinder) using Prism and
bezier_spline. We should be able to let POV make one of any size for us.

You know the basics data
point1, control1, control2, point2
point2, control1, control2, point3
 :          :         :        :
pointN, controlNa, control1a, point1

if the prism is center is <0,0> and the number of points is N
 all the points are just point1 rotated around the center evenly
 the control points are a little more complicated
 if you use the formula with K=N
  control1(K)=(Pnt(N)+Pnt(N+1))*.333 and control2(K)=(Pnt(N)+Pnt(N+1))*.6666
  you will a n sided polygonal shape
 but if you adjust the control points out using
  L=vlength(Pnt(0))
  control1(K)=vnormalize(control1(K))*L
  control2(K)=vnormalize(control1(K))*L
 you should get a nice circle

This is just an over view. The code will have to be different. Prism doesn't
like 3d vectors and vnormalize outputs a 3d vector
I may be wrong, I haven't tried it.

Have Fun!


Post a reply to this message

From: Alain Martel
Subject: Re: How does bezier_spline work in prism?
Date: 18 Sep 2019 18:59:16
Message: <5d82b6c4$1@news.povray.org>
Le 2019-09-18 à 12:45, Leroy a écrit :
> 
>   This may be a little late to help you much.
> So here it goes. A long ago I fell in love with Prisms and Polygons, or I should
> say it was the shapes they created. I think one of my first POV files was a
> snowflake maker using Polygons, then prisms. There are an infinite number of
> shape s you can come up with. To keep up with all those shapes I came up with,
> and make new ones I wrote a windows program.
> You can find it at  http://leroyw.byethost15.com/
> 
>   But you where asking about a circle(really a cylinder) using Prism and
> bezier_spline. We should be able to let POV make one of any size for us.
> 
> You know the basics data
> point1, control1, control2, point2
> point2, control1, control2, point3
>   :          :         :        :
> pointN, controlNa, control1a, point1
> 
> if the prism is center is <0,0> and the number of points is N
>   all the points are just point1 rotated around the center evenly
>   the control points are a little more complicated
>   if you use the formula with K=N
>    control1(K)=(Pnt(N)+Pnt(N+1))*.333 and control2(K)=(Pnt(N)+Pnt(N+1))*.6666
>    you will a n sided polygonal shape
>   but if you adjust the control points out using
>    L=vlength(Pnt(0))
>    control1(K)=vnormalize(control1(K))*L
>    control2(K)=vnormalize(control1(K))*L
>   you should get a nice circle
> 
> This is just an over view. The code will have to be different. Prism doesn't
> like 3d vectors and vnormalize outputs a 3d vector
> I may be wrong, I haven't tried it.
> 
> Have Fun!
> 
> 
> 
> 
If all your points share the same Y coordinate, there is no problem. 
Same if they share the same X or Z.
You can multiply every point by <1,0,1> to ensure that you are on the 
X-Z plane.


Post a reply to this message

From: Leroy
Subject: Re: How does bezier_spline work in prism?
Date: 19 Sep 2019 14:20:00
Message: <web.5d83c551cb41806e561dc72c0@news.povray.org>
I couldn't let this go. I had to write the code!
 so here it is right from my editor

// round prism
// Vers: 3.7
// Auth: Leroy Whetstone
// Email whe### [at] gmailcom
//====================================================================
#version 3.7;
global_settings {assumed_gamma 1 max_trace_level 20}

#include "colors.inc"

camera{ location <0,15,0>
        look_at <0,0,0>
        right x*image_width/image_height
        }
 light_source{<0,20,0> color White}

//-------------change-------------

#declare Pnts=4;// points >=3  3 is a little funky
#declare Rad=3; // radius

//----------end of change----------

#declare Pa=array[Pnts];//points array
#declare Ca=array[2][Pnts];// control points array

#declare Td=4*Pnts;//prism entries

#declare An=360/Pnts;// angle to place points
#declare An2=An/3;// angle of control points

#declare CL=Rad/cos(radians(An2));// length of control points from <0,0,0>

//points
#for(a,0,Pnts-1)
 #declare Pa[a]=vrotate(x*Rad,y*a*An);
#end

//Base of control points
 #declare D=vnormalize(vrotate(Pa[0],y*An2))*CL;
 #declare Ca[0][0]=D;
 #declare D=vnormalize(vrotate(Pa[0],y*An2*2))*CL;
 #declare Ca[1][0]=D;

// rest of control points
#for(a,1,Pnts-1)
 #declare Ca[0][a]=vrotate(Ca[0][0],y*a*An);
 #declare Ca[1][a]=vrotate(Ca[1][0],y*a*An);
#end

//Show

prism{bezier_spline
      -1,1,Td
     #for(a,0,Pnts-1)
      <Pa[a].x,Pa[a].z>
      <Ca[0][a].x,Ca[0][a].z>
      <Ca[1][a].x,Ca[1][a].z>
      #if(a+1>Pnts-1) <Pa[0].x,Pa[0].z>
      #else <Pa[a+1].x,Pa[a+1].z>
      #end
     #end
     pigment{rgb <1,0,0>}
     }

//show points
#for(a,0,Pnts-1)
  sphere{<Pa[a].x,1,Pa[a].z>,.1 pigment{Blue}}
  sphere{<Ca[0][a].x,1,Ca[0][a].z>,.1 pigment{Green}}
  sphere{<Ca[1][a].x,1,Ca[1][a].z>,.1 pigment{Yellow}}

   cylinder{<Pa[a].x,1,Pa[a].z> <Ca[0][a].x,1,Ca[0][a].z>,.05 pigment{Pink}}
   cylinder{<Ca[0][a].x,1,Ca[0][a].z> <Ca[1][a].x,1,Ca[1][a].z>,.05
pigment{Pink}}
  #if(a<Pnts-1)
   cylinder{<Ca[1][a].x,1,Ca[1][a].z><Pa[a+1].x,1,Pa[a+1].z> ,.05 pigment{Pink}}
  #end
#end
  cylinder{<Ca[1][Pnts-1].x,1,Ca[1][Pnts-1].z><Pa[0].x,1,Pa[0].z> ,.05
pigment{Pink}}


 After writing this I thought of another feature to add. That is SCALE !
 You could make ovals.
Have Fun!


Post a reply to this message

From: Bald Eagle
Subject: Re: How does bezier_spline work in prism?
Date: 19 Sep 2019 15:35:00
Message: <web.5d83d80ecb41806e4eec112d0@news.povray.org>
"Leroy" <whe### [at] gmailcom> wrote:
> I couldn't let this go. I had to write the code!
>  so here it is right from my editor

Hi Leroy - I didn't work out your calculations, but comparing the result after
adding:

torus {3, 0.005 texture {pigment {White} finish {diffuse 1}} translate y}

Shows it to have a bit of a VISIO "squircle" thing going on.

[ site:visguy.com squircles ]


Adding #declare CL = CL*0.985;

Makes it noticeably more circular.


If you want to tweak it:
http://spencermortensen.com/articles/bezier-circle/

>  After writing this I thought of another feature to add. That is SCALE !
>  You could make ovals.
> Have Fun!


Post a reply to this message

<<< Previous 2 Messages Goto Initial 10 Messages

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