|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I would like to see the following addition to splines in POV4, support for
automatic values to create evenly spaced items. If there exists a spline S
that is an auto-spline, then the distance between any two points on the spline
S(N*M) and S(N*(M+1)) would be equal. ( S(0.2) - S(0.0) == S(0.4) - S(0.2), and
so on)
I have currently created a macro that automatically creates a spline from an
array. It first determines the total distance of points and then creates a
spline with values ranging from 0.0 to 1.0 based on the distance of any item
from its start:
#macro auto_spline(_points, _count)
// First, determine total length of points
#local cur = 0;
#local total = 0.0;
#while(cur < _count - 1)
#local total = total + vlength(_points[cur + 1] - _points[cur]);
#local cur = cur + 1;
#end
spline
{
linear_spline
#local cur = 0;
#local accum = 0.0;
#while(cur < _count - 1)
accum, _points[cur],
#local accum = accum + vlength(_points[cur + 1] - _points[cur]) /
total;
#local cur = cur + 1;
#end
1.0, _points[cur]
}
#end
One idea would to introduce a new keyword 'auto_spline' that behaves much like a
regular spline, except it is not given values, but only points:
auto_spline
{
linear_spline
<point1>,
<point2>,
...
<pointN>
}
That after reading spline elements it would auto-generate the values such that
the value for any given element is equal to the total distance from that point
to the first point through all intermediate points, divided by the total spline
distance. Such a spline would take into consideration that different spline
types would cause the segments to have different lengths.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
The problem is that splines don't subdivide geometry; they merely
provide a mechanism for finding a point on a curve.
In other words, if I have a spline MySpline, then I could do:
MySpline(0.5)
MySpline(1/9)
MySpline(3.14159265358)
And all would return points. Nowhere does the spline itself create a
list of points.
You seem to be thinking of a spline as a sort of vector array. This is
not the case; it is a mathematical representation used to create a
curve. We then take values from that curve for all sorts of reasons,
but what use we make of them is unrelated to the spline itself.
...Ben Chambers
www.pacificwebguy.com
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Chambers" <ben### [at] pacificwebguycom> wrote:
> The problem is that splines don't subdivide geometry; they merely
> provide a mechanism for finding a point on a curve.
>
> In other words, if I have a spline MySpline, then I could do:
>
> MySpline(0.5)
> MySpline(1/9)
> MySpline(3.14159265358)
>
> And all would return points. Nowhere does the spline itself create a
> list of points.
>
> You seem to be thinking of a spline as a sort of vector array. This is
> not the case; it is a mathematical representation used to create a
> curve. We then take values from that curve for all sorts of reasons,
> but what use we make of them is unrelated to the spline itself.
>
> ...Ben Chambers
> www.pacificwebguy.com
That is the same as the auto_spline idea. It is just a spline without the
values, kind of like the spline for a sphere_sweep. The only difference is that
for an auto_spline the input values would be 0 to 1 and it would find a point on
the curve that is equal to a certain percentage along the curve. MySpline(0.5)
would find the point half-way along the distance of the curve, MySpline(0.75)
would find the point 75% the distance of the curve, etc.
If I have a spline like:
spline
{
linear_spline
0.0, <0, 0, 0>,
0.5, <1, 0, 0>,
1.0, <1, 1, 0>
}
Then using MySpline(0.5) would return the half-way point along the spline. But
if I change it:
spline
{
linear_spline
0.0, <0, 0, 0>,
0.5, <1, 0, 0>,
1.0, <1, 3, 0>
}
Then MySpline(0.5) is no longer half-way along the distance of the spline. It
finds a point on the curve, based on the value for the given point provided. I
must also change the spline value at the point in order to keep 0.5 the
midpoint:
spline
{
linear_spline
0.0, <0, 0, 0>,
0.25, <1, 0, 0>,
1.0, <1, 3, 0>
}
With an auto spline you would still provide a curve and use it to find a point
along that curve, but instead of providing values with those points, the value
would automatically be the distance to the point along the curve. Then it
could still be treated just like a spline, except 0..1 is used to find a point
at a certain percentage along the curve:
For both splines:
auto_spline
{
linear_spline
<0, 0, 0>,
<1, 0, 0>,
<1, 1, 0>
}
auto_spline
{
linear_spline
<0, 0, 0>,
<1, 0, 0>,
<1, 3, 0>
}
MySpline(0.5) would always find the point along the spline that is half-way: <1,
0, 0> for the first and <1, 1, 0> for the second.
Anyway that's the idea.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
OK, so you're saying that
auto_spline(x) - auto_spline(x+h) = l,
where x is a value 0..1, h is some value 0..1-x, and l is the distance
travelled along the spline.
In other words, the "distance" between the points returned by as(0.3)
and as(0.5) is the same as the "distance" between the points returned by
as(0.4) and as(0.6).
Put another way, if a spline were a string, then two points along the
spline separated by a constant factor would always have the same amount
of string between them.
Is that correct?
...Ben Chambers
www.pacificwebguy.com
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Chambers" <ben### [at] pacificwebguycom> wrote:
> OK, so you're saying that
> auto_spline(x) - auto_spline(x+h) = l,
> where x is a value 0..1, h is some value 0..1-x, and l is the distance
> travelled along the spline.
>
> In other words, the "distance" between the points returned by as(0.3)
> and as(0.5) is the same as the "distance" between the points returned by
> as(0.4) and as(0.6).
>
> Put another way, if a spline were a string, then two points along the
> spline separated by a constant factor would always have the same amount
> of string between them.
>
> Is that correct?
>
> ...Ben Chambers
> www.pacificwebguy.com
Yes that's right.
I use a spline for camera movement, and in this case the 'value' for each point
is good as it lets me set up speed. I can have 0..0.5 have a distance of 2 and
0.5..1 have a distance of 4, causing the camera to speed up when using 'clock'.
Or I can use it for nonlinear random numbers, for example the following spline I
use to create a ring of rocks around a small 'planet'
#declare rpos_sp = spline
{
linear_spline
0.0, 3.0,
0.25, 3.5,
0.251, 4.0,
0.5, 4.5,
0.501, 5.0,
1.0, 5.5
}
#declare rpos = rpos_spline(rand(R)).x;
In this case the spline value lets me put ~25% of the rocks at a distance of 3.0
to 3.5, ~25% at 4.0 to 4.5 and ~50% at 5.0 to 5.5, with a very small amount in
between.
But at times I just want to use a spline to duplicate objects along the spline
at even positions. Any time I change the spline curve, I have to go back and
change the values in order to get even positions.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Allen" <bri### [at] yahoocom> wrote:
> I would like to see the following addition to splines in POV4, support for
> automatic values to create evenly spaced items. If there exists a spline S
> that is an auto-spline, then the distance between any two points on the spline
> S(N*M) and S(N*(M+1)) would be equal. ( S(0.2) - S(0.0) == S(0.4) - S(0.2), and
> so on)
>
> I have currently created a macro that automatically creates a spline from an
> array. It first determines the total distance of points and then creates a
> spline with values ranging from 0.0 to 1.0 based on the distance of any item
> from its start:
>
> #macro auto_spline(_points, _count)
> // First, determine total length of points
> #local cur = 0;
> #local total = 0.0;
> #while(cur < _count - 1)
> #local total = total + vlength(_points[cur + 1] - _points[cur]);
> #local cur = cur + 1;
> #end
> spline
> {
> linear_spline
> #local cur = 0;
> #local accum = 0.0;
> #while(cur < _count - 1)
> accum, _points[cur],
> #local accum = accum + vlength(_points[cur + 1] - _points[cur]) /
> total;
> #local cur = cur + 1;
> #end
> 1.0, _points[cur]
> }
> #end
>
> One idea would to introduce a new keyword 'auto_spline' that behaves much like a
> regular spline, except it is not given values, but only points:
>
> auto_spline
> {
> linear_spline
> <point1>,
> <point2>,
> ...
> <pointN>
> }
>
> That after reading spline elements it would auto-generate the values such that
> the value for any given element is equal to the total distance from that point
> to the first point through all intermediate points, divided by the total spline
> distance. Such a spline would take into consideration that different spline
> types would cause the segments to have different lengths.
Is this related to the thread at
http://news.povray.org/povray.pov4.discussion.general/thread/%3C1v9up3pge5h98h0g5botvjnjj3amvddkgs%404ax.com%3E/?ttop=2
98998
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Woody" <nomail@nomail> wrote:
> Is this related to the thread at
>
http://news.povray.org/povray.pov4.discussion.general/thread/%3C1v9up3pge5h98h0g5botvjnjj3amvddkgs%404ax.com%3E/?ttop
=2
> 98998
I don't think so. Basically if I define a spline and set up an animation camera
to follow a spline as follows:
time1, point1,
time2, point2,
time3, point3,
time4, point4,
The value of the time would control the speed the camera moves at, which is
fine. If I want to make a segment faster I can decrease the difference of the
times, or if I want to slow it down I can increase the difference of the times
But any time I make a change I may also have to change the times in order to
keep the desired speed. Now for simple animations it may be desired for the
camera to always move the same speed along the spline, but in order to do this
any time you change the spline shape you must also calculate new times so the
time of each segment is the same. My idea was basically for it to somehow
automatically do that such that the time of each segment is the same. Of
course it could be used for anything a spline can be used for and not just
moving a camera. All it would do is automatically generate the time values
such that:
t / length_from_beginning(my_spline(t))
is equal to:
(t + N) / length_from_beginning(my_spline(t + N))
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> moving a camera. All it would do is automatically generate the time
> values
> such that:
>
> t / length_from_beginning(my_spline(t))
>
> is equal to:
>
> (t + N) / length_from_beginning(my_spline(t + N))
This would also be useful for placing objects with set gaps along a spline.
In the past I have written a macro to do exactly this, but having a built-in
way of doing it makes more sense (and a lot less work!).
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|