
(/VERSIONCHECK 2) 

(DEFUN |NUMTUBE;colinearity| (|x| |y| $)
  (/ (EXPT (SPADCALL |x| |y| (QREFELT $ 23)) 2)
     (* (SPADCALL |x| |x| (QREFELT $ 23))
        (SPADCALL |y| |y| (QREFELT $ 23))))) 

(DEFUN |NUMTUBE;orthog| (|x| |y| $)
  (PROG (|a|)
    (RETURN
      (SEQ (COND
             ((< (QREFELT $ 13) (|NUMTUBE;colinearity| |x| |y| $))
              (LETT |y| (QREFELT $ 22) . #0=(|NUMTUBE;orthog|))))
           (COND
             ((< (QREFELT $ 13) (|NUMTUBE;colinearity| |x| |y| $))
              (LETT |y|
                    (COND
                      ((< (|NUMTUBE;colinearity| |x| (QREFELT $ 18) $)
                          (QREFELT $ 13))
                       (QREFELT $ 18))
                      ('T (QREFELT $ 20))) . #0#)))
           (LETT |a|
                 (- (/ (SPADCALL |x| |y| (QREFELT $ 23))
                       (SPADCALL |x| |x| (QREFELT $ 23)))) . #0#)
           (EXIT (SETELT $ 22
                         (SPADCALL (SPADCALL |a| |x| (QREFELT $ 24))
                             |y| (QREFELT $ 25)))))))) 

(DEFUN |NUMTUBE;poTriad| (|pl| |po| |pr| $)
  (PROG (|t| |pol| |n|)
    (RETURN
      (SEQ (LETT |t|
                 (SPADCALL (SPADCALL |pr| |pl| (QREFELT $ 26))
                     (QREFELT $ 27))
                 . #0=(|NUMTUBE;poTriad|))
           (LETT |pol| (SPADCALL |pl| |po| (QREFELT $ 26)) . #0#)
           (LETT |n|
                 (SPADCALL (|NUMTUBE;orthog| |t| |pol| $)
                     (QREFELT $ 27)) . #0#)
           (EXIT (VECTOR |t| |n| (SPADCALL |t| |n| (QREFELT $ 28)))))))) 

(DEFUN |NUMTUBE;curveTriads| (|l| $)
  (PROG (|k| |b| |triad| #0=#:G1837 |pr| #1=#:G1840 |po| #2=#:G1839
             |pl| #3=#:G1838 |midtriads| |begtriad| |x| |t| |n|
             |endtriad|)
    (RETURN
      (SEQ (LETT |k| (LENGTH |l|) . #4=(|NUMTUBE;curveTriads|))
           (EXIT (COND
                   ((< |k| 2)
                    (|error| "Need at least 2 points to specify a curve"))
                   (#5='T
                    (SEQ (SETELT $ 22 (QREFELT $ 21))
                         (EXIT (COND
                                 ((EQL |k| 2)
                                  (SEQ (LETT |t|
                                        (SPADCALL
                                         (SPADCALL
                                          (SPADCALL |l| (QREFELT $ 30))
                                          (|SPADfirst| |l|)
                                          (QREFELT $ 26))
                                         (QREFELT $ 27)) . #4#)
                                       (LETT |n|
                                        (SPADCALL
                                         (SPADCALL |t| (QREFELT $ 18)
                                          (QREFELT $ 26))
                                         (QREFELT $ 27)) . #4#)
                                       (LETT |b|
                                        (SPADCALL |t| |n|
                                         (QREFELT $ 28)) . #4#)
                                       (LETT |triad|
                                        (VECTOR |t| |n| |b|) . #4#)
                                       (EXIT (LIST |triad| |triad|))))
                                 (#5#
                                  (SEQ (LETT |midtriads|
                                        (PROGN
                                          (LETT #0# NIL . #4#)
                                          (SEQ (LETT |pr| NIL . #4#)
                                           (LETT #1#
                                            (CDR (CDR |l|)) . #4#)
                                           (LETT |po| NIL . #4#)
                                           (LETT #2# (CDR |l|) . #4#)
                                           (LETT |pl| NIL . #4#)
                                           (LETT #3# |l| . #4#) G190
                                           (COND
                                             ((OR (ATOM #3#)
                                               (PROGN
                                                 (LETT |pl|
                                                  (CAR #3#) . #4#)
                                                 NIL)
                                               (ATOM #2#)
                                               (PROGN
                                                 (LETT |po|
                                                  (CAR #2#) . #4#)
                                                 NIL)
                                               (ATOM #1#)
                                               (PROGN
                                                 (LETT |pr|
                                                  (CAR #1#) . #4#)
                                                 NIL))
                                              (GO G191)))
                                           (SEQ
                                            (EXIT
                                             (LETT #0#
                                              (CONS
                                               (|NUMTUBE;poTriad| |pl|
                                                |po| |pr| $)
                                               #0#) . #4#)))
                                           (LETT #3#
                                            (PROG1 (CDR #3#)
                                              (LETT #2#
                                               (PROG1 (CDR #2#)
                                                 (LETT #1#
                                                  (CDR #1#) . #4#)) . #4#)) . #4#)
                                           (GO G190) G191
                                           (EXIT (NREVERSE0 #0#)))) . #4#)
                                       (LETT |x|
                                        (|SPADfirst| |midtriads|) . #4#)
                                       (LETT |t|
                                        (SPADCALL
                                         (SPADCALL
                                          (SPADCALL |l| (QREFELT $ 30))
                                          (|SPADfirst| |l|)
                                          (QREFELT $ 26))
                                         (QREFELT $ 27)) . #4#)
                                       (LETT |n|
                                        (SPADCALL
                                         (|NUMTUBE;orthog| |t|
                                          (QVELT |x| 1) $)
                                         (QREFELT $ 27)) . #4#)
                                       (LETT |begtriad|
                                        (VECTOR |t| |n|
                                         (SPADCALL |t| |n|
                                          (QREFELT $ 28))) . #4#)
                                       (LETT |x|
                                        (SPADCALL |midtriads|
                                         (QREFELT $ 33)) . #4#)
                                       (LETT |t|
                                        (SPADCALL
                                         (SPADCALL
                                          (SPADCALL |l| |k|
                                           (QREFELT $ 34))
                                          (SPADCALL |l| (- |k| 1)
                                           (QREFELT $ 34))
                                          (QREFELT $ 26))
                                         (QREFELT $ 27)) . #4#)
                                       (LETT |n|
                                        (SPADCALL
                                         (|NUMTUBE;orthog| |t|
                                          (QVELT |x| 1) $)
                                         (QREFELT $ 27)) . #4#)
                                       (LETT |endtriad|
                                        (VECTOR |t| |n|
                                         (SPADCALL |t| |n|
                                          (QREFELT $ 28))) . #4#)
                                       (EXIT
                                        (CONS |begtriad|
                                         (SPADCALL |midtriads|
                                          |endtriad| (QREFELT $ 35)))))))))))))))) 

(DEFUN |NUMTUBE;curveLoops| (|pts| |r| |nn| $)
  (PROG (|triads| |cosSin| |triad| #0=#:G1847 |pt| #1=#:G1846 |n| |b|
            |loops|)
    (RETURN
      (SEQ (LETT |triads| (|NUMTUBE;curveTriads| |pts| $)
                 . #2=(|NUMTUBE;curveLoops|))
           (LETT |cosSin| (SPADCALL |nn| (QREFELT $ 37)) . #2#)
           (LETT |loops| NIL . #2#)
           (SEQ (LETT |triad| NIL . #2#) (LETT #0# |triads| . #2#)
                (LETT |pt| NIL . #2#) (LETT #1# |pts| . #2#) G190
                (COND
                  ((OR (ATOM #1#)
                       (PROGN (LETT |pt| (CAR #1#) . #2#) NIL)
                       (ATOM #0#)
                       (PROGN (LETT |triad| (CAR #0#) . #2#) NIL))
                   (GO G191)))
                (SEQ (LETT |n| (QVELT |triad| 1) . #2#)
                     (LETT |b| (QVELT |triad| 2) . #2#)
                     (EXIT (LETT |loops|
                                 (CONS (SPADCALL |pt| |n| |b| |r|
                                        |cosSin| (QREFELT $ 38))
                                       |loops|) . #2#)))
                (LETT #1#
                      (PROG1 (CDR #1#) (LETT #0# (CDR #0#) . #2#)) . #2#)
                (GO G190) G191 (EXIT NIL))
           (EXIT (NREVERSE |loops|)))))) 

(DEFUN |NUMTUBE;tube;CurveDfITp;6| (|curve| |r| |n| $)
  (PROG (|brans| |bran| #0=#:G1851 |loops|)
    (RETURN
      (SEQ (COND
             ((< |n| 3) (|error| "tube: n should be at least 3"))
             ('T
              (SEQ (LETT |brans| (SPADCALL |curve| (QREFELT $ 40))
                         . #1=(|NUMTUBE;tube;CurveDfITp;6|))
                   (LETT |loops| NIL . #1#)
                   (SEQ (LETT |bran| NIL . #1#)
                        (LETT #0# |brans| . #1#) G190
                        (COND
                          ((OR (ATOM #0#)
                               (PROGN
                                 (LETT |bran| (CAR #0#) . #1#)
                                 NIL))
                           (GO G191)))
                        (SEQ (EXIT (LETT |loops|
                                    (SPADCALL |loops|
                                     (|NUMTUBE;curveLoops| |bran| |r|
                                      |n| $)
                                     (QREFELT $ 41)) . #1#)))
                        (LETT #0# (CDR #0#) . #1#) (GO G190) G191
                        (EXIT NIL))
                   (EXIT (SPADCALL |curve| |loops| 'NIL (QREFELT $ 44)))))))))) 

(DEFUN |NumericTubePlot| (#0=#:G1852)
  (PROG ()
    (RETURN
      (PROG (#1=#:G1853)
        (RETURN
          (COND
            ((LETT #1#
                   (|lassocShiftWithFunction| (LIST (|devaluate| #0#))
                       (HGET |$ConstructorCache| '|NumericTubePlot|)
                       '|domainEqualList|)
                   . #2=(|NumericTubePlot|))
             (|CDRwithIncrement| #1#))
            ('T
             (UNWIND-PROTECT
               (PROG1 (|NumericTubePlot;| #0#) (LETT #1# T . #2#))
               (COND
                 ((NOT #1#)
                  (HREM |$ConstructorCache| '|NumericTubePlot|))))))))))) 

(DEFUN |NumericTubePlot;| (|#1|)
  (PROG (DV$1 |dv$| $ |pv$|)
    (RETURN
      (PROGN
        (LETT DV$1 (|devaluate| |#1|) . #0=(|NumericTubePlot|))
        (LETT |dv$| (LIST '|NumericTubePlot| DV$1) . #0#)
        (LETT $ (GETREFV 46) . #0#)
        (QSETREFV $ 0 |dv$|)
        (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #0#))
        (|haddProp| |$ConstructorCache| '|NumericTubePlot| (LIST DV$1)
            (CONS 1 $))
        (|stuffDomainSlots| $)
        (QSETREFV $ 6 |#1|)
        (QSETREFV $ 13
            (SPADCALL (SPADCALL 995 -3 10 (QREFELT $ 10))
                (QREFELT $ 12)))
        (QSETREFV $ 18 (SPADCALL 1.0 0.0 0.0 0.0 (QREFELT $ 17)))
        (QSETREFV $ 20 (SPADCALL 0.0 1.0 0.0 0.0 (QREFELT $ 17)))
        (QSETREFV $ 21 (SPADCALL 1.0 1.0 0.0 0.0 (QREFELT $ 17)))
        (QSETREFV $ 22 (QREFELT $ 21))
        $)))) 

(MAKEPROP '|NumericTubePlot| '|infovec|
    (LIST '#(NIL NIL NIL NIL NIL NIL (|local| |#1|) (|Integer|)
             (|PositiveInteger|) (|Float|) (0 . |float|)
             (|DoubleFloat|) (7 . |convert|) 'LINMAX (12 . |One|)
             (|Point| 11) (|TubePlotTools|) (16 . |point|) 'XHAT
             (24 . |Zero|) 'YHAT 'PREV0 'PREV (28 . |dot|) (34 . *)
             (40 . +) (46 . -) (52 . |unitVector|) (57 . |cross|)
             (|List| 15) (63 . |second|)
             (|Record| (|:| |tang| 15) (|:| |norm| 15) (|:| |bin| 15))
             (|List| 31) (68 . |last|) (73 . |elt|) (79 . |concat|)
             (|List| (|List| 11)) (85 . |cosSinInfo|)
             (90 . |loopPoints|) (|List| 29) (99 . |listBranches|)
             (104 . |concat|) (|Boolean|) (|TubePlot| 6) (110 . |tube|)
             |NUMTUBE;tube;CurveDfITp;6|)
          '#(|tube| 117) 'NIL
          (CONS (|makeByteWordVec2| 1 'NIL)
                (CONS '#()
                      (CONS '#()
                            (|makeByteWordVec2| 45
                                '(3 9 0 7 7 8 10 1 9 11 0 12 0 9 0 14 4
                                  16 15 11 11 11 11 17 0 9 0 19 2 16 11
                                  15 15 23 2 16 15 11 15 24 2 16 15 15
                                  15 25 2 16 15 15 15 26 1 16 15 15 27
                                  2 16 15 15 15 28 1 29 15 0 30 1 32 31
                                  0 33 2 29 15 0 7 34 2 32 0 0 31 35 1
                                  16 36 7 37 5 16 29 15 15 15 11 36 38
                                  1 6 39 0 40 2 39 0 0 0 41 3 43 0 6 39
                                  42 44 3 0 43 6 11 7 45)))))
          '|lookupComplete|)) 
