Skip to content

IndigoRender rotate image #1906

Answered by AlexanderSavelyev
twall asked this question in Q&A
Discussion options

You must be logged in to vote

As a solution we can suggest to use XYZ function for atoms and rotate using standard rotation matrix. See the following code as an example

def rotate(x, y, angle):
    xn = x * math.cos(angle) - y * math.sin(angle)
    yn = x * math.sin(angle) + y * math.cos(angle)
    return xn, yn


m = indigo.loadMolecule('C1([H])C=CC=C1')
m.layout()

indigoRenderer.renderToFile(m, 'result1.png')

angle = 3.14159
for a in m.iterateAtoms():
    xyz = a.xyz()
    xn, yn = rotate(xyz[0], xyz[1], angle)
    a.setXYZ(xn, yn, 0)

indigoRenderer.renderToFile(m, 'result2.png')


Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by AlexanderSavelyev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants