HyperspaceExplorer 0.7.1
|
Base class for Taper classes, providing the actual taper() function. More...
#include <Taper.h>
Public Member Functions | |
taper_base (const VertexData< D > &v) | |
Create a taper_base object from an already existing object. | |
void | taper (unsigned d) |
Execute the taper action of the previous object along axis d . | |
Private Member Functions | |
bool | alreadyTapered () |
Private Attributes | |
int | _previous_dim |
Axis the previous taper() action went along. | |
int | _pre_previous_dim |
Axis the taper() action before the previous went along. |
Base class for Taper classes, providing the actual taper() function.
D | Dimension of the vector space we're working in |
bool taper_base< D >::alreadyTapered | ( | ) | [inline, private] |
References taper_base< D >::_previous_dim.
void taper_base< D >::taper | ( | unsigned | d | ) |
Execute the taper action of the previous object along axis d
.
Generally, a taper action is defined by the following formulas.
For going from a taper to the next, only the st and th coordinate are affected.
The new point is extruded above the center of the st coordinate, thus .
The th coordinate is found by spanning a right triangle with the sides and , and solving the pythagorean equation for the missing cathetus.
While these formulas are relatively easy, keep in mind that
d | The new dimension into which the object is tapered |
By Pythagoras! The coordinate tapered into is sqrt(1-1/2^2).
If this is the first time we taper an object, we must extrude a new point above the middle of the old object. For all directions except the newly tapered one, the coordinate value is the mean of the old ones.
We can skip the test for the dimension tapered into, because it's all zero by definition anyway.
Copy the last tapered point. It serves as reference, because only the coordinate last tapered into changes (it is halved), in addition to the newly extruded point.
If we have extruded only once before, we know the short cathetus of the right triangle spanned by the back of the equilateral triangle to be 0.5 - half a unit, because it lies in the center of the previous object.
Consequently, in this dimension the new point lies in the center of the previous edge.
If we have stored at least two previous extrusions, the cathetus of the new triangle is defined by those.
References std::vector< _Tp, _Alloc >::back(), VertexData< D >::dimension(), fabs(), std::vector< _Tp, _Alloc >::push_back(), VertexData< D >::raw_vertices(), VertexData< D >::realm(), std::vector< _Tp, _Alloc >::size(), size(), sqrt(), and Realm::tapered().