Source code to html (Lisp) [ G.Desnoix ©96,97,98 ]
;;; Unité : ../exemples/Vecteur.src
;;; Date : Fri Jan 29 12:25:12 GMT+01:00 1999
;;; Cible : Lisp (ll)
;;; Produit: Alma (agl), Guillaume Desnoix (c)1998,1999
;;; #:fr:stcpmvn:ebli:geometrie:Vecteur [20]
(defclass {#:java:lang:Object}:Vecteur
m)
(defabbrev Vecteur {#:java:lang:Object}:Vecteur)
(deffield {Vecteur} m)
(deffunction Vecteur0 ()
(progn
(setq m (Matrice2 1 4))
(sendq a m 0 3 0.)
)
)
(deffunction Vecteur3 (ix iy iz)
(progn
(setq m (Matrice2 1 4))
(sendq a m 0 0 ix)
(sendq a m 0 1 iy)
(sendq a m 0 2 iz)
(sendq a m 0 3 0.)
)
)
(defmethod {Vecteur}:x (this) (m)
(progn
(sendq a m 0 0)
)
)
(defmethod {Vecteur}:y (this) (m)
(progn
(sendq a m 0 1)
)
)
(defmethod {Vecteur}:z (this) (m)
(progn
(sendq a m 0 2)
)
)
(defmethod {Vecteur}:x (this ix) (m)
(progn
(sendq a m 0 0 ix)
)
)
(defmethod {Vecteur}:y (this iy) (m)
(progn
(sendq a m 0 1 iy)
)
)
(defmethod {Vecteur}:z (this iz) (m)
(progn
(sendq a m 0 2 iz)
)
)
(defmethod {Vecteur}:toString (this) (m)
(progn
(+ "Vecteur(" (+ (sendq x this) (+ ", " (+ (sendq y this) (+ ", " (+ (sendq z this) ")"))))))
)
)
(defmethod {Vecteur}:norme (this) (m)
(progn
(sendq sqrt Math (sendq produitScalaire this this))
)
)
(defmethod {Vecteur}:normeXY (this) (m)
(progn
(sendq sqrt Math (sendq produitScalaireXY this this))
)
)
(defmethod {Vecteur}:normalise (this) (m)
(let ((n (sendq norme this)) )
(Vecteur3 (/ (sendq x this) n) (/ (sendq y this) n) (/ (sendq z this) n))
)
)
(defmethod {Vecteur}:normaliseXY (this) (m)
(let ((n (sendq normeXY this)) )
(Vecteur3 (/ (sendq x this) n) (/ (sendq y this) n) (sendq z this))
)
)
(defmethod {Vecteur}:equilibre (this) (m)
(let ((n (+ (sendq x this) (+ (sendq y this) (sendq z this)))) )
(Vecteur3 (/ (sendq x this) n) (/ (sendq y this) n) (/ (sendq z this) n))
)
)
(defmethod {Vecteur}:equilibreXY (this) (m)
(let ((n (+ (sendq x this) (sendq y this))) )
(Vecteur3 (/ (sendq x this) n) (/ (sendq y this) n) (sendq z this))
)
)
(defmethod {Vecteur}:rotationZ90 (this) (m)
(progn
(Vecteur3 (- (sendq x this)) (sendq y this) (sendq z this))
)
)
(defmethod {Vecteur}:projectionXY (this) (m)
(progn
(Vecteur3 (sendq x this) (sendq y this) 0.)
)
)
(defmethod {Vecteur}:applique (this t) (m)
(let ((r (Vecteur0)) )
(setq (sendq m r) (sendq multiplication m (sendq m t)))
r
)
)
(defmethod {Vecteur}:multiplication (this d) (m)
(progn
(Vecteur3 (* d (sendq x this)) (* d (sendq y this)) (* d (sendq z this)))
)
)
(defmethod {Vecteur}:division (this d) (m)
(progn
(Vecteur3 (/ (sendq x this) d) (/ (sendq y this) d) (/ (sendq z this) d))
)
)
(defmethod {Vecteur}:division (this v) (m)
(let ((w (sendq projection this v)) )
(if (!= (sendq x v) 0.)
(progn
(/ (sendq x w) (sendq x v))
)
(progn
(if (!= (sendq y v) 0.)
(progn
(/ (sendq y w) (sendq y v))
)
(progn
(if (!= (sendq z v) 0.)
(progn
(/ (sendq z w) (sendq z v))
)
)
)
)
)
)
0.
)
)
(defmethod {Vecteur}:addition (this v) (m)
(progn
(Vecteur3 (+ (sendq x this) (sendq x v)) (+ (sendq y this) (sendq y v)) (+ (sendq z this) (sendq z v)))
)
)
(defmethod {Vecteur}:addition (this p) (m)
(progn
(Point3 (+ (sendq x this) (sendq x p)) (+ (sendq y this) (sendq y p)) (+ (sendq z this) (sendq z p)))
)
)
(defmethod {Vecteur}:soustraction (this v) (m)
(progn
(Vecteur3 (- (sendq x this) (sendq x v)) (- (sendq y this) (sendq y v)) (- (sendq z this) (sendq z v)))
)
)
(defmethod {Vecteur}:produitScalaire (this v) (m)
(progn
(* (sendq x this) (+ (sendq x v) (* (sendq y this) (+ (sendq y v) (* (sendq z this) (sendq z v))))))
)
)
(defmethod {Vecteur}:produitScalaireXY (this v) (m)
(progn
(* (sendq x this) (+ (sendq x v) (* (sendq y this) (sendq y v))))
)
)
(defmethod {Vecteur}:produitSinus (this v) (m)
(progn
(sendq produitScalaire (sendq rotationZ90 this) v)
)
)
(defmethod {Vecteur}:produitSinusXY (this v) (m)
(progn
(* (sendq x v) (- (+ (sendq y this) (* (sendq y v) (sendq x this)))))
)
)
(defmethod {Vecteur}:produitVectoriel (this v) (m)
(progn
(Vecteur3 (* (sendq y this) (- (sendq z v) (* (sendq z this) (sendq y v)))) (* (sendq z this) (- (sendq x v) (* (sendq x this) (sendq z v)))) (* (sendq x this) (- (sendq y v) (* (sendq y this) (sendq x v)))))
)
)
(defmethod {Vecteur}:produitVectorielXY (this v) (m)
(progn
(Vecteur3 0. 0. (* (sendq x this) (- (sendq y v) (* (sendq y this) (sendq x v)))))
)
)
(defmethod {Vecteur}:projection (this v) (m)
(progn
(sendq multiplication (sendq normalise v) (sendq produitScalaire this (sendq normalise v)))
)
)
(defmethod {Vecteur}:produitTripleScalaire (this v1 v2) (m)
(progn
(sendq produitScalaire (sendq produitVectoriel this v1) v2)
)
)
(defmethod {Vecteur}:produitTripleVectoriel (this v1 v2) (m)
(progn
(sendq produitVectoriel (sendq produitVectoriel this v1) v2)
)
)
colors:
package -
macro -
number -
string -
comment