Example:
Create a sphere and try this code snippet:
Code: Select all
o=App.ActiveDocument.ActiveObject
o.evalExpression("minvert(Sphere.Shape.Placement)")
Code: Select all
o=App.ActiveDocument.ActiveObject
o.evalExpression("minvert(Sphere.Shape.Placement)")
I don't know if this is related but I've noticed a problem that makes me think of this. Ocassionaly when creating an object from a base object, two objects are created at once, like if the command was given twice. Do you think this is related? It doesn't seem to be a big problem other than you have to delete the second object.
Oops, this is not the first time I made this mistake. I searched around and fixed some similar ones. PR is here.wmayer wrote: ↑Mon Oct 07, 2019 10:14 pmgit commit 44354b808be (and possibly earlier commits) cause some memory leaks because instances of Py classes are created on the heap and passed as argument to Py::Object() so that the reference counter is incremented twice.
If I understand this right then it's a different thing. What I am talking about is to handle the reference counter of Python objects where it happens that the counter is incremented one time too often so that when releasing it to the interpreter it will never become zero and thus the allocated memory won't be freed any more.vocx wrote: ↑Mon Oct 07, 2019 10:38 pmI don't know if this is related but I've noticed a problem that makes me think of this. Ocassionaly when creating an object from a base object, two objects are created at once, like if the command was given twice. Do you think this is related? It doesn't seem to be a big problem other than you have to delete the second object.
Thanks!realthunder wrote: ↑Tue Oct 08, 2019 1:23 amOops, this is not the first time I made this mistake. I searched around and fixed some similar ones. PR is here.wmayer wrote: ↑Mon Oct 07, 2019 10:14 pmgit commit 44354b808be (and possibly earlier commits) cause some memory leaks because instances of Py classes are created on the heap and passed as argument to Py::Object() so that the reference counter is incremented twice.
Do you have any concrete ideas/suggestions how to implement this? You may know the function "slerp" for quaternions which is about this but the idea could be extended for placements. I wonder whether we should use a real function name for this instead of using the pow() function.DeepSOIC wrote: ↑Mon Sep 30, 2019 2:29 pmI've been actually wanting this arbitrary exponent as a way to interpolate between placements.wmayer wrote: ↑Mon Sep 30, 2019 12:22 pmOn Wikipedia you can find some information for square roots of a matrix but it's only well-defined for positive-definite matrices while for arbitrary matrices it causes ambiguities. But what when using 1/3 as exponent instead? Here I couldn't find a valid definition. So, a power function for arbitrary exponents makes probably not much sense (especially not in a CAD program) and it should be limited to integers only as done by the current implementation.This is true for numbers (1/X = X^-1), but there is a rigorous mathematical notion behind it, that allows to define X^-3 or X^(1/2), but for matrices or Placements, what would mean :
You don't have to define, what ^(1/3) means, as 1/3 can't be precisely represented by a float anyway. A fractional part of float is a sum of fractions:
bit1*1/2 + bit2*1/4 + bit3*1/8 +...
Power-of-two fractional powers can be easily calculated by multiplying M^(1/2) by itself.
Code: Select all
>>> rtm # the square root of matrix of a placement with some translation and some rotation
Matrix ((0.935334,0.241336,0.258664,7.09003),(0.258664,0.965346,0.0346543,8.62005),(0.241336,0.0993202,0.965346,3.10023),(0,0,0,1))
>>> rtplm.toMatrix() # if matrix survives being converted into placement, we are good
Matrix ((0.999922,-0.00851867,0.0088085,7.09003),(0.0088085,0.99942,-0.0322941,8.62005),(-0.00851867,0.0323718,0.99942,3.10023),(0,0,0,1))
>>> #no, matrix of placement is different. Bummer!
Nope
reading,,,wmayer wrote: ↑Tue Oct 08, 2019 8:22 pmThis references an interesting paper about the math and some source code:
http://www.xbdev.net/misc_demos/demos/d ... /paper.pdf
That's exactly what we need.
Users browsing this forum: No registered users and 1 guest