Closed jaredjennings closed 4 years ago
I started on this path. You can have strings in a write-scad data structure and they will write out to SCAD output as literals. Nice! But say I'm defining a module that takes a parameter x
. To do anything with x
rather than pass it straight to another function or module, I need to talk about it in an expression. Say I want to multiply it by 2. My clojure function said (* x 2)
before. Now it either has to be transliterated - "x * 2"
- or I have to teach scad-clj how to write arbitrary expressions, i.e. translate (* "x" 2)
to x * 2
in the output. Easy enough for arithmetic, but where will it stop and where should it?
With vertical-prisms.scad
, manually-written OpenSCAD has come home to roost in this keyboard. I'm fine with a mix of Clojure and OpenSCAD, particularly given that I've determined it's a necessary optimization. The only regrettable thing that remains is the duplication of constants across languages. Wontfix.
In recent days I've read some patents that have made it clear that the key placement is a more open matter for experimentation, less constant than I assumed. In order to achieve key placement flexibility, it will be most convenient to describe a given key placement only once, in Clojure. That means we need this again.
tshort's branch (which I've absorbed a copy of into this repository) has key placement functions that can either use OpenSCAD transformations to place an object, or use Clojure transformations to locate a point. Inspect and use as necessary.
Easy enough for arithmetic, but where will it stop and where should it?
Eh, it should be easy enough to do what needs done, and not much more, with a macro. When needs change, so can the macro.
Hmm, what I really need is to evaluate the same piece of code multiple times with different bindings. tshort did this by passing the relevant functions in as parameters - simple enough, and since the relevant functions were things like "rotate around the x axis" and not "multiply two numbers," it wasn't too stilted.
The only reason tshort did this was (I gather from skimming the code) to be able to obtain the coordinates of a point, rather than only to transform something at the origin to be at that point and rotated properly. I've wanted that, but I've made it so far without it, too.
In fact, now that I've looked at it, key-place is not duplicated in Clojure at all, it's only written in OpenSCAD. So to choose from different key placements all we would have to do is import a different OpenSCAD file. That is simpler than all this. Re-closed.
In order to make KeyPlace and ThumbPlace usable, they have been defined manually in OpenSCAD. But clj-scad can write OpenSCAD, and the manually written OpenSCAD contains redefinitions of constants defined in Clojure.
So make Clojure code that writes the definitions of KeyPlace and ThumbPlace, so that we can stop tracking manually written OpenSCAD.