Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: implementing marching cubes and isosurface plotting #58

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

vnredmon
Copy link

@vnredmon vnredmon commented Jul 1, 2023

No description provided.

9 [xInc (interp y (+ y ystep) v2 v32 rhs) z]
10 [xInc (interp y yInc v4 v64 rhs)]
11 [(x (interp y yInc v8 v128 rhs) zInc)]
"Index must be between 0 and 11" ;TODO how do I throw errors in clojure?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(throw (js/Error. "")) or (throw (ex-info "message" {:k "v"}))

vnredmon added 7 commits July 5, 2023 13:02
next up testing the marching cubes implementation for correctness
...for (TestLhs 1). But there are some points with only 2 entries. huh.
Need to set up tests.
(reduce +
(map (fn [a] (Math/pow a 2)) [x y z])))

(do
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block gives me a vector with a bunch of points who's magnitude is pretty close to 1.

I can add some tests as desired (probably would be good for me to do to learn clojure's testing facilities, but I can also do that independent of implementing this).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please, we definitely want tests.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add. 👍

@@ -727,3 +727,10 @@
(let [[f-bind opts] (mc/compile-3d opts :f 3)]
(-> (c/wrap [f-bind] ['emmy.mathbox.plot/VectorField opts])
(ev/fragment scene))))
(defn implicit-surface
[opts]
(let [[f-bind opts] (mc/compile-3d opts :f 3)]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sritchie -- I'm getting caught up in this function. I know that mc/compile-3d is not what I want. But I'm murky on what's going on here -- these look like functions that take the clojure functions, turn them into clojurescript functions and return a fragment that has all the necessary details for a mathbox plot.

I think I need to implement a compile-implicit function that will take the Lhs and Rhs of the implicit function and do a bunch of the same stuff as compile-3d. Could you walk me through compile-3d and probably the compile-state-fn therein? I don't have a great high-level idea.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so what is going on here is that we have a clojure function on the clj side that we need to turn into something like (js/Function. "input" "body") for the cljs side.

I can definitely help with this; I think the easiest thing to do now is to just IGNORE this part and then pass in a quoted function, like '(fn [in out] ....) with whatever signature you need for your code to work.

Then once everything is humming we can add this part in, which will remove the need for quotes and make everything faster.

wdyt?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Willing to try! I don't really know the tradeoffs, it seems like the development path will be speedier, and I'll probably learn something in the process.

9 [xInc (interp y (+ y yInc) v2 v32 rhs) z]
10 [xInc (interp y yInc v4 v64 rhs)]
11 [x (interp y yInc v8 v128 rhs) zInc]
(println (str "Index must be between 0 and 11. Given: " index)) ;TODO how do I throw errors in clojure?
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will update to throw the error as per the outdated comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants