|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Hello again,
I wrote my macro for splines to be created from set of points given in array. It
works almost perfectly, but my idea is to have a curve following exactly my
points. I know splines work this way, but when I want a curve that is straight
initialy and turns to the right after some length I get a little left bend and
next expected right bend. Is it possible to create needed smooth (it means no
linear and quadratic splines can be used) curve?
Below is my implementation:
#macro createSpline(arr, stype, displacement, middlePoint)
#local arrSize = dimension_size(arr,1);
#local length = 0;
#local i = 0;
#while(i < arrSize - 1)
#local length = length + vlength(arr[i+1] - arr[i]);
#local i = i + 1;
#end
#local overallLength = length;
#local length = 0;
#local i = 0;
spline {
#switch (stype)
#case (linear_spline_id) linear_spline #break
#case (quadratic_spline_id) quadratic_spline #break
#case (cubic_spline_id) cubic_spline #break
#case (natural_spline_id) natural_spline #break
#end
0.00, arr[1] + displacement,
#while(i < arrSize - 1)
#local length = length + vlength(arr[i+1] - arr[i]);
#if(arr[i+1].y < 0)
#declare middlePoint = length/overallLength;
#end
coef*length/overallLength, arr[i+1] + displacement,
#local i = i + 1;
#end
1.00, arr[arrSize - 1] + displacement
}
#end
I thought that using variable "coef" a little bit lower than 1 will solve the
problem but I was wrong? Any idea?
twister
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
If the issue needs to be better described, please let me know as it is very
important for me.
twister
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"twister" <twi### [at] o2pl> wrote:
> works almost perfectly, but my idea is to have a curve following exactly my
> points. I know splines work this way, but when I want a curve that is straight
> initialy and turns to the right after some length I get a little left bend and
> next expected right bend. Is it possible to create needed smooth (it means no
> linear and quadratic splines can be used) curve?
Such effects are basically inevitable if you try to control a spline solely by a
set of points it is to "touch": You obviously give the spline full freedom over
the tangents at those points, and it *will* use this freedom, possibly in a way
you didn't intend. (Unless, of course, you already planned for this effect when
chosing the points.)
By taking a small left turn first, the spline reduces its overall "strain". So
what you can do to minimize this effect is move the last control point on the
straight line inward a bit, to get a softer transition into the curve.
There is nothing you can do in the macro code itself. This is a systematic
problem you will get with any spline type you can possibly imagine: Even if you
chose a spline type that gave you more control over the direction in a specific
point (e.g. Bezier splines), your macro still lacks the user input to decide
how to make any use of it.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"twister" <twi### [at] o2pl> wrote:
> #macro createSpline(arr, stype, displacement, middlePoint)
> #local arrSize = dimension_size(arr,1);
.......
I am working on a spline-generating macro too, so your question is an
interesting one. (I never actually tried to change the spline-type *during* the
spline--I guess I assumed that it would create the very problem you are trying
to work around. But it's an interesting idea.)
Just so that I understand your question correctly: When you switch between a
linear_spline type (for a non-curving straight line) and one of the non-linear
spline types (for an actual curve), are you trying to *minimize* the curve
transition there, or *maximize* it? Or are you trying to simply make the spline
curve *exactly* match the values and spline types you give it, at those
particular spline points? (In which case, clipka's explanation of the problem
is a good one.)
BTW, I only occasionally work with macros, so I'm still learning the finer
points of how to construct them. Before commenting further, I want to make sure
I understand your macro code itself. Is dimension_size another macro of some
kind, that you are plugging in? If so, does it return just a single value?
Ken W.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Kenneth" <kdw### [at] earthlinknet> wrote:
> ...Is dimension_size another macro of some
> kind, that you are plugging in? If so, does it return just a single value?
>
Just discovered that dimension_size() is a POV-Ray keyword for finding the
'dimension size' (Duh!) of a pre-made array. Oh well, I'm still learning...
KW
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Of course I want to get a spline following exactly my points. I didn't even
think of combining two splines in one. I don't think it's possible.
For now because natural_spline doesn't give me solution I wonder how to connect
two separate straight lines with smooth curve as a part of of circle or
quadratic function in the way where you can not see where straight lines end
and curve begins. This is a mathematic problem that shouldn't be very complex.
So in the result I would like to create output points array - some kind of
spline substitution. Any ideas?
twister
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|