Умножение радиус-вектора на скаляр
(defmethod mul2 ((n number) (c cart))
(make-instance 'cart
:x (* n (cart-x c))
:y (* n (cart-y c))))
(defun normalize-angle (a)
(let* ((2pi (* 2 pi))
(rem (rem a 2pi)))
(cond ((< pi rem)
(- rem 2pi))
((<= rem (- pi))
(+ 2pi rem))
(t rem))))
(defmethod mul2 ((n number) (p polar))
(let ((a (angle p)))
(make-instance 'polar
:radius (abs (* n (radius p)))
:angle (if (< n 0)
(normalize-angle (+ a pi))
a))))
(setq 2c (mul2 2 c))
[CART x 8 y 6]
(setq 3p (mul2 3 p))
[POLAR radius 30 angle 0.7853981]
(setq -3p (mul2 -3 p))
[POLAR radius 15 angle -2.3561949]