Open forresto opened 7 years ago
I wonder if the new wasm stuff could just compile the c version.
I hope so, that'd be great! Having minimal experience with LLVM and other C compilation magic it'd be a painful road for me so very open to efforts from others on that strategy
Starting to get very basic solver functions working 🎉 Lots of deps chained together (so there was a lot of boilerplate? to get hammered out first):P Will port methods as they're needed, biggest challenge at this point is knowing how SolveSpace adds geometry and thus constraints to the sketch/system. I've been recording what I can determine in the porting knowledge doc, any insights welcome (esp. via PR)
You shouldn't port all the SolveSpace's code, you can only port Solver part without entities or groups or even id's. Solver can be so simple. Then you can just write your own simple entites and editor for them using js and so on.
That's good news! Not being experienced with either C++ or SolveSpace's internals I wasn't sure what the minimum was for the solver 😅 The library page isn't too helpful in describing the API so I'm unsure of how to add constraints, equations, etc. in the optimal way. Not trying to be critical (docs are hard, there's so much to be thankful for in solvespace!), just me fumbling around. Do you by chance know how to add, say, two lines of lengths with a point at the origin and perpendicular to each other? That may be a bad example; better, simpler, etc are welcome.
(FWIW this is my first time looking at Jacobian etc solvers, I'm not well versed in the theory (yet) (probably obvious from a previous attempt 😅 before I found solvespace))
Now solving for 7 - 3
:
SK
(Sketch) is a global in solvespace, removing globals I have a Sketch instance as a member of a System instance (so system.sketch
from new System()
), maybe that should be reversed?system.mat.Z
or system.mat.X
contains the solutions/answers?@PixnBits, The solver can be spit on two parts:
Thanks @Evil-Spirit !
Looks like System
could be a child property/variable of Sketch
but that System
isn't dependent on Sketch
. Oop. A bit of refactoring to do on my part (i.e. from const system = new System(); system.sketch;
to const sketch = new Sketch(); sketch.system;
).
I think most of System
is completed, but I'm curious of the form of expressions solvespace puts into a System
to find solutions, so I'll probably go deeper there just to get a feel.
All what you should to do - is throw away all about sketch from Sytem. Then you can just fill system every time you need to update your sketch: transfrom your xyz params into Param, then fill equations using this params for every constraint, if System.Solve will be OKAY, you should copy back correspondent Params to your xyz vector. That's simple.
System can be abstracted from geometry completely, you can solve any problems using this (don't forget to choose good params inital values)
I'm also interested in this work. Is there a way to help?
Sorry, I severely overestimated the time I'd have to work on this last year :(
I've put some recent effort into the feature/minimal
branch. I think my original port of System.js
was before I had a groove of recording the original source header and implementation file and lines, and discarded some areas including optimizations (like solving by substitution).
I started the feature/minimal_re-ported-System
branch to see how hard it would be to re-port; turns out I don't think it will be. (The branch is pushed here only so I don't lose the effort, it's not an example of "polished code")
For helping...that's a good question. Adding more scenarios to the tests would be useful?
Adding more scenarios to the tests would be useful?
Absolutely. However, I think adding test cases is more chance to spot the target while using the library. Anyway, I'll do my best when I'm on it.
AFAIK, there are 3 main components in a 3D CAD application: Constraint solver (eg. solvespace), geometric model calculator library (eg. occt), visualizer (eg. threejs). Do you have any such combination plans to make node-solvespace usable in an environment?
If you are looking for web-based CAD please consider my project https://github.com/NoteCAD/NoteCAD
Stalled a bit due to work schedule, but looking to pick this back up in earnest. My 3D printer is great, but after some SolidWorks experience I'm missing parametric modeling for hobbyists. (And can't justify $1.5K for licensing :-P) I've wanted this sort of thing for years.