| 1 |
h1. S-Power-Basis-Forms |
| 2 |
|
| 3 |
2Geom provides a very powerful algebra for modifying paths. Although |
| 4 |
paths are kept in an extended SVG native form where possible, many |
| 5 |
operations require a more mathematical form. Our prefferred form is |
| 6 |
a sequence of s-power basis polynomials, henceforth referred to as |
| 7 |
s-basis. We may convert to this form, perform the required operations |
| 8 |
and convert back, approximating to a requested tolerance as required. |
| 9 |
|
| 10 |
The precise details of the s-basis form are beyond the scope of this |
| 11 |
manual - the interested reader should consult \cite{SanchezReyes1997,SanchezReyes2000,SanchezReyes2001,SanchezReyes2003,SanchezReyes2004}. |
| 12 |
An elementary, functional description is given in Appendix C. |
| 13 |
|
| 14 |
(TODO: work out textile citations, math inclusion) |
| 15 |
|
| 16 |
Geometrically important properties: |
| 17 |
* exact representation of bezier segments |
| 18 |
* low condition number on bezier conversion. |
| 19 |
* strong convergence guarantees |
| 20 |
* $C^0$ continuity guarantee |
| 21 |
|
| 22 |
The following operations are directly implementable and are very efficient: |
| 23 |
* fast conversion from all svg elements |
| 24 |
* basic arithmetic - @+@, @-@, $\times$, $\div$ |
| 25 |
* algebraic derivative and integral |
| 26 |
* elementary trigonometric functions: $\sqrt{\cdot}$, $\sin(\cdot)$, $\cos(\cdot)$, $\exp(\cdot)$ |
| 27 |
* efficient degree elevation and reduction |
| 28 |
* function inversion |
| 29 |
* exact solutions for many non trivial operations |
| 30 |
* root finding |
| 31 |
* composition |
| 32 |
|
| 33 |
All of these operations are fast. For example, multiplication of two |
| 34 |
beziers by converting to s-basis form, multiplying and converting back |
| 35 |
takes roughly the same time as performing the bezier multiplication |
| 36 |
directly, and furthermore, subdivision and degree reduction are |
| 37 |
straightforward in this form. |
| 38 |
|
| 39 |
h2. Implementation |
| 40 |
|
| 41 |
h3. *Linear* |
| 42 |
|
| 43 |
The *Linear* class represents a linear function, mostly for use as a |
| 44 |
building block for *SBasis*. *Linear* fully implements *AddableConcept*, |
| 45 |
*OffsetableConcept*, and *ScalableConcept* yielding the following operators: |
| 46 |
|
| 47 |
<pre><code> |
| 48 |
AddableConcept: x + y, x - y, x += y, x -= y |
| 49 |
OffsetableConcept: x + d, x - d, x += d, x -= d |
| 50 |
ScalableConcept: x * d, x / d, x *= d, x /= d, -x |
| 51 |
</code></pre> |
| 52 |
|
| 53 |
(where @x@ and @y@ are *Linear*, d is *Coord*, and all return *Linear*) |
| 54 |
|
| 55 |
As *Linear* is a basic function type, it also implements the *FragmentConcept*. |
| 56 |
|
| 57 |
The main *Linear* constructor accepts two *Coord* values, one for the Linear's |
| 58 |
value at 0, and one for its value at 1. These may then later be accessed and |
| 59 |
modified with the indexing operator, @[]@, with a value of 0 or 1. |
| 60 |
|
| 61 |
h3. *SBasis* |
| 62 |
|
| 63 |
The *SBasis* class provides the most basic function form, |
| 64 |
$f(t) \rightarrow y$. *SBasis* are made up of multiple *Linear* elements, |
| 65 |
which store to/from values for each polynomial coefficient. |
| 66 |
|
| 67 |
*SBasis*, like *Linear*, above, fully implements *AddableConcept*, |
| 68 |
*OffsetableConcept*, and *ScalableConcept*. |
| 69 |
|
| 70 |
As *SBasis* is a basic function type, it implements the *FragmentConcept*. |
| 71 |
|
| 72 |
Usually you do not have to directly construct SBasis, as they are obtained |
| 73 |
one way or another, and many of the operations are defined, however, *SBasis* |
| 74 |
may be constructed as an implicit *Linear* cast, as a copy, or as a blank. |
| 75 |
The class is actually an extension of @std::vector<Linear>@. This provides |
| 76 |
the primary method of raw *SBasis* construction -- @push_back(Linear)@, which |
| 77 |
adds another coefficient to the *SBasis*. |
| 78 |
|
| 79 |
*SBasis* also provides the indexing accessor/mutator, and due to its vector |
| 80 |
nature, iteration. |
| 81 |
|
| 82 |
(TODO: wouldn't the indexing be provided by vector any way?) |
| 83 |
|
| 84 |
h3. *SBasis2D* |
| 85 |
|
| 86 |
SBasis2D provides a multivariate form - functions of the form |
| 87 |
$f(u,v) \rightarrow z$. These can be used for arbitrary distortion |
| 88 |
functions (take a path $p(t) \rightarrow (u,v)$ and a pair of surfaces |
| 89 |
$f(u,v),g(u,v)$ and compose: $q(t) = (f(p(t)), g(p(t)))$. |
| 90 |
|
| 91 |
(TODO: flesh out this section) |