HyperspaceExplorer 0.7.1
Public Member Functions | Private Member Functions | Private Attributes
taper_base< D > Class Template Reference

Base class for Taper classes, providing the actual taper() function. More...

#include <Taper.h>

Inheritance diagram for taper_base< D >:
Inheritance graph
[legend]
Collaboration diagram for taper_base< D >:
Collaboration graph
[legend]

List of all members.

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.

Detailed Description

template<unsigned D>
class taper_base< D >

Base class for Taper classes, providing the actual taper() function.

Template Parameters:
DDimension of the vector space we're working in
Author:
Helge Preuss <lene.preuss@gmail.com>

Member Function Documentation

template<unsigned D>
bool taper_base< D >::alreadyTapered ( ) [inline, private]
Returns:
Whether working on an object that's already a Taper.

References taper_base< D >::_previous_dim.

template<unsigned D>
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 $ D-1 $ to the next, only the $ D-1 $ st and $ D $ th coordinate are affected.

The new point is extruded above the center of the $ D-1 $ st coordinate, thus $ X_{new,D-1} = \frac{X_{D-1} }{2} $ .

The $ D $ th coordinate is found by spanning a right triangle with the sides $ X_{new,D-1} $ and $ X_{D-2} $ , and solving the pythagorean equation for the missing cathetus.

While these formulas are relatively easy, keep in mind that

  1. You must store previous taper actions to remember $ D-1 $ and $ D-2 $ .
  2. If you haven't tapered at least twice before, you don't have values for $ D-1 $ and $ D-2 $. Thus, you must make up these values. Luckily, this is possible:
    1. If we taper for the first time, the new point lies above the center of the old surface. We calculate the mean of all $ D-1 $ coordinates and extrude above that point. The $ D $ coordinate is $ \sqrt{1 - \bar{x_i}^2} $. $ \bar{x_i} $ is considered to be equal to $ \frac{1}{2} $ in this function, because I don't see how it could have another value that makes sense.
    2. If we taper for the second time, we extrude above the center of the $ D-1 $ st coordinate, so the value for this is halved for the $ D-1 $ coordinate of the new point. The $ D $ coordinate is $ \sqrt{x_{D-1}^2 - \frac{1}{2^2} } $ , because the second leg of the equilateral triangle was created by the first extrusion and is known to be of length $ \frac{1}{2} $ .
Parameters:
dThe 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().

Here is the call graph for this function:


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends

Generated on Mon Apr 9 2012 20:25:18 for HyperspaceExplorer 0.7.1 by doxygen 1.7.4  -  Hosted bySourceForge.net Logo