diff org/test-creature.org @ 82:6b4ca076285e

making some progress on cone joints...
author Robert McIntyre <rlm@mit.edu>
date Fri, 06 Jan 2012 02:03:43 -0700
parents 10f495560c59
children 14b604e955ed
line wrap: on
line diff
     1.1 --- a/org/test-creature.org	Thu Jan 05 21:31:34 2012 -0700
     1.2 +++ b/org/test-creature.org	Fri Jan 06 02:03:43 2012 -0700
     1.3 @@ -173,19 +173,19 @@
     1.4                        twist    (:twist constraints)]
     1.5                    
     1.6                    (println-repl "creating CONE joint")
     1.7 -                  (let [vector-1
     1.8 -                        (.mult (.getWorldRotation joint)
     1.9 -                               Vector3f/UNIT_X)
    1.10 -                        vector-2
    1.11 -                        (.normalize
    1.12 -                         (.subtract
    1.13 -                          (.getWorldTranslation joint)
    1.14 -                          (.getWorldTranslation obj-a)))
    1.15 +                  (let [frame-a
    1.16 +                        (.toRotationMatrix
    1.17 +                         (doto (Quaternion.)
    1.18 +                           (.fromAngleAxis
    1.19 +                            (float
    1.20 +                             (.angleBetween
    1.21 +                              pivot-a Vector3f/UNIT_X))
    1.22 +                            (.cross (.normalize pivot-a)
    1.23 +                                    Vector3f/UNIT_X))))
    1.24                          ]
    1.25                      (println-repl
    1.26 -                     "vector-1 :" vector-1)
    1.27 -                    (println-repl
    1.28 -                     "vector-2 :" vector-2)
    1.29 +                     "angle between pivot-a (" pivot-a ") and UNIT_X is"
    1.30 +                     (.angleBetween Vector3f/UNIT_X (.normalize pivot-a)))
    1.31                      
    1.32                      
    1.33                      
    1.34 @@ -195,40 +195,25 @@
    1.35                           control-b
    1.36                           pivot-a
    1.37                           pivot-b
    1.38 +
    1.39 +                        
    1.40 +                         ;; ;; frame-in-A
    1.41 +                         frame-a
    1.42 +                         frame-a
    1.43                           
    1.44 -                         ;;(doto (Matrix3f.)
    1.45 -                         ;;  (.fromStartEndVectors
    1.46 -                         ;;   Vector3f/UNIT_X
    1.47 -                         ;;   (.normalize
    1.48 -                         ;;    (.subtract
    1.49 -                         ;;     (.getWorldTranslation joint)
    1.50 -                         ;;     (.getWorldTranslation obj-a)))))
    1.51 -
    1.52 -
    1.53 -                         (.toRotationMatrix
    1.54 -                          (.getWorldRotation joint))
    1.55 +                         ;; (.toRotationMatrix
    1.56 +                         ;;  (doto (Quaternion.)
    1.57 +                         ;;    (.fromAngles
    1.58 +                         ;;     0 0 (* -1 (/ Math/PI 2)))))
    1.59  
    1.60                           
    1.61 -                         
    1.62 -                         (.toRotationMatrix
    1.63 -                          (.fromAngleAxis
    1.64 -                           (Quaternion.)
    1.65 -                           (.angleBetween Vector3f/UNIT_X pivot-a)
    1.66 -                           (.cross Vector3f/UNIT_X pivot-a)))
    1.67 -                         
    1.68 +                         ;; ;; frame-in-B
    1.69 +                         ;; (.toRotationMatrix
    1.70 +                         ;;  (doto (Quaternion.)
    1.71 +                         ;;    (.fromAngles
    1.72 +                         ;;     0 0 (* -1.2 (/ Math/PI 2)))))
    1.73  
    1.74 -                         
    1.75 -                         
    1.76 -                         ;; (doto (Matrix3f.)
    1.77 -                         ;;   (.fromStartEndVectors
    1.78 -                         ;;    Vector3f/UNIT_X
    1.79 -                         ;;    (.normalize
    1.80 -                         ;;     vector-1)))
    1.81 -                         
    1.82 -                         ;; (doto (Matrix3f.)
    1.83 -                         ;;   (.fromStartEndVectors
    1.84 -                         ;;    Vector3f/UNIT_X
    1.85 -                         ;;    vector-2))
    1.86 +
    1.87                           )
    1.88                        (.setLimit (float limit-xz)
    1.89                                   (float limit-xy)