Difference between revisions of "User:Le Forgeron/splines"
Le Forgeron (talk | contribs) |
Le Forgeron (talk | contribs) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | {{User:Le_Forgeron/HgPovray38/ | + | {{User:Le_Forgeron/HgPovray38/available}} |
==Splines== | ==Splines== | ||
Line 113: | Line 113: | ||
spline { | spline { | ||
basic_x_spline [freedom_degree FLOAT] | basic_x_spline [freedom_degree FLOAT] | ||
− | time_Val_1, <Vector_1> | + | time_Val_1, <Vector_1> [,] |
− | time_Val_2, <Vector_2> | + | time_Val_2, <Vector_2> [,] |
... | ... | ||
− | time_Val_n, <Vector_n> | + | time_Val_n, <Vector_n> |
} | } | ||
</pre> | </pre> | ||
− | <p>The <span class="code">freedom_degree</span> before the first point is the | + | <p>The <span class="code">freedom_degree</span> before the first point is the value for all points (0.0 by default)</p> |
=====extended x spline===== | =====extended x spline===== | ||
[[Image:LeForgeronSpline04.png]] | [[Image:LeForgeronSpline04.png]] | ||
+ | |||
[[Image:LeForgeronSpline05.png]] | [[Image:LeForgeronSpline05.png]] | ||
<p>Extended spline are always C², but allows sharp points (where both the first and second derivatives drop to zero). All the points are visited.</p> | <p>Extended spline are always C², but allows sharp points (where both the first and second derivatives drop to zero). All the points are visited.</p> | ||
Line 141: | Line 142: | ||
=====general x spline===== | =====general x spline===== | ||
[[Image:LeForgeronSpline06.png]] | [[Image:LeForgeronSpline06.png]] | ||
+ | |||
[[Image:LeForgeronSpline07.png]] | [[Image:LeForgeronSpline07.png]] | ||
+ | |||
[[Image:LeForgeronSpline08.png]] | [[Image:LeForgeronSpline08.png]] | ||
Latest revision as of 10:31, 26 June 2018
- Everything about HgPovray38 in User:Le_Forgeron/HgPovray38
- Code is available on branch hgpovray38 at https://github.com/LeForgeron/povray
Splines
Accessing splines data
Not only the value of a spline can be evaluated with the traditional SPLINE_IDENTIFIER ( FLOAT [, SPLINE_TYPE] )
, it is also possible to get back the actual pieces of information from a spline.
dimension_size( SPLINE_IDENTIFIER )
provides the number of entries in the spline.
For each entry, the spline can be accessed like an array, the first element is the float of the path list and the second element the associated vector.
SPLINE_IDENTIFIER[ INDEX ][0]
is a floatSPLINE_IDENTIFIER[ INDEX ][1]
is a vector- INDEX should evolve as an integer from 0 to
dimension_size(SPLINE_IDENTIFIER)-1
Additional types of splines
Sor spline
the curve followed by a sor
can be evaluted by a spline
of sor_spline
type with a bit of manipulation: the y value of the sor must be used as the float of the path, and the x value become one of the component of the vector. The component of the vector never get negative with a sor spline.
spline{
sor_spline
-1.000000,0.000000*x
0.000000,0.118143*x
0.540084,0.620253*x
0.827004,0.210970*x
0.962025,0.194093*x
1.000000,0.286920*x
1.033755,0.468354*x
}
sor{
7
<0.000000, -1.000000>
<0.118143, 0.000000>
<0.620253, 0.540084>
<0.210970, 0.827004>
<0.194093, 0.962025>
<0.286920, 1.000000>
<0.468354, 1.033755>
}
akima spline
That spline will go through all its points, smoothly.
spline { akima_spline time_Val_1, <Vector_1> [,] time_Val_2, <Vector_2> [,] ... time_Val_n, <Vector_n> }
tcb spline
Also know as Kochanek-Bartels spline, tcb stand for tension, continuity and bias.
The first and last point of such spline are not reached.
spline { tcb_spline [TCB_PARAMETERS] time_Val_1 [TCB_PARAMETERS], <Vector_1> [TCB_PARAMETERS][,] time_Val_2 [TCB_PARAMETERS], <Vector_2> [TCB_PARAMETERS][,] ... time_Val_n [TCB_PARAMETERS], <Vector_n> [TCB_PARAMETERS] } TCB_PARAMETERS: [tension FLOAT] [continuity FLOAT] [bias FLOAT]
The tension
, continuity
and bias
are fully optional. Depending on the place where they appear, they control the spline in different ways:
- Placed right after the tcb_spline keyword, they set the default values for all ends of the spline segments. This placement is ignored in case of copying spline without adding new controls because previous defaults were already propagated to each side of control points.
- Placed between the time_value and the corresponding vector, the tcb parameters determine the properties of the spline segment ending in the vector that follows these parameters (as well as for the spline segment beginning at this vector if not overriden with the third position).
- For tcb parameters following a vector, the properties of the spline segment beginning after this vector are set.
What is controlled by these parameters?
tension
controls how sharply the curve bends.continuity
controls how rapid speed and direction change.bias
controls the direction of the curve as it passes through the control point.
x splines
X-Splines are an alternative to traditional splines that was introduced by Carole Blanc and Christophe Schlick in 1995.
XSplines have the very nice property that they can interpolate (go through) a control point as well as just approximate it. Sharp edges are also possible, but the curve is always C2 continuous, hence the sharp edges are only possible when the first derivative drops to zero.
An X-Spline is completely defined by a set of control point (vertices) and a set of parameters. One parameter is associated with each control point.
There is 3 variations of x splines:
- basic
- extended
- general
basic x spline
The first and last point of such spline are not reached.
spline { basic_x_spline [freedom_degree FLOAT] time_Val_1, <Vector_1> [,] time_Val_2, <Vector_2> [,] ... time_Val_n, <Vector_n> }
The freedom_degree before the first point is the value for all points (0.0 by default)
extended x spline
Extended spline are always C², but allows sharp points (where both the first and second derivatives drop to zero). All the points are visited.
spline { extended_x_spline [freedom_degree FLOAT] time_Val_1, <Vector_1> [freedom_degree FLOAT] [,] time_Val_2, <Vector_2> [freedom_degree FLOAT] [,] ... time_Val_n, <Vector_n> [freedom_degree FLOAT] }
The freedom_degree before the first point is the default value (0.0 by default)
general x spline
All points are visited.
spline { general_x_spline [freedom_degree FLOAT] time_Val_1, <Vector_1> [freedom_degree FLOAT] [,] time_Val_2, <Vector_2> [freedom_degree FLOAT] [,] ... time_Val_n, <Vector_n> [freedom_degree FLOAT] }
The freedom_degree before the first point is the default value (0.0 by default)