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

Transform3D#SetRotation() around arbitrary axis scales coordinates #4995

Closed
sroughley opened this issue Feb 8, 2022 · 3 comments · Fixed by #4997
Closed

Transform3D#SetRotation() around arbitrary axis scales coordinates #4995

sroughley opened this issue Feb 8, 2022 · 3 comments · Fixed by #4997

Comments

@sroughley
Copy link
Contributor

The method Transform3D#SetRotation(double, Point3D) scales the co-ordinates if the axis vector Point3D is not a unit vector:

/*! \brief set the rotation matrix
*
* The rotation matrix is set to rotation by th specified angle
* about an arbitrary axis
*/
void SetRotation(double angle, const Point3D &axis);

Either the documentation should state this requirement, or the method implement it.

This can be demonstrated in the Java wrapper as follows:

String molBlock = "Single Atom should be invariate\n     RDKit          3D\n\n  1  0  0  0  0  0  0  0  0  0999 V2000\n"+
"    1.0000    1.0000    1.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\nM  END\n\n$$$$";
ROMol mol = RWMol.MolFromMolBlock(molBlock);

// An axis around which the molecule should be invariate:
Point3D axis = new Point3D(1.0, 1.0, 1.0);

//The transform
Transform3D t3d = new Transform3D();
t3d.SetRotation(Math.PI, axis);

//Apply it...
mol.transformMolsAtoms(t3d);

System.out.println(mol.MolToMolBlock());

Gives:

Single Atom should be invariate
     RDKit          3D

  1  0  0  0  0  0  0  0  0  0999 V2000
    3.0000    3.0000    3.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
M  END

The result can be correct in the calling code, but this is not obviously required from the documentation, e.g.:

...
// An axis around which the molecule should be invariate:
Point3D axis = new Point3D(1.0, 1.0, 1.0);
axis.normalize();
...
@greglandrum
Copy link
Member

I agree that the behavior should be properly documented.
There's an argument for changing it, but that would remove functionality and potentially break a lot of existing code.

@sroughley
Copy link
Contributor Author

Hi @greglandrum - I think we are agreed - the behaviour change would be 'ideal' but the breakages could be... ouch.

I will add a sentence to the doc comment in the header file and submit a pull request if you think that would cover it?

@greglandrum
Copy link
Member

greglandrum commented Feb 8, 2022

@sroughley

I will add a sentence to the doc comment in the header file and submit a pull request if you think that would cover it?

That would be perfect. Thanks!

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

Successfully merging a pull request may close this issue.

2 participants