Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with function getOrientedBoxFromTransform #20

Open
ChristianDuriez opened this issue Mar 5, 2019 · 1 comment
Open

problem with function getOrientedBoxFromTransform #20

ChristianDuriez opened this issue Mar 5, 2019 · 1 comment

Comments

@ChristianDuriez
Copy link

There is a problem in the new implementation of getOrientedBoxFromTransorm, it creates a bug on step3 of the TRIPOD tutorial

67c1d51#r32599793

@damienmarchal could you have a look at it ?

euler Rotation is a vec3
rotation is a quat

Why are you mixing them ?
The good design, I think, should be to provide the user a function that transforms euler to quat...but then, inside the functions, always use quat...

@damienmarchal
Copy link
Member

Thanks for reporting the problems and the suggestion.

The general design guidlines in c++ would be to have the following:

void aFunction(Quaternion& rotation);
void aFunction(EulerAngles& rotation)
{
     aFunction(Quaternion::fromEulerAngles(rotation));
} 

In python the situation is a bit different as we cannot override function signature and this is not a typed language. In recent STLIB component the design seems to be the following:

def aFunction(rotation):
      qrotation = getRotationFromParameter(rotation)  
      ...

with:
def getRotationFromParameter(rotation):
     if len(rotation) == 3:  # This is euler angle in degree
            return Quaternion::createFromEulerAngle(rotation)
     if len(rotation) == 4:  # This is a quaternion
            return rotation
     raise Exception("This is not a valid rotation")

Eulalie was pointing that handling degree vs radian is a mess. Degree are not SI but everything in Sofa is un Degree. So what to do ?
On my side I like approaches like these:
https://pypi.org/project/numericalunits/
But this may be overkill.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants