|
![](/i/fill.gif) |
/*
On 01/26/2010 12:22 PM, Alan1961 wrote:
>I would like to create prisms with a combination
> of straight lines and curves - including circular.
>For a very very simple example - a 4*4 box shape but with one corner
>rounded off with a circular radius of 1.
>I am struggling to work out how to do this
>with either a cubic or quadratic
>spline and cannot find an example.
>Should I be using beziers?
>I've tried not to be lazy but would
>appreciate some kind experienced Pov user showing me the way!
You can probably find better examples,
but this could be a starting point.
Example below demonstrates how to
combine linear and cubic segments to generate a Bezier spline
for the prism shape.
*/
//======================8<======================
// Persistence of Vision Ray Tracer Scene Description File
// File: ?.pov
// Vers: 3.6
// Desc: Basic Scene Example
// Date: mm/dd/yy
// Auth: ?
//
#version 3.6;
#include "colors.inc"
global_settings {
assumed_gamma 1.0
}
// ----------------------------------------
camera {
location <0.0, 2, -4.0>*4
direction 1.5*z
right x*image_width/image_height
look_at <0.0, 0.0, 0.0>
}
background { color rgb <0.1, 0.3, 0.8> }
light_source {
<0, 0, 0> // light's position (translated below)
color rgb <1, 1, 1> // light's color
translate <-30, 30, -30>
}
// ----------------------------------------
plane {
y, -0.5-1e-6
pigment { color rgb <0.7,0.5,0.3> }
}
#declare Texture=texture {
pigment {color rgb <0.2,0.5,0.2> }
finish {
ambient 0.1 // ambient surface reflection color [0.1]
// (---diffuse lighting---)
diffuse 0.6 // amount [0.6]
brilliance 1.0 // tightness of diffuse illumination [1.0]
// (---phong highlight---)
phong 0.5 // amount [0.0]
phong_size 40 // (1.0..250+) (dull->highly polished) [40]
// (---specular highlight---)
//specular 0.5 // amount [0.0]
//roughness 0.05 // (~1.0..0.0005) (dull->highly polished) [0.05]
// (---phong and specular---)
metallic 0.8 //[Amount] // give highlight color of surface
// (---reflection---)
reflection {
1.0
metallic 1.0
}
}
};
#macro BezierLine(A,D)
// Convert linear segment into cubic Bezier form
#local B=(2*A+D)/3;
#local C=(A+2*D)/3;
A,B,C,D
#end
#macro Corner(P,Q,R,S)
//
#local A=Q;
#local D=R;
#local B=Q+(Q-P)/2;
#local C=R+(R-S)/2;
A,B,C,D
#end
#declare A=array[8]{
<-1,-2>
<1,-2>
<2,-1>
<2,1>
<1,2>
<-1,2>
<-2,1>
<-2,-1>
}
// Prism outline is constructed from linear segments,
// represented as a cubic Bezier
prism {
linear_sweep // or conic_sweep for tapering to a point
bezier_spline // linear_spline | quadratic_spline | cubic_spline |
bezier_spline
-0.5, // height 1
0.5, // height 2
8*4, // number of points
// (--- the <u,v> points ---)
BezierLine(A[0],A[1]),
BezierLine(A[1],A[2]),
BezierLine(A[2],A[3]),
BezierLine(A[3],A[4]),
BezierLine(A[4],A[5]),
BezierLine(A[5],A[6]),
BezierLine(A[6],A[7]),
BezierLine(A[7],A[0])
// [open]
// [sturm]
texture{Texture}
translate -x*3
}
// Here some real cubic curves are used for corners
prism {
linear_sweep // or conic_sweep for tapering to a point
bezier_spline // linear_spline | quadratic_spline | cubic_spline |
bezier_spline
-0.5, // height 1
0.5, // height 2
8*4, // number of points
// (--- the <u,v> points ---)
BezierLine(A[0],A[1]),
Corner(A[0],A[1],A[2],A[3]),
BezierLine(A[2],A[3]),
Corner(A[2],A[3],A[4],A[5]),
BezierLine(A[4],A[5]),
Corner(A[4],A[5],A[6],A[7]),
BezierLine(A[6],A[7]),
Corner(A[6],A[7],A[0],A[1])
// [open]
// [sturm]
texture{Texture}
translate x*3
}
// And this one uses only one curved corner
prism {
linear_sweep // or conic_sweep for tapering to a point
bezier_spline // linear_spline | quadratic_spline | cubic_spline |
bezier_spline
-0.5, // height 1
0.5, // height 2
8*4, // number of points
// (--- the <u,v> points ---)
BezierLine(A[0],A[1]),
Corner(A[0],A[1],A[2],A[3]),
BezierLine(A[2],A[3]),
BezierLine(A[3],A[4]),
BezierLine(A[4],A[5]),
BezierLine(A[5],A[6]),
BezierLine(A[6],A[7]),
BezierLine(A[7],A[0])
// [open]
// [sturm]
texture{Texture}
translate -z*4
}
//======================8<======================
Post a reply to this message
|
![](/i/fill.gif) |