GeoGen Development snapshot a3
Public Member Functions

GGen_Data_1D Class Reference

List of all members.

Public Member Functions

 GGen_Data_1D (GGen_Size length, GGen_Height value)
void Abs ()
void Add (GGen_Height value)
void AddArray (GGen_Data_1D *addend)
void AddArrayMasked (GGen_Data_1D *addend, GGen_Data_1D *mask, bool relative)
void AddMasked (GGen_Height value, GGen_Data_1D *mask, bool relative)
void AddTo (GGen_Data_1D *addend, GGen_CoordOffset offset)
void Clamp (GGen_Height min, GGen_Height max)
GGen_Data_1DClone ()
void Fill (GGen_Height value)
void Flip ()
void Flood (double land_amount)
GGen_Size GetLength ()
GGen_Height GetValue (GGen_Coord x)
GGen_Height GetValueInterpolated (GGen_Coord x, GGen_Size scale_to_length)
void Gradient (GGen_Coord from, GGen_Coord to, GGen_Height from_value, GGen_Height to_value, bool fill_outside)
void Intersection (GGen_Data_1D *victim)
void Invert ()
GGen_Height Max ()
GGen_Height Min ()
void Monochrome (GGen_Height threshold)
void Multiply (double factor)
void MultiplyArray (GGen_Data_1D *factor)
void Noise (GGen_Size min_feature_size, GGen_Size max_feature_size, GGen_Amplitudes *amplitudes)
void Normalize (GGen_Normalization_Mode mode)
void ResizeCanvas (GGen_Size new_length, GGen_CoordOffset new_zero)
void Scale (double ratio, bool scale_values)
void ScaleTo (GGen_Size new_length, bool scale_values)
void ScaleValuesTo (GGen_Height new_min, GGen_Height new_max)
void SetValue (GGen_Coord x, GGen_Height value)
void SetValueInRange (GGen_Coord from, GGen_Coord to, GGen_Height value)
void Shift (GGen_CoordOffset offset, GGen_Overflow_Mode overflow_mode)
void SlopeMap ()
void Smooth (GGen_Distance radius)
GGen_PathToPath (uint16 point_count)
void Union (GGen_Data_1D *victim)

Detailed Description

GGen_Data_1D represents a simple 1D array of values. It can be used to create more complex 2D maps using methods like GGen_Data_2D::Project, GGen_Data_2D::Gradient or GGen_Data_2D::TransformValues.


Constructor & Destructor Documentation

GGen_Data_1D::GGen_Data_1D ( GGen_Size  length,
GGen_Height  value 
)

Creates new GGen_Data_1D object of given length.

Parameters:
lengthLength of the array.
valueDefault value for all cells.

Member Function Documentation

void GGen_Data_1D::Abs ( )

Replaces each value with its absolute value (removes all negative signs).

void GGen_Data_1D::Add ( GGen_Height  value)

Adds an integer to all values in the array.

Parameters:
valueValue to be added to values in the array.
void GGen_Data_1D::AddArray ( GGen_Data_1D addend)

Adds another array to the current array.

Parameters:
addendArray to be added. This array will be scaled to match the original array.
void GGen_Data_1D::AddArrayMasked ( GGen_Data_1D addend,
GGen_Data_1D mask,
bool  relative 
)

Adds another array to the current array. The percentage of each value from the addend will depend on corresponding value from the mask.

Parameters:
addendArray to be added. This array will be scaled to match the original array.
maskArray used to mask the added value.
relativeToggles relative mode.
Note:
0 in the mask always means the original value won't be changed. In relative mode, maximum value found in the mask then means 100%, otherwise 32767 means 100%.
void GGen_Data_1D::AddMasked ( GGen_Height  value,
GGen_Data_1D mask,
bool  relative 
)

Adds a percentage of an integer to all values in the array. The percentage added will depend on corresponding value from the mask.

