|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Objectcommon:Generic
common:Transform
common:UserTransform
mmf:MMF_TrapTransformZold
mmf:MMF_TrapTransformInterpolation
class
Trapping based on interpolation of a*zold^p1 + b*zold^p2
class MMF_TrapTransformInterpolation(MMF_TrapTransformZold) {
; Trapping based on interpolation of a*zold^p1 + b*zold^p2<br>
public:
import "common.ulb"
; @param pparent the parent, generally "this" for the parent, or zero
func MMF_TrapTransformInterpolation(Generic pparent)
MMF_TrapTransformZold.MMF_TrapTransformZold(pparent)
endfunc
; Sets the m_gotold variable to false i.e. "no old trapped values"
; @param pz the initial z value
func Init(complex pz)
MMF_TrapTransformZold.Init(pz)
m_gotold = false
endfunc
; @param pz the z value
complex func Iterate(complex pz)
complex zt = (0,0)
complex a = (0,0)
complex b = (0,0)
bool gotz = false
; m_Iterations = m_Iterations + 1 not used in this transform
if (@usevar=="Predict1" || @usevar=="Predict2") \
&& m_gotold && m_zoldok
if @usevar=="Predict1"
zt = m_oa*m_zold^@pwr1 + m_ob*m_zold^@pwr2
else
zt = m_oa*m_zold^@pwr1 + @valb*m_zold^@pwr2
endif
gotz = true
endif
m_gotold = false
if @usevar=="Just a" || @usevar=="Just b" || @usevar=="Combined" \
|| @usevar=="Predict1"
if m_zolderok
if @pwr1!=(0,0)
if @pwr2!=(0,0)
a = m_zold^@pwr1*m_zolder^@pwr2 - m_zolder^@pwr1*m_zold^@pwr2
else
a = m_zold^@pwr1 - m_zolder^@pwr1
endif
elseif @pwr2!=(0,0)
a = m_zolder^@pwr2 - m_zold^@pwr2
endif
m_gotold = true
endif
elseif m_zoldok
if @pwr1!=(0,0)
a = m_zold^@pwr1
else
a = 1.0
endif
m_gotold = true
endif
if m_gotold
if @usevar=="Just a" || @usevar=="Just b" || @usevar=="Combined" \
|| @usevar=="Predict1"
a = 1.0/a
if @pwr1!=(0,0)
if @pwr2!=(0,0)
if @usevar!="Just a"
b = (m_zold^(@pwr1+1.0) - pz*m_zolder^@pwr1)*a
endif
if @usevar!="Just b"
a = (pz*m_zolder^@pwr2 - m_zold^(@pwr2+1.0))*a
endif
else
if @usevar!="Just a"
b = (m_zold^(@pwr1+1.0) - pz*m_zolder^@pwr1)*a
endif
if @usevar!="Just b"
a = (pz - m_zold)*a
endif
endif
elseif @pwr2!=(0,0)
if @usevar!="Just a"
b = (m_zold - pz)*a
endif
if @usevar!="Just b"
a = (pz*m_zolder^@pwr2 - m_zold^(@pwr2+1.0))*a
endif
endif
elseif @pwr2!=(0,0)
a = (pz - @valb*m_zold^@pwr2)/a
else
a = (pz - @valb)/a
endif
if @usevar=="Predict1" || @usevar=="Predict2"
m_oa = a
m_ob = b
endif
endif
if ((@usevar=="Just a" || @usevar=="Just b" || @usevar=="Combined" \
|| @usevar=="Fixed b") && m_gotold) || ((@usevar=="Predict1" \
|| @usevar=="Predict2") && gotz)
if @usevar=="Predict1" || @usevar=="Predict2"
a = zt
if @trapz
a = pz - zt
endif
endif
if @usevar!="Just b"
if @fna==1
a = log(a)
elseif @fna==2
a = sin(a)
elseif @fna==3
a = cos(a)
elseif @fna==4
a = tan(a)
elseif @fna==5
a = sinh(a)
elseif @fna==6
a = cosh(a)
elseif @fna==7
a = tanh(a)
elseif @fna==8
a = exp(a)
elseif @fna==9
a = sqrt(a)
elseif @fna==10
a = a^(1.0/3.0)
elseif @fna==11
a = a*a
elseif @fna==12
a = a^3.0
endif
endif
if @usevar=="Just b" || @usevar=="Combined"
if @fnb==1
b = log(b)
elseif @fnb==2
b = sin(b)
elseif @fnb==3
b = cos(b)
elseif @fnb==4
b = tan(b)
elseif @fnb==5
b = sinh(b)
elseif @fnb==6
b = cosh(b)
elseif @fnb==7
b = tanh(b)
elseif @fnb==8
b = exp(b)
elseif @fnb==9
b = sqrt(b)
elseif @fnb==10
b = b^(1.0/3.0)
elseif @fnb==11
b = b*b
elseif @fnb==12
b = b^3.0
endif
endif
if @usevar=="Just b"
zt = b
elseif @usevar=="Combined"
if @mix=="Minimum"
if |a|<=|b|
zt = a
else
zt = b
endif
elseif @mix=="Maximum"
if |a|>|b|
zt = a
else
zt = b
endif
else;if @mix=="Mix %age"
zt = (0.01*@percent)*a + (1.0 - 0.01*@percent)*b
endif
else
zt = a
endif
m_solid = false
else
zt = pz
m_solid = true
endif
m_zolder = m_zold
m_zold = pz
m_zolderok = m_zoldok
m_zoldok = true
return zt
endfunc
; Set the "old" flags to false
func IterateSilent()
; m_Iterations = m_Iterations + 1 not used in this transform<br>
m_zolderok = m_zoldok = m_gotold = false
endfunc
; Keep the "old" z values up to date, set the m_gotold flag to false
; @param pz the z value
func IterateSilentZold(complex pz)
; m_Iterations = m_Iterations + 1 not used in this transform<br>
m_zolder = m_zold
m_zold = pz
m_zolderok = m_zoldok
m_zoldok = true
m_gotold = false
endfunc
private:
complex m_oa
complex m_ob
bool m_gotold
default:
title = "Interpolation Transform"
heading
text = "The interpolation requires that the transform is used \
in an iterated manner, so in situations where the \
transform is applied in a 'one-shot' manner interpolation \
is not applicable."
endheading
complex param pwr1
caption = "Power 1"
default = (2,0)
hint = "n1 in 'a*z^n1 + b*z^n2'. Note that if it is (0,0) then the \
interpolation formula becomes 'a + b*z^n2'."
endparam
complex param pwr2
caption = "Power 2"
default = (1,0)
hint = "n2 in 'a*z^n1 + b*z^n2'. Note that if it is (0,0) then the \
interpolation formula becomes 'a*z^n1 + b'."
endparam
int param usevar
caption = "Variable/s to use"
enum = "Just a" "Just b" "Combined" "Fixed b" "Predict1" "Predict2"
default = 0
hint = " \
'Combined' calculates values using a and b separately and then \
allows you to set the final value by combining the two \
separate values. 'Fixed b' allows you to specify a fixed value \
for b in a*z^n1 + b*z^n2 and colours based on a. \
Predict1 calculates both a and b and uses the values from \
the previous iteration to interpolate z and traps the \
interpolated value. Predict2 is the same \
as Predict1 but uses the 'Fixed b' interpolation method."
endparam
bool param trapz
caption = "Trap z ?"
default = false
hint = "Normally just the interpolated value is used for \
'Predict1' and 'Predict2' but you can choose to trap \
the actual z value to the predicted z value instead."
visible = @usevar>3
endparam
complex param valb
caption = "Value of b"
default = (0,0)
visible = @usevar==3 || @usevar==5
endparam
int param mix
caption = "Colour mixing"
enum = "Minimum" "Maximum" "Mix %age"
default = 0
visible = @usevar==2
endparam
float param percent
caption = "Mix %age"
default = 50.0
hint = "100% uses the value from a only, 0% uses the value from b only."
visible = @usevar==2 && @mix==2
endparam
int param fna
caption = "Function for a (or interpolated z)"
enum = "Ident" "Log" "Sin" "Cos" "Tan" "Sinh" "Cosh" "Tanh" "Exp" \
"Sqrt" "Cubert" "Square" "Cube"
default = 0
hint = "Applied to the calculated value of a or the interpolated \
z value before use in any trapping or colouring."
visible = @usevar!=1
endparam
int param fnb
caption = "Function for b"
enum = "Ident" "Log" "Sin" "Cos" "Tan" "Sinh" "Cosh" "Tanh" "Exp" \
"Sqrt" "Cubert" "Square" "Cube"
default = 0
hint = "Applied to the calculated value of b before use in any \
trapping or colouring."
visible = @usevar>0 && @usevar<3
endparam
}
| Constructor Summary | |
|---|---|
MMF_TrapTransformInterpolation()
|
|
MMF_TrapTransformInterpolation(Generic pparent)
|
|
| Method Summary | |
|---|---|
void |
Init(complex pz)
Sets the m_gotold variable to false i.e. |
complex |
Iterate(complex pz)
Note that derived functions should update zold, zolder, zoldok and zolderok as necessary |
void |
IterateSilent()
Set the "old" flags to false |
void |
IterateSilentZold(complex pz)
Keep the "old" z values up to date, set the m_gotold flag to false |
| Methods inherited from class common:Transform |
|---|
IsSolid |
| Methods inherited from class common:Generic |
|---|
GetParent |
| Methods inherited from class Object |
|---|
|
| Constructor Detail |
|---|
public MMF_TrapTransformInterpolation(Generic pparent)
pparent - the parent, generally "this" for the parent, or zeropublic MMF_TrapTransformInterpolation()
| Method Detail |
|---|
public void Init(complex pz)
Init in class MMF_TrapTransformZoldpz - the initial z valuepublic complex Iterate(complex pz)
MMF_TrapTransformZoldNote that derived functions should update zold, zolder, zoldok
and zolderok as necessary
Iterate in class MMF_TrapTransformZoldpz - the z value
public void IterateSilent()
IterateSilent in class MMF_TrapTransformZoldpublic void IterateSilentZold(complex pz)
IterateSilentZold in class MMF_TrapTransformZoldpz - the z value
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||