Created
April 4, 2018 15:18
-
-
Save mmurooka/282f7aec8dba5ddc7630a92849dced12 to your computer and use it in GitHub Desktop.
normalize-vector grep results
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
leus@cygnus:~/ros/indigo_parent/src/euslisp/Euslisp$ find ./ -name "*.l" | xargs grep normalize-vector -A5 -B2 | |
./lib/demo/hehehe.l- (send pole4 :translate #f(15 -15 2)) | |
./lib/demo/hehehe.l- (setq r1 (body+ base pole1 pole2 pole3 pole4 top)) | |
./lib/demo/hehehe.l: (setq pln (make-plane :normal (normalize-vector #f(1 2 8)) | |
./lib/demo/hehehe.l- :point #f(0 0 8))) | |
./lib/demo/hehehe.l- (setq part1 (body/ r1 pln)) | |
./lib/demo/hehehe.l- (send part1 :magnify 10.0)) | |
./lib/demo/hehehe.l- ) | |
./lib/demo/hehehe.l- | |
-- | |
./lib/demo/meteor.l- | |
./lib/demo/meteor.l-(defun reflection-ray (normal light) | |
./lib/demo/meteor.l: (normalize-vector | |
./lib/demo/meteor.l- (v- (scale (* 2.0 (v. normal light)) normal) | |
./lib/demo/meteor.l- light) )) | |
./lib/demo/meteor.l- | |
./lib/demo/meteor.l-(defun random-direction (dir ratio) | |
./lib/demo/meteor.l- (v+ dir (random-vector ratio))) | |
-- | |
./lib/demo/kogi.l- (send pole4 :translate #f(15 -15 2)) | |
./lib/demo/kogi.l- (setq r1 (body+ base pole1 pole2 pole3 pole4 top)) | |
./lib/demo/kogi.l: (setq pln (make-plane :normal (normalize-vector #f(1 2 8)) | |
./lib/demo/kogi.l- :point #f(0 0 8))) | |
./lib/demo/kogi.l- (setq part1 (body/ r1 pln)) | |
./lib/demo/kogi.l- (send part1 :magnify 10.0)) | |
./lib/demo/kogi.l- ) | |
./lib/demo/kogi.l- | |
-- | |
./lib/llib/eusdraw.l- (b)) | |
./lib/llib/eusdraw.l- (setq b (scale arrow-size | |
./lib/llib/eusdraw.l: (normalize-vector (rotate-vector a 0.5 nil)))) | |
./lib/llib/eusdraw.l- (send vs :g-line point0 (v- point0 (coerce b integer-vector)) | |
./lib/llib/eusdraw.l- *draw-gc*) | |
./lib/llib/eusdraw.l- (setq b (scale arrow-size | |
./lib/llib/eusdraw.l: (normalize-vector (rotate-vector a -0.5 nil)))) | |
./lib/llib/eusdraw.l- (send vs :g-line point0 (v- point0 (coerce b integer-vector)) | |
./lib/llib/eusdraw.l- *draw-gc*))) | |
./lib/llib/eusdraw.l- (when (member :end arrow) | |
./lib/llib/eusdraw.l- (let* ((a (coerce (v- point1 point0) float-vector)) | |
./lib/llib/eusdraw.l- (b)) | |
./lib/llib/eusdraw.l- (setq b (scale arrow-size | |
./lib/llib/eusdraw.l: (normalize-vector (rotate-vector a 0.5 nil)))) | |
./lib/llib/eusdraw.l- (send vs :g-line point1 (v- point1 (coerce b integer-vector)) | |
./lib/llib/eusdraw.l- *draw-gc*) | |
./lib/llib/eusdraw.l- (setq b (scale arrow-size | |
./lib/llib/eusdraw.l: (normalize-vector (rotate-vector a -0.5 nil)))) | |
./lib/llib/eusdraw.l- (send vs :g-line point1 (v- point1 (coerce b integer-vector)) | |
./lib/llib/eusdraw.l- *draw-gc*))) | |
./lib/llib/eusdraw.l- ) | |
./lib/llib/eusdraw.l- (:arrow (&optional x sz) | |
./lib/llib/eusdraw.l- (when x | |
-- | |
./lib/llib/utyo.l- (send self :init | |
./lib/llib/utyo.l- p2 | |
./lib/llib/utyo.l: (normalize-vector (v* (v- p3 p2) | |
./lib/llib/utyo.l- (v- p1 p2))) | |
./lib/llib/utyo.l- )) | |
./lib/llib/utyo.l- (:new-from-3dline-3dvector (3dl 3dv) | |
./lib/llib/utyo.l- (let ((p0 (send 3dl :pos))) | |
./lib/llib/utyo.l- (send self :init | |
-- | |
./lib/llib/quaternion.l- (:init (ss aa) ;aa need not to be normalized | |
./lib/llib/quaternion.l- (send self :newquat | |
./lib/llib/quaternion.l: ss (scale (sqrt (- 1.0 (* ss ss))) (normalize-vector aa)))) | |
./lib/llib/quaternion.l- (:norm () (sqrt (+ (* s s) (v. a a)))) | |
./lib/llib/quaternion.l- (:conjugate () (instance quaternion :newquat s (v- a))) | |
./lib/llib/quaternion.l- (:inverse-quaternion () | |
./lib/llib/quaternion.l- (let ((norm (send self :norm))) | |
./lib/llib/quaternion.l- (instance quaternion :newquat (/ s norm) (scale (/ 1.0 norm) (v- a))))) | |
-- | |
./lib/llib/quaternion.l- (scale (* 2.0 s) (v* a r)))) | |
./lib/llib/quaternion.l- (:angle () (* 2.0 (atan (norm a) s))) | |
./lib/llib/quaternion.l: (:axis () (normalize-vector a)) | |
./lib/llib/quaternion.l- (:concat (q) | |
./lib/llib/quaternion.l- (declare (quaternion q)) | |
./lib/llib/quaternion.l- (let ((s2 (quaternion-s q)) (a2 (quaternion-a q))) | |
./lib/llib/quaternion.l- (send self :newquat %(s * s2 - v.(a a2)) | |
./lib/llib/quaternion.l- (v+ (v+ (scale s a2) (scale s2 a)) | |
-- | |
./contrib/utyo/glue.l- | |
./contrib/utyo/glue.l-(defun find-neary-connect-edge (v edg elist) | |
./contrib/utyo/glue.l: (let* ((v1 (normalize-vector (v- (edg . pvert) (edg . nvert)))) | |
./contrib/utyo/glue.l- (result)) | |
./contrib/utyo/glue.l- (dolist (e elist) | |
./contrib/utyo/glue.l- (cond ((or (equal v (e . pvert)) | |
./contrib/utyo/glue.l- (equal v (e . nvert))) | |
./contrib/utyo/glue.l- (push e result)) | |
-- | |
./contrib/utyo/glue.l- (t (return-from angle-of-edges 'not-intersect)) | |
./contrib/utyo/glue.l- ) | |
./contrib/utyo/glue.l: (setq ang (vector-angle (normalize-vector (v- p1 int-point)) | |
./contrib/utyo/glue.l: (normalize-vector (v- p2 int-point)))) | |
./contrib/utyo/glue.l- (setq triang (triangle p1 int-point p2 norm)) | |
./contrib/utyo/glue.l- (cond | |
./contrib/utyo/glue.l- ((minusp triang) (setq ang (- (* 2 pi) ang))) | |
./contrib/utyo/glue.l- (t nil)) | |
./contrib/utyo/glue.l- ang)) | |
-- | |
./contrib/utyo/glue.l- (result)) | |
./contrib/utyo/glue.l- (setq norm | |
./contrib/utyo/glue.l: (normalize-vector | |
./contrib/utyo/glue.l- (v* (v- (edg . pvert) (edg . nvert)) | |
./contrib/utyo/glue.l- (v- ((car elist) . pvert) ((car elist) . nvert))))) | |
./contrib/utyo/glue.l- (if (zerop (vector-length norm)) | |
./contrib/utyo/glue.l- (setq norm | |
./contrib/utyo/glue.l: (normalize-vector | |
./contrib/utyo/glue.l- (v* (v- (edg . pvert) (edg . nvert)) | |
./contrib/utyo/glue.l- (v- ((cadr elist) . pvert) ((cadr elist) . nvert))))) | |
./contrib/utyo/glue.l- (dolist (e elist) | |
./contrib/utyo/glue.l- (push (list e (angle-of-edges edg e norm)) result))) | |
./contrib/utyo/glue.l- (setq result (sort result #'cadr-less)) | |
-- | |
./contrib/utyo/part.l- (let* ((v1 (v- pvert nvert)) | |
./contrib/utyo/part.l- (v2 (v- (ed . pvert) (ed . nvert))) | |
./contrib/utyo/part.l: (norm (normalize-vector | |
./contrib/utyo/part.l- (v* v1 (v* v1 v2)))) | |
./contrib/utyo/part.l- (pln (instance plane :init norm pvert)) | |
./contrib/utyo/part.l- (int-list (send pln :intersect-edge ed)) | |
./contrib/utyo/part.l- ) | |
./contrib/utyo/part.l- (cond | |
-- | |
./contrib/utyo/linraphs.l- (let* ((r1 (matrix-row r 0)) | |
./contrib/utyo/linraphs.l- (r2 (matrix-row r 1)) | |
./contrib/utyo/linraphs.l: (r3 (normalize-vector (v* r1 r2)))) | |
./contrib/utyo/linraphs.l: (v* r3 (normalize-vector r1) r2) | |
./contrib/utyo/linraphs.l- (v* r2 r3 r1) | |
./contrib/utyo/linraphs.l- (replace-matrix r (make-matrix-from-rvector r1 r2 r3)))) | |
./contrib/utyo/linraphs.l-;;(defun authorized-normalize (r) r) | |
./contrib/utyo/linraphs.l- | |
./contrib/utyo/linraphs.l-(eval-when (load eval) | |
-- | |
./contrib/utyo/local.l- (declare (float-vector v)) | |
./contrib/utyo/local.l- (transform rot | |
./contrib/utyo/local.l: (normalize-vector | |
./contrib/utyo/local.l- (float-vector (/ (* (aref v 0) screenx) | |
./contrib/utyo/local.l- viewdistance) | |
./contrib/utyo/local.l- (/ (* (aref v 1) screeny) | |
./contrib/utyo/local.l- viewdistance) | |
./contrib/utyo/local.l- 1)))) | |
-- | |
./contrib/utyo/newton.l- (let* ((r1 (matrix-row r 0)) | |
./contrib/utyo/newton.l- (r2 (matrix-row r 1)) | |
./contrib/utyo/newton.l: (r3 (normalize-vector (v* r1 r2)))) | |
./contrib/utyo/newton.l: (v* r3 (normalize-vector r1) r2) | |
./contrib/utyo/newton.l- (v* r2 r3 r1) | |
./contrib/utyo/newton.l- (replace-matrix r (make-matrix-from-rvector r1 r2 r3)))) | |
./contrib/utyo/newton.l-;;(defun authorized-normalize (r) r) | |
./contrib/utyo/newton.l- | |
./contrib/utyo/newton.l-(eval-when (load eval) | |
-- | |
./contrib/utyo/round.l- (let* ((flist (bod . faces)) | |
./contrib/utyo/round.l- (con-faces (find-con-faces vert flist)) | |
./contrib/utyo/round.l: (n-vect (normalize-vector vect)) | |
./contrib/utyo/round.l- (pln (instance plane :init n-vect (v+ vert (scale depth n-vect)))) | |
./contrib/utyo/round.l- (new-edg-verts | |
./contrib/utyo/round.l- (mapcar #'(lambda (f) (send pln :intersect-face f)) | |
./contrib/utyo/round.l- con-faces)) | |
./contrib/utyo/round.l- (new-verts (flatten new-edg-verts))) | |
-- | |
./contrib/utyo/round.l- (let* ((vert1) | |
./contrib/utyo/round.l- (vert2) | |
./contrib/utyo/round.l: (norm (normalize-vector | |
./contrib/utyo/round.l- (v+ ((edg . pface) . normal) ((edg . nface) . normal)))) | |
./contrib/utyo/round.l- (vect (scale (- depth) norm)) | |
./contrib/utyo/round.l- (apoint (v+ (edg . pvert) vect)) | |
./contrib/utyo/round.l- (pln (instance plane :init norm apoint))) | |
./contrib/utyo/round.l- (setq con-edge1 | |
-- | |
./contrib/utyo/round.l- (verts) | |
./contrib/utyo/round.l- (vert) | |
./contrib/utyo/round.l: (norm (normalize-vector | |
./contrib/utyo/round.l- (v+ ((edg . pface) . normal) ((edg . nface) . normal)))) | |
./contrib/utyo/round.l- (vect (scale (- depth) norm)) | |
./contrib/utyo/round.l- (apoint (v+ (edg . pvert) vect)) | |
./contrib/utyo/round.l- (pln (instance plane :init norm apoint))) | |
./contrib/utyo/round.l- (setq con-edges | |
-- | |
./contrib/utyo/round.l- (let* ((con-faces) | |
./contrib/utyo/round.l- (verts) | |
./contrib/utyo/round.l: (norm (normalize-vector | |
./contrib/utyo/round.l- (v+ ((edg . pface) . normal) ((edg . nface) . normal)))) | |
./contrib/utyo/round.l- (vect (scale depth norm)) | |
./contrib/utyo/round.l- (apoint (v+ (edg . pvert) vect)) | |
./contrib/utyo/round.l- (pln (instance plane :init norm apoint))) | |
./contrib/utyo/round.l- (setq con-faces (list (edg . pface) (edg . nface))) | |
-- | |
./contrib/utyo/localop.l- (let* ((v1 (v- pvert nvert)) | |
./contrib/utyo/localop.l- (v2 (v- (ed . pvert) (ed . nvert))) | |
./contrib/utyo/localop.l: (norm (normalize-vector | |
./contrib/utyo/localop.l- (v* v1 (v* v1 v2)))) | |
./contrib/utyo/localop.l- (pln (instance plane :init norm pvert)) | |
./contrib/utyo/localop.l- (int-list (send pln :intersect-edge ed)) | |
./contrib/utyo/localop.l- ) | |
./contrib/utyo/localop.l- (cond | |
-- | |
./contrib/contact/model2constRobust.l- (push (instance edge :init | |
./contrib/contact/model2constRobust.l- :pvertex position | |
./contrib/contact/model2constRobust.l: :nvertex (normalize-vector (scale sign n-point)) | |
./contrib/contact/model2constRobust.l- :pface (first flist) :nface (car (last flist))) | |
./contrib/contact/model2constRobust.l- eset)) | |
./contrib/contact/model2constRobust.l- (push eset esets)) | |
./contrib/contact/model2constRobust.l- (push flist esets)) | |
./contrib/contact/model2constRobust.l- (setq eset nil) | |
-- | |
./lisp/geo/geopack.l-(defun direction-vector (org dest) | |
./lisp/geo/geopack.l- "(org dest) returns a normalized vector from org to dest" | |
./lisp/geo/geopack.l: (normalize-vector (v- dest org))) | |
./lisp/geo/geopack.l- | |
./lisp/geo/geopack.l-(defparameter triangle-temp1 (float-vector 0 0 0)) | |
./lisp/geo/geopack.l-(defparameter triangle-temp2 (float-vector 0 0 0)) | |
./lisp/geo/geopack.l- | |
./lisp/geo/geopack.l-(defun triangle (a b c &optional (normal #f(0 0 1))) | |
-- | |
./lisp/geo/geopack.l-(defun triangle-normal (a b c) | |
./lisp/geo/geopack.l-"normal vector for the plane on which three points (a b c) lie." | |
./lisp/geo/geopack.l: (normalize-vector (v* (v- b a) (v- c a)))) | |
./lisp/geo/geopack.l- | |
./lisp/geo/geopack.l:(defun vector-angle (v1 v2 &optional (normal (normalize-vector (v* v1 v2))) (parallel-thre 1e-10)) | |
./lisp/geo/geopack.l-"Compute angle (radian) between two vectors, v1 and v2. | |
./lisp/geo/geopack.l-Normal is vertical to both v1 and v2. | |
./lisp/geo/geopack.l-v1, v2 and normal must be normalized in advance. | |
./lisp/geo/geopack.l-Normal must be given if the sign of the angle is needed." | |
./lisp/geo/geopack.l- (if (< (norm2 (v* v1 v2)) parallel-thre) | |
-- | |
./lisp/geo/geopack.l- (setq v2 (car vertices)) | |
./lisp/geo/geopack.l- (v+ (v* v1 v2 v) normal normal) | |
./lisp/geo/geopack.l: (normalize-vector normal normal)) ) | |
./lisp/geo/geopack.l- | |
./lisp/geo/geopack.l-(defun farthest (p points) | |
./lisp/geo/geopack.l- ;; in a list of vectors bound to points, find the point farthest from p. | |
./lisp/geo/geopack.l- (let* ((vv (pop points)) (dist (distance p vv)) (d 0.0)) | |
./lisp/geo/geopack.l- (dolist (v points) | |
-- | |
./lisp/geo/geopack.l- | |
./lisp/geo/geopack.l-(defun random-normalized-vector () | |
./lisp/geo/geopack.l: (normalize-vector (float-vector (random 1.0) (random 1.0) (random 1.0)))) | |
./lisp/geo/geopack.l- | |
./lisp/geo/geopack.l-#| Kameyama function | |
./lisp/geo/geopack.l-(defun random-normalized-vector2() | |
./lisp/geo/geopack.l- (let ((v1 (- (random 2.0) 1.0)) | |
./lisp/geo/geopack.l- (v2 (random 1.0)) | |
-- | |
./lisp/geo/geopack.l- (:end-point (v) | |
./lisp/geo/geopack.l- (if (eq pvert v) v (if (eq nvert v) v nil))) | |
./lisp/geo/geopack.l: (:direction () (normalize-vector (v- nvert pvert))) | |
./lisp/geo/geopack.l- (:prin1 (strm) | |
./lisp/geo/geopack.l- (flet ((string-float-vector (fv) | |
./lisp/geo/geopack.l- (let ((s (make-string-output-stream 30))) | |
./lisp/geo/geopack.l- (princ "#f(" s) | |
./lisp/geo/geopack.l- (dotimes (i (length fv)) | |
-- | |
./lisp/geo/geopack.l- (:next-vertex (f) (send (send f :next-edge self) :nvertex f)) | |
./lisp/geo/geopack.l- (:direction (&optional (f pface)) ;directed edge direction | |
./lisp/geo/geopack.l: (cond ((eq f pface) (normalize-vector (v- nvert pvert))) | |
./lisp/geo/geopack.l: ((eq f nface) (normalize-vector (v- pvert nvert))) | |
./lisp/geo/geopack.l- ((facep f) | |
./lisp/geo/geopack.l- (dolist (h (send f :holes)) | |
./lisp/geo/geopack.l- (if (memq self (send h :edges)) | |
./lisp/geo/geopack.l- (return-from :direction (send self :direction h)))) | |
./lisp/geo/geopack.l- (error "hole for :direction")) | |
-- | |
./lisp/geo/geopack.l- (warn "no such face")))) | |
./lisp/geo/geopack.l- (:binormal (f) | |
./lisp/geo/geopack.l: (normalize-vector (v* (cond ((eq f pface) (v- nvert pvert)) | |
./lisp/geo/geopack.l- ((eq f nface) (v- pvert nvert)) | |
./lisp/geo/geopack.l- (t (send self :error "bad face"))) | |
./lisp/geo/geopack.l- (send f :normal)))) | |
./lisp/geo/geopack.l- (:angle () angle) ;angle between pface and nface | |
./lisp/geo/geopack.l- (:approximated-p () (eq (logand flags 1) 1)) | |
-- | |
./lisp/geo/geopack.l- (setq angle (vector-angle (face-normal pface) | |
./lisp/geo/geopack.l- (face-normal nface) | |
./lisp/geo/geopack.l: (normalize-vector (v- nvert pvert))))) | |
./lisp/geo/geopack.l- (:set-face (pv nv f) | |
./lisp/geo/geopack.l- (cond | |
./lisp/geo/geopack.l- ((and (eq pv pvert) (eq nv nvert)) (setq pface f)) | |
./lisp/geo/geopack.l- ((and (eq nv pvert) (eq pv nvert)) (setq nface f)) | |
./lisp/geo/geopack.l- (t (send self :error "inconsistent face setting")))) | |
-- | |
./lisp/geo/geopack.l-(defmethod edge | |
./lisp/geo/geopack.l- (:center-coordinates () | |
./lisp/geo/geopack.l: (let* ((z (normalize-vector (v- nvert pvert))) | |
./lisp/geo/geopack.l- (x (if (< (distance z #f(1 0 0)) 0.0001) | |
./lisp/geo/geopack.l- #f(0 1 0) #f(1 0 0))) | |
./lisp/geo/geopack.l- (y (v* z x))) | |
./lisp/geo/geopack.l- (setq x (v* y z)) | |
./lisp/geo/geopack.l- (instance coordinates :init | |
-- | |
./lisp/geo/geopack.l- (:brightness (light-source) | |
./lisp/geo/geopack.l-; (if (> (norm light-source) 2.0) | |
./lisp/geo/geopack.l:; (setq light-source (normalize-vector | |
./lisp/geo/geopack.l-; (v- light-source (car vertices))))) ; point light-source | |
./lisp/geo/geopack.l- (+ 1.0 (/ (v. normal light-source) 2.0))) ;parallel lighting | |
./lisp/geo/geopack.l- (:project (&optional (point (float-vector 0 0 0))) | |
./lisp/geo/geopack.l- (declare (float-vector point)) | |
./lisp/geo/geopack.l- (v- point (scale (+ distance (v. point normal)) normal)) ) | |
-- | |
./lisp/geo/geopack.l- (if (> (abs d) (abs sign2)) (setq sign2 d))))) | |
./lisp/geo/geopack.l- ; check if both signs are different | |
./lisp/geo/geopack.l: (if (minusp (* sign1 sign2)) (normalize-vector (scale sign1 normal))))) | |
./lisp/geo/geopack.l- (:init (n apoint) | |
./lisp/geo/geopack.l- ;defines a plane whose normal is n and passes on apoint | |
./lisp/geo/geopack.l- (setq normal n) | |
./lisp/geo/geopack.l- (if (float-vector-p apoint) | |
./lisp/geo/geopack.l- (setq distance (- (v. normal apoint))) | |
-- | |
./lisp/geo/geopack.l- (setq normal (face-normal-vector point point)) | |
./lisp/geo/geopack.l- (setq point (car point))) | |
./lisp/geo/geopack.l: (setq normal (normalize-vector normal)) | |
./lisp/geo/geopack.l- (if distance (setq point (scale (- distance) normal))) | |
./lisp/geo/geopack.l- (instance plane :init normal point)) | |
./lisp/geo/geopack.l- | |
./lisp/geo/geopack.l-(defconstant *xy-plane* (make-plane)) | |
./lisp/geo/geopack.l-(defconstant *yz-plane* (make-plane :normal #f(1 0 0))) | |
-- | |
./lisp/geo/gdome.l- (setf gvector (v- (apply #'v++ (cdr (face-vertices gf))) | |
./lisp/geo/gdome.l- (scale 3 radiant))) | |
./lisp/geo/gdome.l: (normalize-vector gvector gvector) | |
./lisp/geo/gdome.l- (push gf results) | |
./lisp/geo/gdome.l- (dolist (of ofaces) | |
./lisp/geo/gdome.l- (setf intersect (send of :intersect-point-vector radiant gvector)) | |
./lisp/geo/gdome.l- (when (equal (car intersect) ':inside) | |
./lisp/geo/gdome.l- (setq dist | |
-- | |
./lisp/geo/viewing.l- (if (null view-direction) | |
./lisp/geo/viewing.l- (setq view-direction (v- target pos))) | |
./lisp/geo/viewing.l: (setq view-direction (normalize-vector view-direction)) | |
./lisp/geo/viewing.l- (unless view-right | |
./lisp/geo/viewing.l- (setq view-right (v* view-direction view-up))) | |
./lisp/geo/viewing.l: (setq view-right (normalize-vector view-right)) | |
./lisp/geo/viewing.l: (setq view-up (normalize-vector (v* view-right view-direction))) | |
./lisp/geo/viewing.l- (setq view-direction (scale -1.0 view-direction)) | |
./lisp/geo/viewing.l- (setf (array-entity rot) | |
./lisp/geo/viewing.l- (concatenate float-vector view-right view-up view-direction)) | |
./lisp/geo/viewing.l- (transpose rot rot) ) | |
./lisp/geo/viewing.l- (send self :worldcoords) | |
-- | |
./lisp/geo/viewing.l- "returns direction vector pointing (u,v) in NDC from the viewpoint" | |
./lisp/geo/viewing.l- (declare (float u v)) | |
./lisp/geo/viewing.l: (normalize-vector | |
./lisp/geo/viewing.l- (send self :rotate-vector | |
./lisp/geo/viewing.l- (float-vector (* screenx u) (* screeny v) (- viewdistance))))) | |
./lisp/geo/viewing.l- (:view-plane (&optional (offset 0.0)) | |
./lisp/geo/viewing.l-"+offset makes the viewplane closer to the viewpoint, | |
./lisp/geo/viewing.l--offset takes further distance." | |
-- | |
./lisp/geo/viewing.l- (send box :corners)) | |
./lisp/geo/viewing.l- )) | |
./lisp/geo/viewing.l: (setq v1 (normalize-vector (send box :minpoint)) | |
./lisp/geo/viewing.l: v2 (normalize-vector (send box :maxpoint))) | |
./lisp/geo/viewing.l- (setq ang (acos (v. v1 v2))) | |
./lisp/geo/viewing.l- (send self :hither | |
./lisp/geo/viewing.l- (* 0.5 (aref (send box :extream-point #f(0 0 -1)) 2))) | |
./lisp/geo/viewing.l- (send self :yon | |
./lisp/geo/viewing.l- (* 2.0 (aref (send box :extream-point #f(0 0 1)) 2))) | |
-- | |
./lisp/geo/viewing.l- (declare (float-vector v)) | |
./lisp/geo/viewing.l- (transform (transpose (viewcoords . rot)) | |
./lisp/geo/viewing.l: (normalize-vector | |
./lisp/geo/viewing.l- (float-vector (/ (* (aref v 0) screenx) | |
./lisp/geo/viewing.l- viewdistance) | |
./lisp/geo/viewing.l- (/ (* (aref v 1) screeny) | |
./lisp/geo/viewing.l- viewdistance) | |
./lisp/geo/viewing.l- 1)))) | |
-- | |
./lisp/geo/lighting.l- (let ((normal (send f :normal))) | |
./lisp/geo/lighting.l- ; (setq light (v- light point)) | |
./lisp/geo/lighting.l: (normalize-vector | |
./lisp/geo/lighting.l- %(v-(scale((2.0 * v.(normal light)) normal) light))))) | |
-- | |
./lisp/geo/render.l- | |
./lisp/geo/render.l-(defun reflection-ray (normal light) | |
./lisp/geo/render.l: (normalize-vector | |
./lisp/geo/render.l- (v- (scale (* 2.0 (v. normal light)) normal) | |
./lisp/geo/render.l- light) )) | |
./lisp/geo/render.l- | |
./lisp/geo/render.l-(defvar *render-shadow* t) | |
./lisp/geo/render.l- | |
-- | |
./lisp/geo/render.l- (v- vp point normal-view) | |
./lisp/geo/render.l- (setq brightness (* 0.1 reflectance)) ;ambient | |
./lisp/geo/render.l: (normalize-vector normal-view normal-view) | |
./lisp/geo/render.l- (dolist (light lights) | |
./lisp/geo/render.l- (when (or (null *render-shadow*) | |
./lisp/geo/render.l- (send light :illuminated-p point face3)) | |
./lisp/geo/render.l- (v- (send light :worldpos) point lighting) | |
./lisp/geo/render.l: (normalize-vector lighting normal-lighting) | |
./lisp/geo/render.l- (setq income (/ (send light :intensity) | |
./lisp/geo/render.l- (v. lighting lighting)) ) | |
./lisp/geo/render.l- (setq diffusion | |
./lisp/geo/render.l- (max 0.0 (* (v. normal normal-lighting) | |
./lisp/geo/render.l- income diffusal-reflectance) )) | |
-- | |
./lisp/geo/extroid.l- | |
./lisp/geo/extroid.l-(defun 2d-random-normalized-vector () | |
./lisp/geo/extroid.l: (normalize-vector (float-vector (random 1.0) (random 1.0)))) | |
./lisp/geo/extroid.l- | |
./lisp/geo/extroid.l-(defun 2d-random-vectors (n r) | |
./lisp/geo/extroid.l- (if (< n 1) | |
./lisp/geo/extroid.l- nil | |
./lisp/geo/extroid.l- (cons (2d-random-vector r) (2d-random-vectors (1- n) r)))) | |
-- | |
./lisp/geo/geobody.l- ((eql axis :y) #f(0 1 0)) | |
./lisp/geo/geobody.l- ((eql axis :z) #f(0 0 1)) | |
./lisp/geo/geobody.l: (t (normalize-vector axis)))) | |
./lisp/geo/geobody.l- (dolist (v model-vertices) | |
./lisp/geo/geobody.l- (v+ (scale (* (- scale 1.0) (v. v axis)) axis) v v) ) | |
./lisp/geo/geobody.l- ) | |
./lisp/geo/geobody.l- (t (dolist (v model-vertices) (scale scale v v)) )) | |
./lisp/geo/geobody.l- (send self :update) | |
-- | |
./lisp/geo/geobody.l- (:closest-point (point) | |
./lisp/geo/geobody.l- (v+ (send self :worldpos) | |
./lisp/geo/geobody.l: (scale radius (normalize-vector (v- point (send self :worldpos)))))) | |
./lisp/geo/geobody.l- (:intersect-with-body (bod) | |
./lisp/geo/geobody.l- (dolist (v (send bod :vertices)) | |
./lisp/geo/geobody.l- (if (< (distance v pos) radius) (return-from :intersect-with-body t))) | |
./lisp/geo/geobody.l- nil) | |
./lisp/geo/geobody.l- (:init (&key (center (float-vector 0 0 0)) ((:radius r) 1.0)) | |
-- | |
./lisp/geo/grahamhull.l- (v) | |
./lisp/geo/grahamhull.l- (start (farthest o vertices)) | |
./lisp/geo/grahamhull.l: (vstart (normalize-vector (v- start o))) | |
./lisp/geo/grahamhull.l- (vtemp (floatvector 0 0 0))) | |
./lisp/geo/grahamhull.l- (setq vertices (remove start vertices :count 1)) | |
./lisp/geo/grahamhull.l- (print start) | |
./lisp/geo/grahamhull.l- (dolist (v vertices) | |
./lisp/geo/grahamhull.l- (v- v o vtemp) | |
./lisp/geo/grahamhull.l: (normalize-vector vtemp vtemp) | |
./lisp/geo/grahamhull.l- (setq ang (vector-angle vstart vtemp normal)) | |
./lisp/geo/grahamhull.l- (if (< ang 0.0) (setq ang (+ ang 2pi))) | |
./lisp/geo/grahamhull.l- (push (list ang v) sorted-vertices)) | |
./lisp/geo/grahamhull.l- (setq sorted-vertices (mapcar #'cadr (sort sorted-vertices #'< #'car))) | |
./lisp/geo/grahamhull.l- (setq result (cons start sorted-vertices )) | |
-- | |
./lisp/geo/primt.l-(defun coplanar-p (p1 p2 p3 p4 &optional (*epsilon* *coplanar-threshold*)) | |
./lisp/geo/primt.l- (let* ((v1 (v- p2 p1)) (v2 (v- p3 p2)) (v3 (v- p4 p1)) | |
./lisp/geo/primt.l: (n (normalize-vector (v* v1 v2)))) | |
./lisp/geo/primt.l- (eps= (v. n v3) 0.0))) | |
./lisp/geo/primt.l- | |
./lisp/geo/primt.l-#+:ieee-floating-point | |
./lisp/geo/primt.l-(progn (defparameter *-inf* (/ -1.0 0.0)) | |
./lisp/geo/primt.l- (defparameter *inf* (/ 1.0 0.0) | |
-- | |
./lisp/geo/primt.l- (if (= 0.0 (elt vec 2)) (setq angle 0.0) | |
./lisp/geo/primt.l- (setq angle | |
./lisp/geo/primt.l: (vector-angle (normalize-vector vec) | |
./lisp/geo/primt.l: (normalize-vector fvec) | |
./lisp/geo/primt.l: (normalize-vector (v* vec fvec)) | |
./lisp/geo/primt.l- ))) | |
./lisp/geo/primt.l- (when (< angle minangle) | |
./lisp/geo/primt.l- (setq result v minangle angle))) | |
./lisp/geo/primt.l- ) | |
./lisp/geo/primt.l- result)) | |
-- | |
./lisp/geo/primt.l- (setq angle | |
./lisp/geo/primt.l- (vector-angle #f(0 0 1) | |
./lisp/geo/primt.l: (normalize-vector n) | |
./lisp/geo/primt.l: (normalize-vector (v* #f(0 0 1) n)) | |
./lisp/geo/primt.l- ))) | |
./lisp/geo/primt.l- (if (< angle minangle) | |
./lisp/geo/primt.l- (setq result v minangle angle)))) | |
./lisp/geo/primt.l- ) | |
./lisp/geo/primt.l- result)) | |
-- | |
./lisp/geo/primt.l- (setf (gethash v oldverts) (list (copy-object v)))) | |
./lisp/geo/primt.l- (dolist (e (hedron . edges)) | |
./lisp/geo/primt.l: (setq v (scale radius (normalize-vector (v+ (e . pvert) (e . nvert))))) | |
./lisp/geo/primt.l- (setf (gethash e newverts) (cons e (list v)))) | |
./lisp/geo/primt.l- (dolist (fac (hedron . faces)) | |
./lisp/geo/primt.l- (setq v (fac . vertices) e (fac . edges)) | |
./lisp/geo/primt.l- (setq vlist1 (list (gethash (car v) oldverts) | |
./lisp/geo/primt.l- (gethash (cadr v) oldverts) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment