r/OpenPythonSCAD • u/rebuyer10110 • Oct 15 '24
Is an inverse() function supported to invert a handle?
I typically follow the pattern of translating + rotating a component during assembly to do touch up work, and perform inverse movement to put the component back to its original position to prep for printing on the base plate.
I have been utilizing handles for this a lot.
The pain point I ran into: I really could use numpy's np.linalg.inv() to calculate the inverse eigen vector to restore a component back to its original position.
Questions:
- Is there a way to import libraries I install from pip into pythonscad's run time? I see a File > Show Library Folder. Is that where I can place dependencies? It is still clunky for numpy since it has a chain of py files I would need to copy over.
- Is there a built-in matrix inverse operator I can use right now?
3
Upvotes
2
u/gadget3D Oct 15 '24
Sorry, PythonSCAD does not have a native function to invert handles. after all handles are just a 4x4 python lists.
If you manage to get the inversed numbers, you will reach your goal.
You could probably use align again for that. its syntax is align(object, dsthandle, refhandle) whereas internally redfhandle gets "inversed" for correct calculation
Similar to openscad, pythonSCAD has a working multmatrix function. but in addition, PythonSCAD has divmatrix,
so you would not have to invert the matrix, but just use divmatrix instead ?
(so divmatrix is probably the solution, you are looking for ? )
About imorting libraries, usually PythonSCAD shares the libraries you install for windows Python. But there are limitations. Especially libraries which use DLLs won't work ( and i would be happy if someone could find the reason)
1
u/WillAdams Oct 15 '24
If I understand correctly, I was able to do:
and use that to check which modules were loaded/where they were loaded from and have been using:
both to place the .py module I've been developing (when I'm loading it into Python), and to load other modules.
Note that .py files which are used by a .scad file in OpenPythonSCAD are placed in a normal OpenSCAD Libraries folder such as:
and I believe it's necessary to copy a file into both places if you wish to be able to both import and use it from both sides.