|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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!
I appreciate my simple example could be achieved with some bits in a union, but
I am looking for a more generic approach for more complex shapes combining
straight lines and curves and want to make sure I'm not chasing something
impossible / impractical.
Excuse my lack of mathematical understanding, but is it also the case that
bezier curves cannot truly implement a circular curve?
Many thanks for any help.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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.
>
You could use CSG for that example.
Difference a cylinder from a box to create a box with a corner hollowed
out. Then difference your box prism with your newly created Difference.
If that does not make sense I can give an example after work.
--
Best Regards,
Stephen
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Stephen <mca### [at] aolDOTcom> wrote:
> 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.
> >
>
> You could use CSG for that example.
> Difference a cylinder from a box to create a box with a corner hollowed
> out. Then difference your box prism with your newly created Difference.
> If that does not make sense I can give an example after work.
>
> --
>
> Best Regards,
> Stephen
Thnaks Stephen... I have used CSG to do this before... but as I said in my
request I'm looking for prism based solutions to cater for much more complex
shapes. Essentially I want a generic approach to combined straight lines and
curves (inc circular) to define my prims.
Any other ideas anyone?
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> 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!
>
> I appreciate my simple example could be achieved with some bits in a union, but
> I am looking for a more generic approach for more complex shapes combining
> straight lines and curves and want to make sure I'm not chasing something
> impossible / impractical.
>
> Excuse my lack of mathematical understanding, but is it also the case that
> bezier curves cannot truly implement a circular curve?
>
> Many thanks for any help.
>
>
>
>
>
Bezier spline looks your best bet. Then, even with the added control it
gives you, you may need to subdivide the curved parts so that they
follow the desired curve well enough. You'll need to experiment with the
length of the control lines to get the desired curvature.
Second to that is the cubic spline.
I can't recomend the use of the quadratic spline as the control ot the
curvature is only effective at one end of every segments.
Another possibility would be to increase the number of points for your
prism and use a cubic spline. You need at least 3 points, placed very
close together, at each corners to make them sharp when you use a cubic
spline. Using that approach, there will be a small chamfer at those
corners. It can be a good thing in several cases, but it may not be
exactly what you want in this case.
Alain
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
/*
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Thanks guys for the really comprehensive answers and a great demonstration bart.
This gives me the encouragement to move forward with beziers.
Thanks again... Alan
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Bart as you correctly said I can use this as a starting point and I will
continue to investigate beziers. However I think (could be wrong) your
solution only works if the two lines either side of the corner are the same
length... for example this does not work... but I say again it does give me a
start point to think about.
//Setup for corner points
#declare C1 = <0,0>;
#declare C2 = <4,0>;
#declare C3 = <4,16>;
#declare C4 = <0,16>;
//Create array given desired corner radius of 1
#declare A=array[8]
{
C1 + <1,0>
C2 - <1,0>
C2 + <0,1>
C3 - <0,1>
C3 - <1,0>
C4 + <1,0>
C4 - <0,1>
C1 + <0,1>
}
// 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
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*-9
}
sphere { A[0] 0.1 pigment{Red} rotate 90*x translate <-9,0.5,0>}
sphere { A[1] 0.1 pigment{Red} rotate 90*x translate <-9,0.5,0>}
sphere { A[2] 0.1 pigment{Red} rotate 90*x translate <-9,0.5,0>}
sphere { A[3] 0.1 pigment{Red} rotate 90*x translate <-9,0.5,0>}
sphere { A[4] 0.1 pigment{Red} rotate 90*x translate <-9,0.5,0>}
sphere { A[5] 0.1 pigment{Red} rotate 90*x translate <-9,0.5,0>}
sphere { A[6] 0.1 pigment{Red} rotate 90*x translate <-9,0.5,0>}
sphere { A[7] 0.1 pigment{Red} rotate 90*x translate <-9,0.5,0>}
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
>Bart as you correctly said I can use this as a starting point
>and I will continue to investigate beziers.
you will not regret, it's truly amazing subject
>However I think (could be wrong) your solution only works
>if the two lines either side of the corner are the same
>length... for example this does not work...
true, that was a very raw example.
You need to edit Corner() macro to suit your own needs.
As Alain pointed out, you may need to subdivide the curved parts,
so the modified Corner() macro could generate several
cubic Bezier segments to fit the path you need.
>but I say again it does give me a start point to think about.
Meanwhile, you can try this simple one:
//======================8<=================
#macro Corner(P,Q,R,S)
#local A=Q;
#local D=R;
#local B=Q+(Q-P)/vlength(Q-P);
#local C=R+(R-S)/vlength(R-S);
A,B,C,D
#end
//======================8<=================
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
If your using the window version I wrote a POV Prism/Polygon program.
It let you see the difference splines.
PolPPrm is it's name.
It's here: http://leroywhetstone.s5.com/Win_Programs.html
Have Fun!
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Thanks for your help and patience Bart and again for your excellent macros. I
love the increased readability of spline definitions they bring - I know
probably not for everyone, but for me as a novice thinking about splines as a
series of trace actions is easier to understand and manage then a large pile of
points, for me it gives more focus on shape and dimensions. Your macros
provide elegant simplicity - I think your suggestions should be an example in
the help file to help novices get started or even a standard include file
"SplinesForDummies.inc" could be put together by someone way above my pay grade.
In case anyone is interested, I've copied my current feeble efforts to
illustrate a) that I know next to nothing about Pov or Beziers! and b) to show
the kind of mechanisms of how I would like to be able to setup splines. Clearly
I have a long way to go... but having fun ... many thanks again.
Alan
//======================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, 18, -4>
direction 1.5*z
right x*image_width/image_height
look_at <0.0, 0.0, 2.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 0.6 // amount [0.6]
brilliance 1.0 // tightness of diffuse illumination [1.0]
phong 0.5 // amount [0.0]
phong_size 40 // (1.0..250+) (dull->highly polished) [40]
metallic 0.8 //[Amount] // give highlight color of surface
reflection {1.0 metallic 1.0}
}
};
#macro BezierLine(A,D)
#local LineVec = D-A;
#local B= A + LineVec * 1/3;
#local C= A + LineVec * 2/3;
A,B,C,D
#declare CurrentPoint = D;
#declare CurrentDirection = vnormalize (LineVec);
#declare CurrentDirection = <CurrentDirection.x, CurrentDirection.y>;
#declare LastControl = C;
#end
//Draw a curve to a delta point with a specified exit direction
#macro CurveBy(dx,dy, ExitVec)
#declare Sharpness =3;
#local Ev = vnormalize(ExitVec);
#local Ev = <Ev.x, Ev.y>;
#local EndPoint = CurrentPoint + <dx,dy>;
#local VecLen = vlength(EndPoint-CurrentPoint);
#local Cp1 = CurrentPoint + CurrentDirection*VecLen/Sharpness;
#local Cp2 = EndPoint - Ev*VecLen/Sharpness;
CurrentPoint, Cp1, Cp2, EndPoint
#declare CurrentPoint = EndPoint;
#declare CurrentDirection = Ev;
#declare CurrentDirection = <CurrentDirection.x, CurrentDirection.y>;
#end
//Record the start point to allow use of closure statements
#macro SplineStart(Pos)
#declare StartingPoint = Pos;
#declare CurrentPoint = Pos;
#declare CurrentDirection = <1,0>;
#end
//Draw a horizontal line
#macro HLine(dx)
BezierLine(CurrentPoint, CurrentPoint + <dx,0>)
#end
//Draw a vertical line
#macro VLine(dy)
BezierLine(CurrentPoint, CurrentPoint + <0,dy>)
#end
//Draw by a delta amount
#macro LineBy(dx,dy)
BezierLine(CurrentPoint, CurrentPoint + <dx,dy>)
#end
#macro SplineCloseWithLine()
BezierLine(CurrentPoint,StartingPoint)
#end
prism {
linear_sweep // or conic_sweep for tapering to a point
bezier_spline // linear_spline | quadratic_spline |
cubic_spline |
-0.5, // height 1
0.1, // height 2
10*4, // number of points
SplineStart(<0,0>)
LineBy(4,4),
VLine(2),
CurveBy(-1.5, 2, < -1, 0>),
CurveBy(-1.5, -3, < -1,-1>),
CurveBy(-1, -0.5, < -1, 0>),
CurveBy(-1, 0.5, < -1, 1> ),
CurveBy(-1.5, 3, < -1, 0> ),
CurveBy(-1.5, -2 < 0,-1> ),
VLine(-2),
SplineCloseWithLine()
//open
texture{Texture}
}
union
{
#declare dx = -5; #while (dx < 5) cylinder{ <dx,-0.5,0> <dx,-0.5,10>
0.01 pigment{Red} } #declare dx = dx + 0.5; #end
#declare dz = 0; #while (dz < 10) cylinder{ <-5,-0.5,dz> <5,-0.5,dz >
0.01 pigment{Blue} } #declare dz = dz + 0.5; #end
translate .1*y
no_shadow
}
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|