[ Ticket #4236 Recompute issue ] Placement.Rotation.Axis and non unit vector?

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
User avatar
Roy_043
Veteran
Posts: 7393
Joined: Thu Dec 27, 2018 12:28 pm

[ Ticket #4236 Recompute issue ] Placement.Rotation.Axis and non unit vector?

Post by Roy_043 »

In the attached file the placement of Body001 is linked to that of Body through formulas.
Everything seems to work fine except for one thing. I can change the rotation axes of Body to values that do not correspond to a unit vector. But in that case the rotation axes of Body001 are recalculated to unit vector values, resulting in a different placement.

This behavior seems strange.

Test:
Change the rotation axes of Body to: 1,0,1.
Result for the rotation axes of Body001: 0.71,0,0.71.

Code: Select all

OS: Windows 8.1 (6.3)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18946 (Git)
Build type: Release
Branch: master
Hash: 0175008ceba01666449657086ca036fc59e0e6c7
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Dutch/Netherlands (nl_NL)
Attachments
PlacementTest.FCStd
(17.27 KiB) Downloaded 32 times
Last edited by Roy_043 on Fri Dec 27, 2019 8:47 pm, edited 1 time in total.
User avatar
Vincent B
Veteran
Posts: 4491
Joined: Sun Apr 05, 2015 9:02 am
Location: La Rochelle, France

Re: Placement.Rotation.Axis and non unit vector?

Post by Vincent B »

Axe data are just a vector, its must be ok with 0.71 0 0.71
...but I've got 0.69 0.00 0.72... :shock: something wrong.

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18990 (Git)
Build type: Release
Branch: master
Hash: e499f384240196c415f207520bfbcb8df9d1b0d2
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: French/France (fr_FR)
openBrain
Veteran
Posts: 8997
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Placement.Rotation.Axis and non unit vector?

Post by openBrain »

Rotation are internally stored as quaternions, so indeed you'll get normalized vector even if you entered a non one. But this should not change the placement.
User avatar
Roy_043
Veteran
Posts: 7393
Joined: Thu Dec 27, 2018 12:28 pm

Re: Placement.Rotation.Axis and non unit vector?

Post by Roy_043 »

@openBrain, you are probably right, and this may actually turn out to be a confusing recompute issue.
After changing the axes of Body to 1,0,1 Body001 has to be recomputed 5 times to visually adopt its correct placement.
openBrain
Veteran
Posts: 8997
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Placement.Rotation.Axis and non unit vector?

Post by openBrain »

I took some time to open the file, and there is definitely something weird.
I ran below snippet :

Code: Select all

old = App.ActiveDocument.Body001.Placement.Rotation.Axis
for i in range(2,100):
    App.ActiveDocument.Body001.touch()
    App.ActiveDocument.recompute()
    print("Iteration %i : %s" % (i, App.ActiveDocument.Body001.Placement.Rotation.Axis))
    if old == App.ActiveDocument.Body001.Placement.Rotation.Axis:
        print("Steady state achieved")
        break
    old = App.ActiveDocument.Body001.Placement.Rotation.Axis
And it takes 26 iterations of recomputing (including the 1st automatically performed by FC) to get a steady state !!! :!:
Unfortunately I can't get no further clue about what happens.
User avatar
Roy_043
Veteran
Posts: 7393
Joined: Thu Dec 27, 2018 12:28 pm

Re: Placement.Rotation.Axis and non unit vector?

Post by Roy_043 »

Thanks for testing. Weird indeed. I'll check the situation in V0.18.
User avatar
Roy_043
Veteran
Posts: 7393
Joined: Thu Dec 27, 2018 12:28 pm

Re: Placement.Rotation.Axis and non unit vector?

Post by Roy_043 »

Somehow the formulas applied in V0.19 are missing when the file is opened in V0.18 (known issue?).
But after creating a similar model in V0.18 I find that the recompute issue also occurs there.

Code: Select all

OS: Windows 8.1
Word size of OS: 64-bit
Word size of FreeCAD: 32-bit
Version: 0.18.4 (GitTag)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: 980bf9060e28555fecd9e3462f68ca74007b70f8
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: Dutch/Netherlands (nl_NL)
Attachments
PlacementTest_V018.FCStd
(15.95 KiB) Downloaded 19 times
openBrain
Veteran
Posts: 8997
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Placement.Rotation.Axis and non unit vector?

Post by openBrain »

I can reproduce with a minimal example with just a cube and a cylinder... :)
Let's ask to who knows. ;)
wmayer wrote: Ping
@wmayer, easy fix or deserve a ticket ?
wmayer
Founder
Posts: 19965
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Placement.Rotation.Axis and non unit vector?

Post by wmayer »

openBrain wrote: Fri Dec 27, 2019 3:50 pm I can reproduce with a minimal example with just a cube and a cylinder... :)
Let's ask to who knows. ;)
wmayer wrote: Ping
@wmayer, easy fix or deserve a ticket ?
Go ahead and open a ticket please. I think there might be something wrong in the expression engine.

It's true that on low-level when calculating with the quaternions the axes are normalized but the Rotation class stores the original axis coordinates and angle so that the property editor will show the original values instead of the normalized values.
chrisb
Veteran
Posts: 51227
Joined: Tue Mar 17, 2015 9:14 am

Re: Placement.Rotation.Axis and non unit vector?

Post by chrisb »

Roy_043 wrote: Fri Dec 27, 2019 2:03 pm Somehow the formulas applied in V0.19 are missing when the file is opened in V0.18 (known issue?).
That can be expected. The new expression engine in 0.19 uses new syntax, wich probably (in most cases) cannot be interpreted in 0.18.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply