Half hearted
Jump to navigation
Jump to search
Half hearted is a program that outputs the coordinates of a cubic bézier curve, specifically one with the control points (-1,0), (0,1), (1,2), (0,1).
You should be able to tell the program how many points the curve it should output (to prevent hard coding). The program must output the start and end, and i-2 other values that define the curve. It does not have to draw it, nor output a common format.
Implementations
MoreMathRPN
inputR "Input number of points >= 2" floor repeat ]0 "init variables 1 >>> 0 1 - >> 2 1 - / hold t - hold t' "point #1 (0,-1) >> 0 >> 0 * * 0 -1 m 1 2 * "point #2 (1,0) 3 place t place t' >> 0 * * * 1 0 m 1 2 * + "point #3 (1,2) 3 place t >> 0 place t' * * * 1 2 m 1 2 * + "point #4 (0,1) place t >> 0 >> 0 * * 0 1 m 1 2 * + "output outputV outputS ", " next