-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
base: main
Are you sure you want to change the base?
WIP: implementing marching cubes and isosurface plotting #58
Conversation
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? |
There was a problem hiding this comment.
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"}))
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 |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add. 👍
src/emmy/mathbox/plot.clj
Outdated
@@ -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)] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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? |
There was a problem hiding this comment.
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.
No description provided.