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

Update quaternions to prevent sign flipping #623

Merged
merged 3 commits into from
Nov 15, 2024

Conversation

AustinSanders
Copy link
Contributor

Licensing

This project is mostly composed of free and unencumbered software released into the public domain, and we are unlikely to accept contributions that are not also released into the public domain. Somewhere near the top of each file should have these words:

This work is free and unencumbered software released into the public domain. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain.

  • I dedicate any and all copyright interest in this software to the public domain. I make this dedication for the benefit of the public at large and to the detriment of my heirs and successors. I intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

Closes #603

We've had a few discussions on the dev team about how to accomplish this, and, for the most part, we decided on implementing these changes through subclassing. This PR does not do that, but instead makes a quick and easy change that accomplishes the same thing but without isolating the change to LineScan cameras.

In order to access the quaternions from a LineScanner, it is necessary to go the route of LineScanner.FrameChain.Rotation.quats, and there are two types of rotations -- TimeDependent and Constant, so we would need at least 3 subclasses to achieve this (a custom frame chain + two types of custom rotations). TimeDependentRotation and ConstantRotation classes have methods that instantiate other TimeDependentRotation or ConstantRotation, so a lot of the methods can't use simple inheritance -- they'd need to have their logic copied and objects changed.

Ultimately, subclassing is turning out to be pretty bloated and messy. It's still possible, but this seems significantly cleaner, and I don't think the functionality inherently needs to be isolated to LineScanners.

@Kelvinrr Kelvinrr requested a review from acpaquette November 6, 2024 23:30
@acpaquette
Copy link
Collaborator

@AustinSanders Looks like a dawn test is failing from the change

@AustinSanders
Copy link
Contributor Author

Running isd_generate on the image linked in the issue now results in quaternions that are represented correctly.

New representation:

[
        -0.00014084959512966424,
        0.06988009226932775,
        -0.9799806108855965,
        -0.18642627270348733
      ],
      [
        -5.113202307559794e-05,
        0.0698602605370718,
        -0.9799805775003425,
        -0.18643392691595587
      ],
      [
        3.8327611438555095e-05,
        0.06983938596985084,
        -0.9799806386052183,
        -0.1864414295623614
      ],
      [
        0.0001291419108749148,
        0.06981977990312137,
        -0.979980865507725,
        -0.1864475392580358
      ],

Old representation:

[
        0.00014084959512966424, <<< positive, decreasing
        -0.06988009226932775,
        0.9799806108855965,
        0.18642627270348733
      ],
      [
        5.113202307559794e-05, <<< positive, decreasing, about to flip sign
        -0.0698602605370718,
        0.9799805775003425,
        0.18643392691595587
      ],
      [
        3.8327611438555095e-05, <<< Should be negative, but flips all signs to keep scalar positive 
        0.06983938596985084,    
        -0.9799806386052183,    
        -0.1864414295623614
      ],
      [
        0.0001291419108749148, 
        0.06981977990312137,
        -0.979980865507725,
        -0.1864475392580358
      ],

Note that the positive scalar criterion is no longer enforced, and the sign performs a "natural flip" when crossing the 0 boundary, but the other quaternions do not flip.

Copy link
Collaborator

@acpaquette acpaquette left a comment

Choose a reason for hiding this comment

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

Looks good!

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

Successfully merging this pull request may close these issues.

Quaternion sign flip for LROC NAC
2 participants