|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Hi.
Can someone help me out with a macro that can convert bezier splines to
regular splines? Something that can take as input:
prism {
linear_sweep
bezier_spline
1.0, //top
0.0, //bottom
16, //nr points
/* 0*/ <202, 884>, <202, 884>, <508,884>, <508,884>,
/* 1*/ <508, 884>, <508, 884>, <508,602>, <508,602>
}
and output something like
spline {
cubic_spline
0.0, <202, 0, 884>,
0.125, <202, 0, 884>,
0.25, <508, 0, 884>,
0.375, <508, 0, 884>,
0.5, <508, 0, 884>,
0.625, <508, 0, 884>,
0.75, <508, 0, 602>,
0.875, <508,602>
}
That is a macro that can take a prism containing a bezier_spline, and output
a regular spline.
My main problem is I don't know how to perform operations on POV-Ray objects
to extract their underlying structure. Any help would be greatly
appreciated.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"scam" <sca### [at] mailusydeduau> wrote:
> Hi.
>
> Can someone help me out with a macro that can convert bezier splines to
> regular splines? Something that can take as input:
>
> prism {
> linear_sweep
> bezier_spline
> 1.0, //top
> 0.0, //bottom
> 16, //nr points
> /* 0*/ <202, 884>, <202, 884>, <508,884>, <508,884>,
> /* 1*/ <508, 884>, <508, 884>, <508,602>, <508,602>
> }
>
> and output something like
>
> spline {
> cubic_spline
> 0.0, <202, 0, 884>,
> 0.125, <202, 0, 884>,
> 0.25, <508, 0, 884>,
> 0.375, <508, 0, 884>,
> 0.5, <508, 0, 884>,
> 0.625, <508, 0, 884>,
> 0.75, <508, 0, 602>,
> 0.875, <508,602>
> }
>
> That is a macro that can take a prism containing a bezier_spline, and output
> a regular spline.
>
> My main problem is I don't know how to perform operations on POV-Ray objects
> to extract their underlying structure. Any help would be greatly
> appreciated.
I don't know how to either. I hope you aren't dealing with a huge number of
items outputted by a modeler. If there are few enough, I'd go ahead and
manually extract the splines. Then you can make a macro which takes a
spline-identifier & interpolates along it. Note that the following is
written in the web-form and so it's not tested. I normally prefer
cubic_splines like your sample output but then you've got to deal with
adding the tangents on the end... Not too hard though because you've got
that info
from the bezier points. I just need to get to sleep.
#macro Bezier_To_Natural(TheBezierSpline,From_Point,To_Point,Frequency)
#local Ctr= From_Point;
spline{ natural_spline
#while(Ctr <= To_Point)
Ctr, //value along spline
TheBezierSpline(Ctr), //defining point
#local Ctr = Ctr+(1/Frequency);
#end //end while
#end //end macro
Charles
PS, did you want the output as text, or just a spline equivalent to your
example?
Post a reply to this message
|
|
| |
| |
|
|
From: bart
Subject: Re: Converting bezier splines to regular splines
Date: 12 Dec 2006 03:17:39
Message: <457e65a3@news.povray.org>
|
|
|
| |
| |
|
|
scam wrote:
> Hi.
>
> Can someone help me out with a macro that can convert bezier splines to
> regular splines?
Exact coversion bezier_spline => cubic_spline
or bezier_spline => natural_spline
is not possible in general case,
only other way conversion
cubic_spline => bezier_spline,
natural_spline => bezier_spline
would be always valid. See example in p.t.s-f.
Unfortunately, among (official) POV-Ray SDL spline types
there are no "general cubic" spline type (yet?),
like. for example, bezier_spline,
the one that any other cubic spline
could be converted to precisely.
Post a reply to this message
|
|
| |
| |
|
|
From: Tek
Subject: Re: Converting bezier splines to regular splines
Date: 13 Dec 2006 07:28:38
Message: <457ff1f6@news.povray.org>
|
|
|
| |
| |
|
|
You know personally I just wish pov could take bezier splines as one of it's
spline types, I love the whole control point system of bezier, it makes so
much sense!
Unfortunately the only way to "convert" it that I know of is to write your
own macro that supports bezier splines, then sample it at a lot of points
and create a spline to approximate those, though if you've got a macro that
does bezier splines there's no need to convert it! Unfortunately I haven't
got such a macro, the maths is on the internet somewhere...
--
Tek
http://evilsuperbrain.com
"scam" <sca### [at] mailusydeduau> wrote in message
news:web.457e0b831c8380c719862de70@news.povray.org...
> Hi.
>
> Can someone help me out with a macro that can convert bezier splines to
> regular splines? Something that can take as input:
>
> prism {
> linear_sweep
> bezier_spline
> 1.0, //top
> 0.0, //bottom
> 16, //nr points
> /* 0*/ <202, 884>, <202, 884>, <508,884>, <508,884>,
> /* 1*/ <508, 884>, <508, 884>, <508,602>, <508,602>
> }
>
> and output something like
>
> spline {
> cubic_spline
> 0.0, <202, 0, 884>,
> 0.125, <202, 0, 884>,
> 0.25, <508, 0, 884>,
> 0.375, <508, 0, 884>,
> 0.5, <508, 0, 884>,
> 0.625, <508, 0, 884>,
> 0.75, <508, 0, 602>,
> 0.875, <508,602>
> }
>
> That is a macro that can take a prism containing a bezier_spline, and
> output
> a regular spline.
>
> My main problem is I don't know how to perform operations on POV-Ray
> objects
> to extract their underlying structure. Any help would be greatly
> appreciated.
>
>
>
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Tek" <tek### [at] evilsuperbraincom> wrote:
> You know personally I just wish pov could take bezier splines as one of it's
> spline types, I love the whole control point system of bezier, it makes so
> much sense!
>
> Unfortunately the only way to "convert" it that I know of is to write your
> own macro that supports bezier splines, then sample it at a lot of points
> and create a spline to approximate those, though if you've got a macro that
> does bezier splines there's no need to convert it! Unfortunately I haven't
> got such a macro, the maths is on the internet somewhere...
>
> --
> Tek
> http://evilsuperbrain.com
>
Thanks for the replies guys.
I realised yesterday that I didn't actually need a POV-Ray compatible
spline, and that writing my own macro was the way to go. The maths is
actually very simple, and a non-recurrence form for a cubic bezier spline
can be found here: http://mathforum.org/library/drmath/view/54434.html
I'll post my macro once I clean it up a bit.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"scam" <sca### [at] mailusydeduau> wrote in message
news:web.457ffbce6a30df8e19862de70@news.povray.org...
>
> I'll post my macro once I clean it up a bit.
Awesome! I've wanted one for ages but always wussed out of looking up the
maths!
Though I remember writing a recursive one about 12 years ago...
Looking forward to your macro :)
--
Tek
http://evilsuperbrain.com
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|