## Standard Class Standard_Slope

```Object
common:Generic
common:Formula
Standard:Standard_Slope
```

`class Formula:Standard_Slope`

Object version of the Slope formulas in Standard.ufm which allows any fractal formula to be used. Creates 3D lighting effects when combined with the Lighting coloring algorithm. The calculations are modified so that z contains a surface normal to the set instead of the orbit value. This is intended primarily for the Lighting coloring method, but might have interesting results for other methods, too. Originally written by Damien M. Jones.

Ultra Fractal Source
``` class Standard_Slope(common.ulb:Formula) {
;
; Object version of the Slope formulas in Standard.ufm which allows any fractal
; formula to be used. Creates 3D lighting effects when combined with the
; Lighting coloring algorithm. The calculations are modified so that z contains
; a surface normal to the set instead of the orbit value.  This is intended
; primarily for the Lighting coloring method, but might have interesting
; results for other methods, too.
;
; Originally written by Damien M. Jones.
;
public:
func Standard_Slope(Generic pparent)
Formula(pparent)
fHelper[0] = new @helperClass(this)
fHelper[1] = new @helperClass(this)
fHelper[2] = new @helperClass(this)
endfunc

complex func Init(complex pz)
complex z1 = fHelper[0].Init(pz) ; primary iterated point
fHelper[1].Init(pz + @offset) ; horizontally offset point
fHelper[2].Init(pz + flip(@offset)) ; vertically offset point
fIteration = 0
return z1
endfunc

complex func Iterate(complex pz)
; We can't use the pz value because we need to keep track of three z values.
fIteration = fIteration + 1
complex z1 = fHelper[0].Iterate()
fHelper[1].Iterate()
fHelper[2].Iterate()
m_BailedOut = fHelper[0].IsBailedOut()
if @everyiter || m_BailedOut || fIteration == #maxiter
; done, or every iteration, or last
float e1 = fHelper[0].CalcHeight(fIteration)
float e2 = fHelper[1].CalcHeight(fIteration)
float e3 = fHelper[2].CalcHeight(fIteration)

; determine surface normal
; that is, the normal to the surface defined by:
; (real(c1), imag(c1), e1)
; (real(c2), imag(c2), e2)
; (real(c3), imag(c3), e3)
float vx = e2-e1
float vy = e3-e1
float vz = -@offset
; normalize vector
float vd = 1/sqrt(sqr(vx)+sqr(vy)+sqr(vz))
vx = vx*vd
vy = vy*vd
vz = vz*vd
return vx + flip(vy); fudge z from vector
else ; didn't compute z this time
; use primary iteration value to keep periodicity working
return z1
endif
endfunc

private:
Standard_SlopeHelper fHelper[3]
int fIteration

default:
title = "Slope"
helpfile = "Uf*.chm"
helptopic = "Html/formulas/standard/slope.html"
heading
text = "Tip: Use with the Lighting coloring algorithm."
endheading
Standard_SlopeHelper param helperClass
selectable = false
endparam
float param offset
caption = "Orbit Separation"
default = 0.00000001
exponential = true
hint = "Defines how far apart the simultaneous orbits are.  Smaller \
distances will produce more accurate results."
endparam
bool param everyiter
caption = "Every Iteration"
default = false
hint = "If set, the surface normal will be computed at every \
iteration.  If you are using a coloring algorithm which \
processes every iteration, you will need this."
endparam
complex param p_power ; Hide p_power from Formula
visible = false
endparam
}
```

Constructor Summary
`Standard_Slope()`

`Standard_Slope(Generic pparent)`

Method Summary
` complex` `Init(complex pz)`
Set up for a sequence of values
` complex` `Iterate(complex pz)`
Produce the next value in the sequence

Methods inherited from class common:Formula
`GetLowerBailout, GetPrimaryExponent, GetUpperBailout, IsBailedOut`

Methods inherited from class common:Generic
`GetParent`

Methods inherited from class Object

Constructor Detail

### Standard_Slope

`public Standard_Slope(Generic pparent)`

### Standard_Slope

`public Standard_Slope()`
Method Detail

### Init

`public complex Init(complex pz)`
Description copied from class: `Formula`
Set up for a sequence of values

This function will be called at the beginning of each sequence of values (e.g. at the beginning of each fractal orbit).

Overrides:
`Init` in class `Formula`
Parameters:
`pz` - seed value for the sequence; for a normal fractal formula, this will be #pixel
Returns:
first value in the sequence; this corresponds to #z in a fractal formula

### Iterate

`public complex Iterate(complex pz)`
Description copied from class: `Formula`
Produce the next value in the sequence

As long as the sequence has not bailed out, this function will be continually called to produce sequence values.

Overrides:
`Iterate` in class `Formula`
Parameters:
`pz` - previous value in the sequence; corresponds to #z in a fractal formula. Note that you should always use this value for computing the next iteration, rather than a saved value, as the calling code may modify the returned value before passing it back to the next Iterate() call.
Returns:
the next value in the sequence