Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stack is exactly 8 doubles in length
- the ith element refers to the value i places beneath the top of the stack
- an array should be allocated for variables used during calculation
- the vth var refers to the var of index v
- alternatively, the vth var may be FTx, FPx, TC, etc. to use those values
- operation summary:
- (these manipulate the stack or the values on it)
- dup [i] - duplicate the top or ith element
- push x[, ...] - push immediate values onto the stack
- drop n - discard n values off the top of the stack
- set x, i - set the ith element of the stack to x
- load v[, i] - push the vth var or set the ith element to the vth var
- loadxy - push FTy then FTx
- loadxyz - push FTz then FTy then FTx
- pop v - pop the top value to the vth var
- store v, i - copy the ith element to the vth var
- swap [i, j] - swap the first element with the second or the ith with the jth
- (these binary operators pop the top two values; each has a two-argument i, j
- version which operates on the ith and jth elements without popping them, and
- versions named *xy, *xz, and *yz (e.g. addxy, addxz, addyz) which use
- FTx and FTy, FTx and FTz, and FTy and FTz, respectively, as their arguments)
- add - add the top two values and push the result
- sub - push the result of subtraction of the second element from the first
- rsub - push the result of subtraction of the first element from the second
- mul - multiply the top two values and push the result
- div - push the result of division of the first element by the second
- rdiv - push the result of division of the second element by the first
- mod - push the remainder of division of the first element by the second
- rmod - push the remainder of division of the second element by the first
- polar - push atan2(y, x) and hypot(y, x) where y is the second element and
- x is the first. the radius is the new first element.
- rect - push x * sin(y) and x * cos(y) where y is the second element and x is
- the first. the horizontal component is the new first element.
- note: polar and rect with nothing between them effectively become a nop
- pow - push the result of exponentiation of the second element by the first
- rpow - push the result of exponentiation of the first element by the second
- atan2 - atan2(y, x), where x is the first element and y the second
- note: the xy, xz, and yz versions of this are reversed; atan2xy is
- equivalent to atan2(FTy, FTx)
- (these are similar to the binary operators above but with three arguments;
- i, j, k versions use the ith, jth, and kth elements, and *xyz versions use
- FTx, FTy, and FTz)
- spherical - push acos(z / sqrt(x*x + y*y + z*z)), atan2(y, x), and
- sqrt(x*x + y*y + z*z), where z is the third element, y is the second,
- and x is the first. the new first element is the radius and the second
- the angle from the arctangent.
- rect3d - push x * cos(z), x * sin(y) * sin(z), and x * cos(y) * sin(z). the
- new first element is the component along the x axis and the second the
- component along the y axis.
- fma - push x * y + z
- (these unaries follow conventions similar to those of the binaries and
- ternaries, with i, *x, *y, *z versions)
- neg - change sign
- acos - arccosine
- asin - arcsine
- atan - arctangent
- cos - cosine
- cosh - hyperbolic cosine
- sin - sine
- sinh - hyperbolic sine
- tan - tangent
- tanh - hyperbolic tangent
- exp - exponential (e to the power of the first element)
- ln - natural logarithm
- sqrt - square root
- ceil - ceiling
- abs - absolute value
- floor - floor
- (these unaries use common variables)
- mulv - multiply (in place) the top of the stack by VVAR
- addto* - pop stack and add to FP* (e.g. addtox -> FPx += top)
- subfrom* - pop stack and subtract from FP* (e.g. subfromx -> FPx -= top)
- vaddto* - same as mulv followed by addto*
- vsubfrom* - same as mulv followed by subfrom*
- (control flow; branches pop the top two elements by default, but have *k
- versions (e.g. beqk) which do not pop. their arguments are a signed int8_t.)
- beq n - branch forward n bytes if the top two elements are equal
- bne n - branch forward n bytes if the top two elements are not equal
- bgt n - greater than
- ble n - not greater than
- bge n - greater than or equal
- blt n - neither greater than nor equal
- end - exit the function (in xi rho, the point is plotted)
- quit - exit the function (in xi rho, the point is not plotted)
- (randomness)
- randint [a, b] - random integer in [0, DBL_MAX] or [a, b] (a and b are
- element numbers)
- random [a, b] - random real in [0, 1) or [a, b)
- plugins can be text files so that implementations can interpret them as they
- will. dot directives. madness.
- .name spherivoid // variation name is spherivoid
- .3d // 3d variation
- .vars real spherivoid_radius = 0 // like VAR_REAL(spherivoid_radius, 0.0)
- sphericalxyz // convert (FTx, FTy, FTz) to spherical coordinates
- load spherivoid_radius
- add // add spherivoid_radius to the radius coordinate
- rect3d // convert back to rectangular coordinates
- vaddtox
- vaddtoy
- vaddtoz
- end
- .name julian
- .vars int julian_power = 2, real julian_dist = 1
- .privs int absn, real cn
- .prep // prepare method
- load julian_power
- dup
- abs
- store absn, 0
- load julian_dist, 0
- div
- push 0.5
- mul
- store cn, 0 // end following this line is implicit
- .calc // calculate method
- atan2xy // atan2(y, x)
- load absn
- push 0
- randint 0, 1 // random integer between 0 and absn
- swap 2, 0; drop 2 // remove absn and 0 from the stack
- push 6.283185308 // 2pi
- fma // 2pi * randint + theta
- load julian_power
- rdiv // (2pi * randint + theta) / power
- load ftx
- dup
- mul // sqr(ftx)
- load fty
- dup
- fma // sqr(ftx) + sqr(fty)
- load cn
- pow // pow(sqr(ftx) + sqr(fty), cn)
- load vvar
- mul // vvar * pow(sqr(ftx) + sqr(fty), cn)
- rect // convert to rectangular coordinates
- addtox
- addtoy
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement