Vcross   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/contrib/gsl.xtm

Implementation

;; for 3d only
(bind-func Vcross
  (lambda (v1 v2)
    (let ((size:size_t (tref v1 0))
    (v3 (Valloc 3)))
      (gsl_vector_set_zero v3)
      (if (<> size 3)
    (begin (printf "Vcross for 3d vectors only!\n")
     v3)
    (begin (gsl_vector_set v3 0 (- (* (gsl_vector_get v1 1)
              (gsl_vector_get v2 2))
           (* (gsl_vector_get v1 2)
              (gsl_vector_get v2 1))))
     (gsl_vector_set v3 1 (- (* (gsl_vector_get v1 2)
              (gsl_vector_get v2 0))
           (* (gsl_vector_get v1 0)
              (gsl_vector_get v2 2))))
     (gsl_vector_set v3 2 (- (* (gsl_vector_get v1 0)
              (gsl_vector_get v2 1))
           (* (gsl_vector_get v1 1)
              (gsl_vector_get v2 0))))
     v3)))))


Back to Index

Similar Entries

  • cpvcross    xtlang
  • vvcross    xtlang
  • vvcross    xtlang