Hi, your code is really hard to understand. Please let let to be your friend! I extracted things a little bit and put everything in a let. Since I have no clue about collission detection in physics engines I derived the local names from the operations done "i"nc, "d"ec, etc. More meaningful names conveying domain information are left to the astute reader as an excercise. ;-)
You probably can replace defstruct with defrecord. defrecord will supersede defstruct eventually. > (defstruct projection-struct :start :stop :start-points :stop-points) > (println 1) Here you can use the type function. Also note: your method won't work. Your dispatch function should match your methods in arity. It may take more if they are "don't cares" for the dispatch. > (defmulti projection (fn [shape & _] (type shape))) > (println 2) As I said, some cleanup with let (hopefully without messing things up). Also you cannot "call" integers with vectors. You have to use nth. > (defmethod projection :polygon > [shape plane] > (let [points (:points shape) > npoints (int (count points)) > dotp #(->> % (nth points) (dot plane)) > search (fn [condition] > (loop [accum (int 0) > step npoints > from (int -1)] > (let [step (inc (/ step (int 2))) > iaccum (+ accum step) > daccum (- accum step) > naccum (mod iaccum npoints) > paccum (mod daccum npoints) > dotp-accum (dotp accum) > dotp-naccum (dotp naccum) > dotp-paccum (dotp paccum) > apoints (nth points accum) > fpoints (nth points from)] > (condp condition dotp-accum > dotp-naccum (if (= from iaccum) > [dotp-naccum [fpoints apoints]] > (recur naccum step accum)) > dotp-paccum (if (= from daccum) > [dotp-paccum [fpoints apoints]] > (recur paccum step accum)) > [dotp-accum [apoints]])))) > [start start-points] (search <=) > [end end-points] (search >=)] > (struct projection-struct start end start-points end-points))) > (println 3) On 1 Nov., 01:10, Jarl Haggerty <fictivela...@gmail.com> wrote: > I've also redefined the math functions to work with vectors and > matrices. Hmm.. I would suggest to stay away from such experiments until you have a better understanding on Clojure. That all said: I don't have a problem for your real problem. I don't see an obvious reason why the defmethod should hang. I would expect some quirk in your environment from outside this code snippet. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en