|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object common:Generic common:TrapShape kcc5:KCC_StarOfDavidTrap
class
The Star of David trap.
For an example of what this trap looks like,
click here.
class KCC_StarOfDavidTrap( common.ulb:TrapShape ) { ; The Star of David trap. ; <p> ; For an example of what this trap looks like, ; <a href="../additional/kcc5/images/Star of David Trap.jpg">click here</a>. ; public: import "common.ulb" ; constructor func KCC_StarOfDavidTrap( Generic pparent ) TrapShape.TrapShape( pparent ) endfunc ; call this before each sequence of values to be trapped func Init( complex pz ) TrapShape.Init( pz ) rangeNum = 0 halfside = 1.73205080756888 * @starSize endfunc ; call this for each iteration being trapped float func Iterate( complex pz ) TrapShape.Iterate( pz ) trapped = false ;Compute all the distances rz = real( pz ) iz = imag( pz ) d2 = abs( iz + @starSize ) d4 = abs( iz - @starSize ) d1 = abs( 0.866025403784439 * rz + 0.5 * iz - @starSize ) d3 = abs( -0.866025403784439 * rz + 0.5 * iz - @starSize ) d5 = abs( 0.866025403784439 * rz - 0.5 * iz - @starSize ) d6 = abs( -0.866025403784439 * rz - 0.5 * iz - @starSize ) ;Check line 1 if( d1 < @starWidth ) rangeNum = 0 if( d2 < @starWidth ) trapped = true if( d1 <= d2 ) dist = d1 if( iz <= -@starSize ) dist = d2 endif else dist = d2 if( rz >= halfside ) dist = d1 endif endif m_LastChannel = m_Iterations + rangeNum m_Texture = dist / @starWidth return dist elseif( d3 < @starWidth ) trapped = true if( d1 <= d3 ) dist = d1 if( rz <= 0.0 ) dist = d3 endif else dist = d3 if( rz > 0.0 ) dist = d1 endif endif m_LastChannel = m_Iterations + rangeNum m_Texture = dist / @starWidth return dist elseif( d4 < @starWidth ) trapped = true if( d1 <= d4 ) dist = d1 else dist = d4 rangeNum = 1 endif m_LastChannel = m_Iterations + rangeNum m_Texture = dist / @starWidth return dist elseif( d5 < @starWidth ) trapped = true if( d1 <= d5 ) dist = d1 else dist = d5 rangeNum = 1 endif m_LastChannel = m_Iterations + rangeNum m_Texture = dist / @starWidth return dist elseif( rz >= 0.0 && iz >= -@starSize ) trapped = true dist = d1 m_LastChannel = m_Iterations + rangeNum m_Texture = dist / @starWidth return dist endif endif ;Check line 2 if( d2 < @starWidth && !trapped ) rangeNum = 0 if( d3 < @starWidth ) trapped = true if( d2 <= d3 ) dist = d2 if( rz <= -halfside ) dist = d3 endif else dist = d3 if( iz <= -@starSize ) dist = d2 endif endif m_LastChannel = m_Iterations + rangeNum m_Texture = dist / @starWidth return dist elseif( d5 < @starWidth ) trapped = true if( d2 <= d5 ) dist = d2 else dist = d5 rangeNum = 1 endif m_LastChannel = m_Iterations + rangeNum m_Texture = dist / @starWidth return dist elseif( d6 < @starWidth ) trapped = true if( d2 <= d6 ) dist = d2 else dist = d6 rangeNum = 1 endif m_LastChannel = m_Iterations + rangeNum m_Texture = dist / @starWidth return dist elseif( abs(rz) <= halfside ) trapped = true dist = d2 m_LastChannel = m_Iterations + rangeNum m_Texture = dist / @starWidth return dist endif endif ;Check line 3 if( d3 < @starWidth && !trapped ) rangeNum = 0 if( d4 < @starWidth ) trapped = true if( d3 <= d4 ) dist = d3 else dist = d4 rangeNum = 1 endif m_LastChannel = m_Iterations + rangeNum m_Texture = dist / @starWidth return dist elseif( d6 < @starWidth ) trapped = true if( d3 <= d6 ) dist = d3 else dist = d6 rangeNum = 1 endif m_LastChannel = m_Iterations + rangeNum m_Texture = dist / @starWidth return dist elseif( rz <= 0.0 && iz >= -@starSize ) trapped = true dist = d3 m_LastChannel = m_Iterations + rangeNum m_Texture = dist / @starWidth return dist endif endif ;Check line 4 if( d4 < @starWidth && !trapped ) rangeNum = 1 if( d5 < @starWidth ) trapped = true if( d4 <= d5 ) dist = d4 if( rz >= halfside ) dist = d5 endif else dist = d5 if( iz >= @starSize ) dist = d4 endif endif m_LastChannel = m_Iterations + rangeNum m_Texture = dist / @starWidth return dist elseif( d6 < @starWidth ) trapped = true if( d4 <= d6 ) dist = d4 if( rz <= -halfside ) dist = d6 endif else dist = d6 if( iz >= @starSize ) dist = d4 endif endif m_LastChannel = m_Iterations + rangeNum m_Texture = dist / @starWidth return dist elseif( abs(rz) <= halfside ) trapped = true dist = d4 m_LastChannel = m_Iterations + rangeNum m_Texture = dist / @starWidth return dist endif endif ;Check line 5 if( d5 < @starWidth && !trapped ) rangeNum = 1 if( d6 < @starWidth ) trapped = true if( d5 <= d6 ) dist = d5 if( rz <= 0.0 ) dist = d6 endif else dist = d6 if( rz > 0.0 ) dist = d5 endif endif m_LastChannel = m_Iterations + rangeNum m_Texture = dist / @starWidth return dist elseif( rz >= 0.0 && iz <= @starSize ) trapped = true dist = d5 m_LastChannel = m_Iterations + rangeNum m_Texture = dist / @starWidth return dist endif endif ;Check line 6 if( d6 < @starWidth ) rangeNum = 1 if( rz <= 0.0 && iz <= @starSize ) trapped = true dist = d6 m_LastChannel = m_Iterations + rangeNum m_Texture = dist / @starWidth return dist endif endif return 1e20 endfunc float func GetTextureValue() return m_Texture endfunc protected: bool trapped int rangeNum float halfside float rz float iz float dist float d1 float d2 float d3 float d4 float d5 float d6 float m_Texture default: title = "Star of David Trap" int param v_KCC_StarOfDavidTrap caption = "Version (KCC_StarOfDavidTrap)" default = 100 hint = "This version parameter is used to detect when a change has been \ made to the formula that is incompatible with the previous version. \ When that happens, this field will reflect the old version number to \ alert you to the fact that an alternate rendering is being used." visible = @v_KCC_StarOfDavidTrap < 100 endparam float param starSize caption = "Star Size" default = 0.1 hint = "The Size of the star. Suggested range (0.05 to 1.0)." endparam float param starWidth caption = "Star Width" default = 0.1 hint = "The width of the star. Suggested range (0.01 to 0.5)." endparam }
Constructor Summary | |
---|---|
KCC_StarOfDavidTrap()
|
|
KCC_StarOfDavidTrap(Generic pparent)
constructor |
Method Summary | |
---|---|
float |
GetTextureValue()
Get texture value. |
void |
Init(complex pz)
call this before each sequence of values to be trapped |
float |
Iterate(complex pz)
call this for each iteration being trapped |
Methods inherited from class common:TrapShape |
---|
GetColorChannel, GetTransformedPoint, IterateSilent, SetThreshold |
Methods inherited from class common:Generic |
---|
GetParent |
Methods inherited from class Object |
---|
|
Constructor Detail |
---|
public KCC_StarOfDavidTrap(Generic pparent)
public KCC_StarOfDavidTrap()
Method Detail |
---|
public void Init(complex pz)
Init
in class TrapShape
public float Iterate(complex pz)
Iterate
in class TrapShape
public float GetTextureValue()
TrapShape
Ordinarily, a trap shape does not have a native texture (it is flat). Some formulas may pair trap shapes with trap textures, and may need more information about trap textures when trap shapes are nested via TrapShapeMerge. This function provides support for accessing texture information.
GetTextureValue
in class TrapShape
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |