|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Objectcommon:Generic
common:Coloring
common:GradientColoring
mmf:DistanceEstimatorBase
mmf:MMF_NewtonDistanceEstimator
class
Distance Estimator for Newton formulas solving z^p-c.
class MMF_NewtonDistanceEstimator(DistanceEstimatorBase) {
; Distance Estimator for Newton formulas solving z^p-c.
public:
import "common.ulb"
; @param pparent the parent, generally "this" for the parent, or zero
func MMF_NewtonDistanceEstimator(Generic pparent)
DistanceEstimatorBase.DistanceEstimatorBase(pparent)
endfunc
; @param pz
; @param ppixel
func Init(complex pz, complex ppixel)
DistanceEstimatorBase.Init(pz, ppixel)
zold = pz
odz = 1.0
dz = (@power - 1.0)/@power - @root*(@power - 1.0)*pz^(@power - 2.0) \
/(@power*pz^(2.0*(@power - 1.0)))
endfunc
; @param pz
func Iterate(complex pz)
; m_Iterations = m_Iterations + 1
zold = pz
odz = dz
dz = dz *((@power - 1.0)/@power - @root*(@power - 1.0)*pz^(@power - 2.0) \
/(@power*pz^(2.0*(@power - 1.0))))
endfunc
; @param pz
; @return the gradient index
float func ResultIndex(complex pz)
float a = 0.0
float d = 0.0
complex zv = pz - zold
complex dzv = 1.0/(dz - odz)
if @mode=="Angle" || @mode=="Combined"
if (a = atan2(zv*dzv)*(0.5/#pi))<0.0
a = a + 1.0
endif
if @mode=="Angle"
return a
endif
endif
if @mode=="Distance" || @mode=="Combined"
d = 0.5*cabs((@power - 1.0)*zv)
d = -d*log(d)*cabs(dzv)
if @mode=="Distance"
return d
endif
endif
return a+d
endfunc
; @param pz
; @return the distance
float func ResultDistance(complex pz)
float v = 0.5*cabs((@power - 1.0)*(pz - zold))
return -v*log(v)/cabs(dz-odz)
endfunc
; @param pz
; @return the angle (from 0 to 1)
float func ResultAngle(complex pz)
float r
if (r=atan2((pz-zold)/(dz-odz))*(0.5/#pi))<0.0
r = r + 1.0
endif
return r
endfunc
protected:
complex zold
complex odz
default:
title = "MMF Newton Distance Estimator"
int param v_mmf_newtondistanceestimator
caption = "Version (MMF Newton Distance Estimator)"
enum = "1.0"
default = 0
hint = "This field is to absolutely ensure backward compatibility, \
the default will always be set to the latest version, but \
there may be some cases where an older effect that you like \
is lost in an update and you could still use it by selecting \
the older version number."
visible = false
endparam
int param mode
caption = "Mode"
enum = "Distance" "Angle" "Combined"
default = 0
endparam
complex param power
caption = "Power (p in z^p-r)"
default = (3,0)
endparam
complex param root
caption = "Root (r in z^p-r)"
default = (1,0)
endparam
}
| Constructor Summary | |
|---|---|
MMF_NewtonDistanceEstimator()
|
|
MMF_NewtonDistanceEstimator(Generic pparent)
|
|
| Method Summary | |
|---|---|
void |
Init(complex pz,
complex ppixel)
Set up for a sequence of values |
void |
Iterate(complex pz)
Process the next value in the sequence |
float |
ResultAngle(complex pz)
|
float |
ResultDistance(complex pz)
|
float |
ResultIndex(complex pz)
Produce a resulting color index after a sequence is finished |
| Methods inherited from class common:GradientColoring |
|---|
IsGradient, IsSolid, Result |
| Methods inherited from class common:Coloring |
|---|
GetPixel |
| Methods inherited from class common:Generic |
|---|
GetParent |
| Methods inherited from class Object |
|---|
|
| Constructor Detail |
|---|
public MMF_NewtonDistanceEstimator(Generic pparent)
pparent - the parent, generally "this" for the parent, or zeropublic MMF_NewtonDistanceEstimator()
| Method Detail |
|---|
public void Init(complex pz,
complex ppixel)
GradientColoringThis function will be called at the beginning of each sequence of values (e.g. at the beginning of each fractal orbit).
Init in class GradientColoringpz - ppixel - public void Iterate(complex pz)
GradientColoringAs long as the sequence has not bailed out, this function will be continually called to produce sequence values. Note that such processing generally will not know in advance precisely how long the sequence is, and should be prepared to deal with sequences of arbitrary length.
Your coloring may determine at some point that a solid color should be used rather than an index value.
Iterate in class GradientColoringpz - public float ResultIndex(complex pz)
GradientColoringThis corresponds to the final: section in a coloring formula. Once it is called, no further calls to Iterate() should be made without calling Init() first.
ResultIndex in class GradientColoringpz -
public float ResultDistance(complex pz)
ResultDistance in class DistanceEstimatorBasepz -
public float ResultAngle(complex pz)
ResultAngle in class DistanceEstimatorBasepz -
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||