Parameters:
valueValue to be added to values in the array.
maskArray used to mask the added value. This array will be scaled to match the current array.
relativeToggles relative mode.
Note:
0 in the mask always means the original value won't be changed. In relative mode, maximum value found in the mask then means 100%, otherwise 32767 means 100%.
void GGen_Data_1D::AddTo ( GGen_Data_1D addend,
GGen_CoordOffset  offset 
)

Adds another array to the current array. Its coordinates will be shifted by an offset.

Parameters:
addendArray to be added. This array will NOT be scaled to match the original array.
offsetCoordinates of the addend will be shifted by this value.
void GGen_Data_1D::Clamp ( GGen_Height  min,
GGen_Height  max 
)

Clamps all values to range.

Parameters:
minNew minimum value.
maxNew maximum value.
Note:
All values outside the given range will be set either to min or max, whichever is closer.
GGen_Data_1D * GGen_Data_1D::Clone ( )

Creates a 1:1 copy of the current object.

Returns:
Copy of the object.
void GGen_Data_1D::Fill ( GGen_Height  value)

Sets all values in the array.

Parameters:
valueThe fill value.
void GGen_Data_1D::Flip ( )

Flips order of values in the array, so the first value is the last.

void GGen_Data_1D::Flood ( double  land_amount)

Changes the values so given percentage of values is higher than 0.

Parameters:
land_amountThe percentage of values to be higher than 0. 0 means no "land", 1.0 means no "water".
GGen_Size GGen_Data_1D::GetLength ( )

Returns length of the array.

Returns:
Length of the array.
GGen_Height GGen_Data_1D::GetValue ( GGen_Coord  x)

Returns one value from the array.

Parameters:
xTile coordinate.
Returns:
Value in the tile.
GGen_Height GGen_Data_1D::GetValueInterpolated ( GGen_Coord  x,
GGen_Size  scale_to_length 
)

Return one value from the array interpolated to a different array length.

Parameters:
xTile coordinate (in the interpolated array).
scale_to_lengthInterpolated array length.
Returns:
Interpolated value in the tile.
Note:
If the interpolated size is larger than the original, interpolated values will be calculated using the linear interpolation algorithm. Otherwise, interpolated values will be chosen using the nearest neighbor algorithm.
void GGen_Data_1D::Gradient ( GGen_Coord  from,
GGen_Coord  to,
GGen_Height  from_value,
GGen_Height  to_value,
bool  fill_outside 
)

Creates a smooth gradient between two coords. The values will make transition between two values.

Parameters:
fromThe left bound coordinate.
toThe right bound coordinate.
from_valueThe left transition base.
to_valueThe right transition base.
fill_outsideShould the values outside gradient interval be filled as well?
Note:
If fill_flat is set to true, values with coord lower than left bound will be filled with from_value< and value with coord higher than the right bound will be filled with to_value.
void GGen_Data_1D::Intersection ( GGen_Data_1D victim)

Performs a set intersection of the array graphs (higher of two respective values is applied).

Parameters:
victimThe intersection array. This array will be scaled to match the original array.
void GGen_Data_1D::Invert ( )

Flips sign of all values in the array.

GGen_Height GGen_Data_1D::Max ( )

Returns the maximum of all values in the array.

Returns:
The maximum.
GGen_Height GGen_Data_1D::Min ( )

Returns the minimum of all values in the array.

Returns:
The minimum.
void GGen_Data_1D::Monochrome ( GGen_Height  threshold)

Replaces each value with 0 if it is less than equal than the threshold or 1 otherwise.

Parameters:
thresholdValues above threshold will be 1, otherwise 0.
void GGen_Data_1D::Multiply ( double  factor)

Multiplies each value in the array by a real number.

Parameters:
factorReal number to multiply all values in the array.
void GGen_Data_1D::MultiplyArray ( GGen_Data_1D factor)

Multiplies each value in the array by a corresponding value from factor.

