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

fix negative scale factor of coordinate function due to spatial transform axis direction #3992

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion OpenSim/Simulation/SimbodyEngine/SpatialTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ void SpatialTransform::scale(const SimTK::Vec3 scaleFactors)
}
SimTK::Vec3 axis;
transform.getAxis(axis);
double scaleFactor = ~axis * scaleFactors;
// we want weighted aggregate of scale factors but to ignore the sign
// ignoring sign due to issue #3991 resulting -ve scale factor
double scaleFactor = ~axis.abs() * scaleFactors;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a reasonable enough change; but it makes me wonder: is there any scenario where we would want to preserve the sign on the scale factor?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While manual scales can be set to -ve numbers, measurement-based scale factors are ratios between (unsigned) distances so can't be -ve. If we think about it as how much we stretch/shrink segments then this should never be -ve otherwise vectors/directions flip which is unlikely an intended behavior of our 'scaling'. However if you suspect there're other places in the code worth more investigation please let me know @nickbianco

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, just making sure I understood this correctly.

// If the function is already a MultiplierFunction, just update its scale factor.
// Otherwise, make a MultiplierFunction from it and make the transform axis use
// the new MultiplierFunction.
Expand Down
Loading