POV-Ray : Newsgroups : povray.general : How does bezier_spline work in prism? Server Time
24 Apr 2024 13:37:07 EDT (-0400)
  How does bezier_spline work in prism? (Message 11 to 12 of 12)  
<<< Previous 10 Messages Goto Initial 10 Messages
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 10 Messages Goto Initial 10 Messages

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