I didn't know freecad has it's own api. I expected the default python math package.
And I know from that one that is not optimised for vectors...
I didn't know freecad has it's own api. I expected the default python math package.
From python math module i am using only few things. (math.pi, math.sqrt() ) at uncritical points regarding speed.
@kbwbe, @Turro75Turro75 wrote: ↑Sun Jul 29, 2018 7:28 am Substract spincenter to both v1 and v2, now you have two vectors which are both starting at origin and keep original angle. So now getangle gives you a reliable value.
As Kbwbe already said be careful on using methods on spincenter as most of them modify spincenter too
Hi @project4,project4 wrote: ↑Sun Jul 29, 2018 2:53 pm@kbwbe, @Turro75Turro75 wrote: ↑Sun Jul 29, 2018 7:28 am Substract spincenter to both v1 and v2, now you have two vectors which are both starting at origin and keep original angle. So now getangle gives you a reliable value.
As Kbwbe already said be careful on using methods on spincenter as most of them modify spincenter too
Guys,
It looks like Vector.getAngle returns absolute angle without the rotation direction.
I would expect to see opposite numbers if I call "v1.getAngle(v2)" and "v2.getAngle(v1)".
For example, for that case, where bottom bars are fixed and I sum all the angles, I would expect to see zero sum:
4.png
Any tips how I can get rotation angle with rotation direction?
Hi @Turro75,Turro75 wrote: ↑Sun Jul 29, 2018 3:29 pm Try playing with vector.dot(vector)
this what it does
def dotproduct(first, other):
"dotproduct(Vector,Vector) - returns the dot product of both vectors"
if isinstance(first,FreeCAD.Vector) and isinstance(other,FreeCAD.Vector):
return (first.x*other.x + first.y*other.y + first.z*other.z)
def angle(first, other=FreeCAD.Vector(1,0,0)):
"angle(Vector,Vector) - returns the angle in radians between the two vectors.
If only one is given, angle is between the vector and the horizontal East direction"
if isinstance(first,FreeCAD.Vector) and isinstance(other,FreeCAD.Vector):
return math.acos(dotproduct(normalized(first),normalized(other)))
this is taken from here
https://www.freecadweb.org/wiki/FreeCAD ... th_library
Hi @kbwbe, @project4 and @turro75 !kbwbe wrote: ↑Sun Jul 29, 2018 1:40 pm Hi @project4,@turro75,@manuelkrause,
Branch "solver-stabilization" has been updated again.
There is a new command "repair-treeview". After deleting an imported part and further undoing this by FreeCAD, the constraints were not grouped under the import parts any more. By using "repair-treeview" they are sorted again to correct place.
I do not know how to start this automatically after "undo", therefore a new command at moment.
@project4: Do you know how to start the "repair-treeview" after undo automatically ?
Ok. Based on the printouts now I have the needed rotation center and the rotation angle...kbwbe wrote: ↑Sun Jul 29, 2018 3:52 pmHi @Turro75,Turro75 wrote: ↑Sun Jul 29, 2018 3:29 pm Try playing with vector.dot(vector)
this what it does
def dotproduct(first, other):
"dotproduct(Vector,Vector) - returns the dot product of both vectors"
if isinstance(first,FreeCAD.Vector) and isinstance(other,FreeCAD.Vector):
return (first.x*other.x + first.y*other.y + first.z*other.z)
def angle(first, other=FreeCAD.Vector(1,0,0)):
"angle(Vector,Vector) - returns the angle in radians between the two vectors.
If only one is given, angle is between the vector and the horizontal East direction"
if isinstance(first,FreeCAD.Vector) and isinstance(other,FreeCAD.Vector):
return math.acos(dotproduct(normalized(first),normalized(other)))
this is taken from here
https://www.freecadweb.org/wiki/FreeCAD ... th_library
please do not use "DraftVecUtils". There is to much python inside. It seems to be slow. I hope that FreeCAD's vector api is not using it.