Parameters:
factorArray to be multiplied by. This array will be scaled to match the original array.
void GGen_Data_1D::Noise ( GGen_Size  min_feature_size,
GGen_Size  max_feature_size,
GGen_Amplitudes amplitudes 
)

Fills the array with random perlin noise (http://freespace.virgin.net/hugo.elias/models/m_perlin.htm).

Parameters:
min_feature_sizeMinimum wave length for amplitude to be used.
max_feature_sizeMaximum wave length for amplitude to be used.
amplitudesGGen_Amplitudes object.
Note:
Resulting computational complexity increases with number of amplitudes used.
void GGen_Data_1D::Normalize ( GGen_Normalization_Mode  mode)

Makes sure that there are no slopes steeper than 45° in the array. Steeper slopes will be dealt with according to mode.

Parameters:
modeThe normalization mode (see GGen_Normalization_Mode).
void GGen_Data_1D::ResizeCanvas ( GGen_Size  new_length,
GGen_CoordOffset  new_zero 
)

Crops or expands the array without changing its values.

Parameters:
new_lengthNew array length.
new_zeroCoordinate of new origin relative to the original zero.
Note:
All values outside new length will be discarded. Newly created values will be set to 0.
void GGen_Data_1D::Scale ( double  ratio,
bool  scale_values 
)

Scales length of the array by a real number.

Parameters:
ratioScaling ratio (0.5 = 50%, 2.0 = 200%).
scale_valuesMultiply the values by the ratio as well?
Note:
If the new size is larger than the original, the new values will be calculated using the linear interpolation algorithm. Otherwise, the new values will be chosen using the nearest neighbor algorithm.
void GGen_Data_1D::ScaleTo ( GGen_Size  new_length,
bool  scale_values 
)

Scales length of the array to new length.

Parameters:
new_lengthTarget array length.
scale_valuesScale the valuess correspondingly as well?
Note:
If the new size is larger than the original, the new values will be calculated using the linear interpolation algorithm. Otherwise, the new values will be chosen using the nearest neighbor algorithm.
void GGen_Data_1D::ScaleValuesTo ( GGen_Height  new_min,
GGen_Height  new_max 
)

Scales values in the array to fit a new value range.

Parameters:
new_minNew minimum value.
new_maxNew maximum value.
void GGen_Data_1D::SetValue ( GGen_Coord  x,
GGen_Height  value 
)

Sets value in one tile.

Parameters:
xCoordinate to set.
valueValue to use.
void GGen_Data_1D::SetValueInRange ( GGen_Coord  from,
GGen_Coord  to,
GGen_Height  value 
)

Sets value in all tiles in range (bounds are included).

Parameters:
fromStarting point.
toEnding point.
valueValue to use.
void GGen_Data_1D::Shift ( GGen_CoordOffset  offset,
GGen_Overflow_Mode  overflow_mode 
)

Shifts all values by a distance.

Parameters:
offsetCoordinate of new origin relative to the original zero.
overflow_modeOverflow mode (see GGen_Overflow_Mode).
Note:
All values outside the array will be discarded. Newly created values will be set to 0.
void GGen_Data_1D::SlopeMap ( )

Replaces values in the array with information about steepness of slope (change in value) in that particular value.

void GGen_Data_1D::Smooth ( GGen_Distance  radius)

Smooths differences between values in the array. Uses linear smoothing algorithm.

Parameters:
radiusSmoothing kernel radius.
GGen_Path * GGen_Data_1D::ToPath ( uint16  point_count)

Creates a GGen_Path object from current object.

Parameters:
point_countNumber of points in the newly created path object.
Note:
Point's coordinates are calculated as [value index, value].
void GGen_Data_1D::Union ( GGen_Data_1D victim)

Performs a set union of the array graphs (higher of two respective values is applied).

Parameters:
victimThe union array. This array will be scaled to match the original array.

The documentation for this class was generated from the following files: