Mini 10: More Random Distribution
author |
Steve Losh <steve@stevelosh.com> |
date |
Fri, 06 May 2016 18:40:23 +0000 |
parents |
7a40282385de |
children |
29b2d3f28208 |
(in-package #:coding-math.points)
(defun quadratic-bezier (from to control n)
(vec-lerp (vec-lerp from control n)
(vec-lerp control to n)
n))
(defun fast-quadratic-bezier (from to control n
&optional (destination (make-vec)))
(with-vecs ((fx fy) from
(tx ty) to
(cx cy) control)
(setf (vec-x destination)
(+ (* (square (- 1 n)) fx)
(* 2 (- 1 n) n cx)
(* n n tx))
(vec-y destination)
(+ (* (square (- 1 n)) fy)
(* 2 (- 1 n) n cy)
(* n n ty))))
(values))
(defun cubic-bezier (from to control-1 control-2 n)
(vec-lerp (vec-lerp (vec-lerp from control-1 n)
(vec-lerp control-1 control-2 n)
n)
(vec-lerp (vec-lerp control-1 control-2 n)
(vec-lerp control-2 to n)
n)
n))