|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Objectcommon:Generic
common:TrapShape
mmf:MMF_TrapShapeZold
mmf:MMF_TrapShapeInterpolation
class
Based on the interpolation methods in mmf3.ucl Orbitals+.
class MMF_TrapShapeInterpolation(MMF_TrapShapeZold) {
;
; Based on the interpolation methods in mmf3.ucl Orbitals+.<br>
;
public:
import "common.ulb"
func MMF_TrapShapeInterpolation(Generic pparent)
MMF_TrapShapeZold.MMF_TrapShapeZold(pparent)
endfunc
func Init(complex pz)
; m_Iterations = 0 not used in this trapshape
m_LastZ = m_zold = m_zolder = pz
m_zoldok = m_zolderok = m_gotold = false
endfunc
; The recip(0) ensures that "no result" due to no zold or zolder
; returns a value outside the threshold<br>
float func Iterate(complex pz)
complex zt = (0,0)
complex a = (0,0)
complex b = (0,0)
float r = recip(0.0)
float t = 0.0
bool gotz = false
; m_Iterations = m_Iterations + 1 not used in this trapshape
m_LastZ = pz
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
if @trap=="Magnitude"
r = cabs(a)
elseif @trap=="Real"
r = abs(real(a))
elseif @trap=="Imaginary"
r = abs(imag(a))
elseif @trap=="Angle"
r = atan2(a)
if @angle=="Absolute"
r = 2.0*abs(r)
elseif @angle=="All Angles 1"
if r<0.0
r = 2.0*#pi + r
endif
elseif @angle=="All Angles 2"
r = abs(#pi + r)
endif
if @usesin
r = abs(1.0 + sin(r))
else
r = r/(2.0*#pi)
endif
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
if @trap=="Magnitude"
t = cabs(b)
elseif @trap=="Real"
t = abs(real(b))
elseif @trap=="Imaginary"
t = abs(imag(b))
elseif @trap=="Angle"
t = atan2(b)
if @angle=="Absolute"
t = 2.0*abs(t)
elseif @angle=="All Angles 1"
if t<0.0
t = 2.0*#pi + t
endif
elseif @angle=="All Angles 2"
t = abs(#pi + t)
endif
if @usesin
t = abs(1.0 + sin(t))
else
t = t/(2.0*#pi)
endif
endif
if @usevar=="Just b"
r = t
elseif @mix=="Minimum" && t<r
r = t
elseif @mix=="Maximum" && t>r
r = t
elseif @mix=="Mix %age"
r = (0.01*@percent)*r + (1.0 - 0.01*@percent)*t
endif
endif
endif
m_zolder = m_zold
m_zold = pz
m_zolderok = m_zoldok
m_zoldok = true
return r
endfunc
func IterateSilent()
m_zoldok = m_zolderok = m_gotold = false
; m_Iterations = m_Iterations + 1 not used in this trapshape
endfunc
func IterateSilentZold(complex pz)
m_zolder = m_zold
m_zold = pz
m_gotold = false
m_zolderok = m_zoldok
m_zoldok = true
; m_Iterations = m_Iterations + 1 not used in this trapshape
endfunc
private:
complex m_oa
complex m_ob
bool m_gotold
default:
title = "Interpolation Constants"
heading
text = "This method allows you to trap the interpolation \
constants a and/or b in a*z^n1 + b*z^n2. It is \
intended for use with 'MMF Smooth Orbit Traps (Gradient)' or \
similar smoothing formulas since smoothing is often required."
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
int param trap
caption = "Value to trap"
enum = "Magnitude" "Real" "Imaginary" "Angle"
default = 0
endparam
int param angle
caption = "Angle method"
enum = "Absolute" "All Angles 1" "All Angles 2"
default = 0
visible = @trap==3
endparam
bool param usesin
caption = "Take the sine of the angle"
default = false
visible = @trap==3
endparam
}
| Constructor Summary | |
|---|---|
MMF_TrapShapeInterpolation()
|
|
MMF_TrapShapeInterpolation(Generic pparent)
|
|
| Method Summary | |
|---|---|
void |
Init(complex pz)
call this before each sequence of values to be trapped |
float |
Iterate(complex pz)
The recip(0) ensures that "no result" due to no zold or zolder returns a value outside the threshold |
void |
IterateSilent()
Update internal counters without transforming a value Flag for "got old z values" set to false |
void |
IterateSilentZold(complex pz)
Update internal counters without transforming a value Keep updating old z values |
| Methods inherited from class common:TrapShape |
|---|
GetColorChannel, GetTextureValue, GetTransformedPoint, SetThreshold |
| Methods inherited from class common:Generic |
|---|
GetParent |
| Methods inherited from class Object |
|---|
|
| Constructor Detail |
|---|
public MMF_TrapShapeInterpolation(Generic pparent)
public MMF_TrapShapeInterpolation()
| Method Detail |
|---|
public void Init(complex pz)
MMF_TrapShapeZold
Init in class MMF_TrapShapeZoldpz - the initial z valuepublic float Iterate(complex pz)
Iterate in class MMF_TrapShapeZoldpz - the z value
public void IterateSilent()
MMF_TrapShapeZold
IterateSilent in class MMF_TrapShapeZoldpublic void IterateSilentZold(complex pz)
MMF_TrapShapeZold
IterateSilentZold in class MMF_TrapShapeZoldpz - the z value
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||