Commit 7d8a5962 authored by Dave Cooper's avatar Dave Cooper

added ordering on regression system. Added epsilon to angle-between-vectors per Issue #166

parent 4fdfb508
......@@ -484,7 +484,39 @@ if given, must be orthogonal to the first two.
(radians-to-degrees
(angle-between-vectors vector-1 vector-2))))
(defun angle-between-vectors (vector-1 vector-2 &optional reference-vector &key (epsilon *zero-epsilon*) -ve negative?)
(defun angle-between-vectors (vector-1 vector-2
&optional reference-vector
&key (epsilon *zero-epsilon*) -ve negative?)
"Number. Returns the angle in radians between <b>vector-1</b> and <b>vector-2</b>.
If no <b>reference-vector</b> given, the smallest possible angle is returned.
If a <b>reference-vector</b> is given, computes according to the right-hand rule.
If <b>-ve</b> is given, returns a negative number for angle if it really is
negative according to the right-hand rule.
:arguments (vector-1 \"3D Vector\"
vector-2 \"3D Vector\")
:&optional ((reference-vector nil) \"3D Vector\")
:&key ((epsilon *zero-epsilon*) \"Number. Determines how small of an angle is considered to be zero.\"
(-ve nil) \"Boolean\")"
(let ((vector-1 (unitize-vector vector-1 :epsilon epsilon))
(vector-2 (unitize-vector vector-2 :epsilon epsilon)))
(let ((dot-vector (dot-vectors vector-1 vector-2)))
(when (> dot-vector 1.0) (setq dot-vector 1.0))
(when (< dot-vector -1.0) (setq dot-vector -1.0))
(let ((smallest-angle (acos dot-vector)))
(when (< smallest-angle epsilon) (setq smallest-angle 0.0))
(let ((try (if (and reference-vector
(minusp (dot-vectors reference-vector (cross-vectors vector-1 vector-2))))
(- (twice pi) smallest-angle)
smallest-angle)))
(if (and (or -ve negative?) (> try pi)) (- try (twice pi)) try))))))
#+nil
(defun angle-between-vectors (vector-1 vector-2
&optional reference-vector
&key (epsilon *zero-epsilon*) -ve negative?)
"Number. Returns the angle in radians between <b>vector-1</b> and
<b>vector-2</b>. If no <b>reference-vector</b> given, the smallest
possible angle is returned. If a <b>reference-vector</b> is given,
......@@ -513,6 +545,22 @@ if given, must be orthogonal to the first two.
(if (and (or -ve negative?) (> try pi)) (- try (twice pi)) try))))))
(defun unitize-vector (vector &key (epsilon *zero-epsilon*))
"Unit Vector. Returns the normalized unit-length vector corresponding to <b>vector</b>.
:arguments (vector \"3D Vector\"
:&key ((espsilon *zero-epsilon*) \"Number. How close vector should be to 1.0 to be considered unit-length.\")"
(when (and *zero-vector-checking?* (zero-vector? vector))
(error "~s has Euclidean length zero; cannot unitize." vector))
(if (near-to? (length-vector vector) 1.0 epsilon)
vector
(scalar*vector (/ (length-vector vector)) vector)))
#+nil
(defun unitize-vector (vector)
"Unit Vector. Returns the normalized unit-length vector corresponding to <b>vector</b>.
......
;;;; -*- coding: utf-8 -*-
(asdf:defsystem #:regression :description
"The Gendl™ regression Subsystem" :author "John McCarthy" :license
"Affero Gnu Public License (http://www.gnu.org/licenses/)" :serial t
:version "20150122" :depends-on (:lift :surf :tasty)
(asdf:defsystem
#:regression
:description
"The Gendl™ regression Subsystem"
:author
"Genworks International"
:license
"Affero Gnu Public License (http://www.gnu.org/licenses/)"
:serial
t
:version
"20150311"
:depends-on
(:lift :surf :tasty)
#-asdf-unicode :defsystem-depends-on #-asdf-unicode (:asdf-encodings)
#+asdf-encodings :encoding #+asdf-encodings :utf-8
:components
((:file "utils/source/package") (:file "utils/source/genworks")
(:file "utils/source/parameters") (:file "utils/source/functions")
(:file "assembly-output/source/package")
(:file "assembly-output/source/bracket-test")
(:file "assembly-output/source/bracket")
(:file "dgdl/source/remote") (:file "geom-base/source/box-matrix")
(:file "geom-base/source/drawing")
(:file "geom-base/source/general-note")
(:file "gwl/source/package") (:file "gwl/source/ajax-json")
(:file "gwl/source/hey-now") (:file "gwl/source/large-data")
(:file "gwl/source/svg-error-handling")
(:file "issues/source/issue-65") (:file "issues/source/issue-67")
(:file "issues/source/issue-68") (:file "source/package")
(:file "source/parameters") (:file "source/approximated-curve")
(:file "source/arc-curve") (:file "source/b-spline-curve")
(:file "source/b-spline-surface") (:file "source/blended-solid")
(:file "source/boolean") (:file "source/box-solid")
(:file "source/boxed-curve") (:file "source/boxed-surface")
(:file "source/brep-brep-solve") (:file "source/brep-intersect")
((:file "utils/source/package")
(:file "utils/source/genworks")
(:file "utils/source/parameters")
(:file "utils/source/functions")
(:file "source/package")
(:file "source/parameters")
(:file "source/approximated-curve")
(:file "source/arc-curve")
(:file "source/b-spline-curve")
(:file "source/b-spline-surface")
(:file "source/blended-solid")
(:file "source/boolean")
(:file "source/box-solid")
(:file "source/boxed-curve")
(:file "source/boxed-surface")
(:file "source/brep-brep-solve")
(:file "source/brep-intersect")
(:file "source/compatible-curves")
(:file "source/compatible-surfaces")
(:file "source/composed-curve") (:file "source/composed-curves")
(:file "source/cone-solid") (:file "source/conic-curve")
(:file "source/cylinder-solid") (:file "source/decomposed-curves")
(:file "source/dropped-curve") (:file "source/dual-blend-surface")
(:file "source/composed-curve")
(:file "source/composed-curves")
(:file "source/cone-solid")
(:file "source/conic-curve")
(:file "source/cylinder-solid")
(:file "source/decomposed-curves")
(:file "source/dropped-curve")
(:file "source/dual-blend-surface")
(:file "source/edge-blend-surface")
(:file "source/elliptical-curve") (:file "source/extended-surface")
(:file "source/extruded-solid") (:file "source/fitted-conic")
(:file "source/fitted-curve") (:file "source/fitted-surface")
(:file "source/gdlxml") (:file "source/general-dual-blend-surface")
(:file "source/general-note") (:file "source/general-sweep")
(:file "source/elliptical-curve")
(:file "source/extended-surface")
(:file "source/extruded-solid")
(:file "source/fitted-conic")
(:file "source/fitted-curve")
(:file "source/fitted-surface")
(:file "source/gdlxml")
(:file "source/general-dual-blend-surface")
(:file "source/general-note")
(:file "source/general-sweep")
(:file "source/global-filleted-polyline-curves")
(:file "source/iges-reader") (:file "source/iges-writer")
(:file "source/intersected-solid") (:file "source/iso-curve")
(:file "source/joined-surfaces") (:file "source/linear-curve")
(:file "source/lofted-surface") (:file "source/merged-solid")
(:file "source/native-reader") (:file "source/orientations")
(:file "source/iges-reader")
(:file "source/iges-writer")
(:file "source/intersected-solid")
(:file "source/iso-curve")
(:file "source/joined-surfaces")
(:file "source/linear-curve")
(:file "source/lofted-surface")
(:file "source/merged-solid")
(:file "source/native-reader")
(:file "source/orientations")
(:file "source/pegasus-regioned-solid")
(:file "source/planar-contour-surface")
(:file "source/planar-offset-curve")
(:file "source/planar-section-curve")
(:file "source/planar-section-curves")
(:file "source/planar-surface") (:file "source/poly-brep")
(:file "source/planar-surface")
(:file "source/poly-brep")
(:file "source/projected-curve")
(:file "source/rectangular-surface")
(:file "source/regioned-solid")
(:file "source/reparameterized-curve")
(:file "source/revolved-surface")
(:file "source/revolved-surfaces") (:file "source/ruled-surface")
(:file "source/separated-solid") (:file "source/sewn-solid")
(:file "source/shelled-solid") (:file "source/silhouette-curves")
(:file "source/spherical-surface") (:file "source/split-surface")
(:file "source/step-reader") (:file "source/step-writer")
(:file "source/stitched-solid") (:file "source/subtracted-solid")
(:file "source/revolved-surfaces")
(:file "source/ruled-surface")
(:file "source/separated-solid")
(:file "source/sewn-solid")
(:file "source/shelled-solid")
(:file "source/silhouette-curves")
(:file "source/spherical-surface")
(:file "source/split-surface")
(:file "source/step-reader")
(:file "source/step-writer")
(:file "source/stitched-solid")
(:file "source/subtracted-solid")
(:file "source/surface-knot-reduction")
(:file "source/swept-solid") (:file "source/test-harness")
(:file "source/swept-solid")
(:file "source/test-harness")
(:file "source/transformed-curve")
(:file "source/transformed-solid")
(:file "source/transformed-surface") (:file "source/trimmed-curve")
(:file "source/trimmed-surface") (:file "source/united-solid")
(:file "source/transformed-surface")
(:file "source/trimmed-curve")
(:file "source/trimmed-surface")
(:file "source/united-solid")
(:file "assembly-output/source/package")
(:file "assembly-output/source/bracket-test")
(:file "assembly-output/source/bracket")
(:file "dgdl/source/remote")
(:file "geom-base/source/angle-between-vectors")
(:file "geom-base/source/box-matrix")
(:file "geom-base/source/drawing")
(:file "geom-base/source/general-note")
(:file "gwl/source/package")
(:file "gwl/source/ajax-json")
(:file "gwl/source/hey-now")
(:file "gwl/source/large-data")
(:file "gwl/source/svg-error-handling")
(:file "issues/source/issue-65")
(:file "issues/source/issue-67")
(:file "issues/source/issue-68")
(:file "tasty/source/center-loss")
(:file "threads/source/box-solid")))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment