Hi Lee, I've already implemented the algorithm described in this paper
and it will be part of my upcoming geometry library. To not keep you
waiting for the release, I've extracted the relevant code and put up
here:

https://gist.github.com/postspectacular/9021724

I had quite a few problems to get this working reliably (even the
original C code). It turned out the algorithm expects the vertices of
the tetrahedra to be in a certain ordering or else produces wrong
results. I've removed this need and added a function which ensures
this expected ordering and in my tests it seems to work all now. Also,
since the original C version wasn't very friendly to the Clojure way,
I've implemented some of the functions in more Clojuresque way, which
actually makes the code much more legible, but also does a little bit
more work in some cases than the C version with its endless
quick-fail-if-statements... Most of it though is pretty much the same
and I've tried to make it as lazy as possible. Any improvements
++welcome though!

Hope that helps! K.

On 13 February 2014 23:02, Lee Spector <lspec...@hampshire.edu> wrote:
>
> Can anyone point to Clojure code for detecting when two 3d shapes overlap, 
> when given the [x y z] vertices of the two shapes?
>
> The specific case I care about will always involve two regular tetrahedra 
> (each of which is specified by 4 vertices), which may allow for special 
> simplifications or efficiencies, but I'd be happy to have a more general 
> solution as long as it's not weirdly slow.
>
> I know that there are some sophisticated algorithms for doing this sort of 
> thing (e.g. [1]), but the the algorithms I've found aren't trivial and the 
> only source code I've found is pretty messy and would take some work to 
> translate (e.g. from C).
>
> And I figure that if anybody is doing 3d stuff in Clojure then the code for 
> this is probably floating around somewhere... but I haven't been able to find 
> it.
>
> Does anyone know of (or want to write :-) code for this?
>
> I guess that a Java solution would also be workable, if I the interop is 
> straightforward enough, but it'd be nicer to have a working algorithm in 
> Clojure.
>
> Thanks,
>
>  -Lee
>
> [1] Fast tetrahedron-tetrahedron overlap algorithm. F. Ganovelli, F. Ponchio 
> and C. Rocchini August 11, 2002. 
> http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=862BA3F999652E3B0BC1E7A6A3E04D49?doi=10.1.1.114.2540&rep=rep1&type=pdf
>
>
>
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
Karsten Schmidt
http://postspectacular.com | http://toxiclibs.org | http://toxi.co.uk

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to