HyperspaceExplorer 0.7.1
|
A four-dimensional Menger Sponge. More...
#include <Sponge.h>
Public Member Functions | |
Sponge (unsigned _level=1, unsigned _distance=2, double _rad=0.8, VecMath::Vector< 4 > _center=VecMath::Vector< 4 >(0., 0., 0., 0.)) | |
Sponge constructor. | |
virtual | ~Sponge () |
Sponge destructor. | |
virtual std::string | getFunctionName () const |
virtual void | Transform (const VecMath::Rotation< 4 > &R, const VecMath::Vector< 4 > &T, const VecMath::Vector< 4 > &scale) |
Transforms a Sponge. | |
virtual void | Project (double ScrW, double CamW, bool DepthCue4D) |
Projects a Sponge into three-space. | |
virtual void | Draw (UI::View *view) |
Draw the projected Sponge (onto screen or into GL list, as it is) | |
virtual void | SetParameters (const ParameterMap &parms) |
Set parameters to the Displayable. | |
virtual void | ReInit (double, double, double, double, double, double, double, double, double) |
Rebuild the Sponge if the parameters have changed. | |
virtual std::string | description () |
Protected Member Functions | |
virtual void | Initialize () |
This function actually creates the hypersponge. | |
virtual unsigned long | MemRequired (unsigned) |
return the approximate amount of memory needed to display a sponge of current level and given distance | |
Protected Attributes | |
unsigned | Level |
Level of the hypersponge. | |
std::vector< Hypercube * > | List |
List of sub-sponges (see Initialize()) | |
int | distance |
max. distance (see Initialize()) | |
double | rad |
radius, more correctly size, of the sponge | |
VecMath::Vector< 4 > | center |
center of the sponge |
A four-dimensional Menger Sponge.
A Menger Sponge in three dimensions is a fractal produced by subdividing a cube and taking away parts of the cube which get subsequentally smaller. The level parameter controls how often this process is repeated, i.e. how many holes there are in the final object.
A four-dimensional Menger Sponge is created analogously from a hypercube.
The fractal can be further controlled by the distance parameter:
Sponge::Sponge | ( | unsigned | _level = 1 , |
unsigned | _distance = 2 , |
||
double | _rad = 0.8 , |
||
VecMath::Vector< 4 > | _center = VecMath::Vector<4>(0., 0.,0., 0.) |
||
) |
Sponge constructor.
Construct a Hypersponge of level level
.
_level | hypersponge level |
_distance | distance of subcubes to center to be counted as part of the fractal
|
_rad | side_length/2 |
_center | center |
_level | Level of recursion used in creating the Sponge |
_distance | see Initialize() |
_rad | Size of the Sponge - _rad is half the side length |
_center | Center point of the Sponge |
References Displayable::declareParameter(), and Initialize().
virtual std::string Sponge::description | ( | ) | [inline, virtual] |
Reimplemented from Hypercube.
References std::ends(), and Level.
void Sponge::Draw | ( | UI::View * | view | ) | [virtual] |
Draw the projected Sponge (onto screen or into GL list, as it is)
Draws all sub-sponges, recursively.
Reimplemented from Hypercube.
References UI::View::commitDraw(), Level, List, and std::vector< _Tp, _Alloc >::size().
virtual std::string Sponge::getFunctionName | ( | ) | const [inline, virtual] |
Reimplemented from Hypercube.
void Sponge::Initialize | ( | void | ) | [protected, virtual] |
This function actually creates the hypersponge.
It views it as an assembly of smaller sponges, slicing the sponge in three sub-sponges in every one of the four dimensions, and then taking away some of the resulting 81 smaller sub-sponges.
If the level of the sponge is 1, the sub-sponges are hypercubes. Otherwise, they are Hypersponges with a level reduced by 1.
Reimplemented from Hypercube.
References abs(), center, std::cerr, distance, std::endl(), Loki::SingletonHolder< T, CreationPolicy >::Instance(), Level, List, Displayable::MemRequired(), std::vector< _Tp, _Alloc >::push_back(), and rad.
Referenced by Sponge().
unsigned long Sponge::MemRequired | ( | unsigned | distance | ) | [protected, virtual] |
return the approximate amount of memory needed to display a sponge of current level
and given distance
distance | see Initialize() |
void Sponge::Project | ( | double | scr_w, |
double | cam_w, | ||
bool | depthcue4d | ||
) | [virtual] |
Projects a Sponge into three-space.
The projection is achieved by projecting all constituting sub-sponges.
scr_w | w coordinate of screen |
cam_w | w coordinate of camera |
depthcue4d | wheter to use hyperfog/dc |
Reimplemented from VertexHolder< 4, 1, double >.
References List, and std::vector< _Tp, _Alloc >::size().
virtual void Sponge::SetParameters | ( | const ParameterMap & | ) | [inline, virtual] |
Set parameters to the Displayable.
Reimplemented from Hypercube.
References std::map< _Key, _Tp, _Compare, _Alloc >::begin(), std::cerr, distance, std::map< _Key, _Tp, _Compare, _Alloc >::end(), Level, rad, Displayable::setParameter(), and ParameterMap::toString().
void Sponge::Transform | ( | const VecMath::Rotation< 4 > & | R, |
const VecMath::Vector< 4 > & | T, | ||
const VecMath::Vector< 4 > & | scale | ||
) | [virtual] |
Transforms a Sponge.
The transformation is achieved by transforming all constituting sub-sponges.
R | rotation |
T | translation |
References List, and std::vector< _Tp, _Alloc >::size().
std::vector<Hypercube *> Sponge::List [protected] |
List of sub-sponges (see Initialize())
Referenced by Draw(), Initialize(), Project(), ReInit(), Transform(), and ~Sponge().