POV-Ray : Newsgroups : povray.newusers : Quadrilateral with rounded corners Server Time
22 Dec 2024 00:37:50 EST (-0500)
  Quadrilateral with rounded corners (Message 1 to 2 of 2)  
From: John Greenwood
Subject: Quadrilateral with rounded corners
Date: 30 Nov 2013 05:50:00
Message: <web.5299c2b541dcd53fa7cafab50@news.povray.org>
I really wanted objects with a rectangular cross-section with rounded corners
for my first serious scene. There does not seem to be satisfactory means of
creating this so I have written the scene below.

This works fine but is very clunky. Could it be turned into a macro?
Could it be extended to take an arbitrary number of sides?
I have looked at the manual but feel rather daunted!

// Persistence Of Vision Ray Tracer sample Scene
// by John Greenwood
// Rounded.POV demonstrates a means of creating a straight sided quadrilateral
// with rounded corners


#version 3.7;
global_settings {assumed_gamma 1.0}
#default{ finish{ ambient 0.1 diffuse 0.9 }}

#include "colors.inc"

light_source { <100,1000,-1000>, White}

camera { location <2,10,-20>
         right     x*image_width/image_height
         angle 35 // direction 2*z
         look_at <0,0,0>
       }

#declare Cor = array [5][4] {
  { 0.0 , 4.0 , 1.0 , 0.0 },   // Put the coordinates of the four corners in the
first two cells in the row.
  { -4.0 , 0.0 , 1.0 , 0.0 },  // Put the radius for the corner in the third
cell in the row.
  { 0.0 , -4.0 , 1.0 , 0.0 },  // The fourth cell in the row is used for
calculation, no input required.
  { 4.0 , 0.0 , 3.0 , 0.0 },
  { 0.0 , 4.0 , 1.0 , 0.0 }    // same as row 1
} ;


#for (N,0,3)
  #declare Cor[N][3] =  atan2((Cor[N][1]-Cor[N+1][1]),(Cor[N][0]-Cor[N+1][0]));
#end
#declare Cor[4][3] =  Cor[0][3];

#declare S = array[32]

#for (N,0,3)
  #declare S[8*N  ] = <Cor[N][0]  -    Cor[N][2]  *cos(Cor[N][3])  ,Cor[N][1]  -
   Cor[N][2]  *sin(Cor[N][3])>;
  #declare S[8*N+1] = <Cor[N][0]  -1.5*Cor[N][2]  *cos(Cor[N][3])  ,Cor[N][1]
-1.5*Cor[N][2]  *sin(Cor[N][3])>;
  #declare S[8*N+2] = <Cor[N+1][0]+1.5*Cor[N+1][2]*cos(Cor[N][3])
,Cor[N+1][1]+1.5*Cor[N+1][2]*sin(Cor[N][3])>;
  #declare S[8*N+3] = <Cor[N+1][0]+    Cor[N+1][2]*cos(Cor[N][3])  ,Cor[N+1][1]+
   Cor[N+1][2]*sin(Cor[N][3])>;
  #declare S[8*N+4] = <Cor[N+1][0]+    Cor[N+1][2]*cos(Cor[N][3])  ,Cor[N+1][1]+
   Cor[N+1][2]*sin(Cor[N][3])>;
  #declare S[8*N+5] = <Cor[N+1][0]+0.5*Cor[N+1][2]*cos(Cor[N][3])
,Cor[N+1][1]+0.5*Cor[N+1][2]*sin(Cor[N][3])>;
  #declare S[8*N+6] =
<Cor[N+1][0]-0.5*Cor[N+1][2]*cos(Cor[N+1][3]),Cor[N+1][1]-0.5*Cor[N+1][2]*sin(Cor[N+1][3])>;
  #declare S[8*N+7] = <Cor[N+1][0]-    Cor[N+1][2]*cos(Cor[N+1][3]),Cor[N+1][1]-
   Cor[N+1][2]*sin(Cor[N+1][3])>;
#end

prism {
  linear_sweep
  bezier_spline
  0,1,32,
  S[0] ,S[1] ,S[2] ,S[3] ,S[4] ,S[5] ,S[6] ,S[7],    // can this be done more
elegantly?
  S[8] ,S[9 ],S[10],S[11],S[12],S[13],S[14],S[15],
  S[16],S[17],S[18],S[19],S[20],S[21],S[22],S[23],
  S[24],S[25],S[26],S[27],S[28],S[29],S[30],S[31]
  pigment { White }
}


Post a reply to this message

From: Le Forgeron
Subject: Re: Quadrilateral with rounded corners
Date: 30 Nov 2013 06:17:02
Message: <5299c92e$1@news.povray.org>
Le 30/11/2013 11:49, John Greenwood nous fit lire :
> I really wanted objects with a rectangular cross-section with rounded corners
> for my first serious scene. There does not seem to be satisfactory means of
> creating this so I have written the scene below.

You might have overlooked the superellipsoid, especially the ones with
parameters below <1,1> (sphere) to <0,0> (box).


Post a reply to this message

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