You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
422 B
19 lines
422 B
;;;; utils.lisp
|
|
(in-package :break)
|
|
|
|
(defun in-range (num vec)
|
|
(and (not (< num (aref vec 0)))
|
|
(not (> num (aref vec 1)))))
|
|
|
|
(defun clamp-v2 (min max vec)
|
|
(v! (clamp (aref min 0) (aref max 0) (aref vec 0))
|
|
(clamp (aref min 1) (aref max 1) (aref vec 1))))
|
|
|
|
(defun magnitude (vec)
|
|
(sqrt (apply #'+ (map 'list
|
|
(lambda (s) (expt s 2))
|
|
vec))))
|
|
|
|
(defun normalize-v3 (vec)
|
|
(v3:/S vec (magnitude vec)))
|