-
Notifications
You must be signed in to change notification settings - Fork 15
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 quaternion default initialisation #300
base: master
Are you sure you want to change the base?
Fix quaternion default initialisation #300
Conversation
The current initialization is neither the identity quaternion 1 + 0i + 0j + 0k (Q(w = 1, x = 0, y = 0, z = 0)) nor represents a pure rotation as it is not normalized. Therefore revert changes made earlier returning to Q(0,0,0,0). Note: Initialisation to Q(0,0,0,0) is beneficial for performance reasons to Q(1,0,0,0). Signed-off-by: Christoph Niethammer <[email protected]>
…rameters Signed-off-by: Christoph Niethammer <[email protected]>
b5128cf
to
e11f7f1
Compare
Still failing the internalGenerator testcase - will need another look at this |
Signed-off-by: Christoph Niethammer <[email protected]>
e11f7f1
to
4fe755b
Compare
Signed-off-by: Christoph Niethammer <[email protected]>
@HomesGH Tests passing and ready for review. |
To be honest, I still don't see the benefit of changing it to the invalid Q(0,0,0,0). Is it just performance-wise why we don't choose the identity Q(1,0,0,0)? There is much worse performing code, eg. the check for duplicated IDs. For me, it would be ok to initialize the Quaternion class itself with 0,0,0,0, but all molecules should always carry valid data (Q(0,0,0,0) is invalid). Therefore, I see two options:
Furthermore, I can not guarantee that there are no hidden molecule initializations somewhere in the code. Those could break when using invalid data for initialization. |
These lines could also cause trouble, even though, they should not be relevant in theory. Also the I can not guarantee that I found all |
Remove the default parameters for the Molecule constructor to prevent unintentional incorrect initialization of molecules. Fix all related places in the code with the appropriate initialization values. Signed-off-by: Christoph Niethammer <[email protected]>
I address the concern about missing initialization values by changing the Molecule constructor to require all parameters to be passed - removing default values from the interface. This should catch all places during compile time! |
This is ok-ish for me. Even though, always having to set all of those zeros including a single |
@@ -60,9 +60,9 @@ void ParticleDataFull::MoleculeToParticleData(ParticleDataFull &particleStruct, | |||
particleStruct.D[2] = molecule.D(2); | |||
} | |||
|
|||
void ParticleDataFull::ParticleDataToMolecule(const ParticleDataFull &particleStruct, Molecule &molecule) { | |||
Molecule ParticleDataFull::ParticleDataToMolecule(const ParticleDataFull &particleStruct) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of interest: Is the whole object returned or just a pointer?
If former, isn't this quite bad since a Molecule object is rather big?
This PR reverts changes to the defaults in the constructor made in 20a6b8f back to 0 + 0i + 0j + 0k (Q(w=0, x=0, y=0, z=0)) to address #291. The issue was first mentioned in #255
This has been tested using