This should do it...

import pybel
matrix = pybel.ob.matrix3x3()
matrix.RotAboutAxisByAngle(pybel.ob.vector3(1, 0, 0), 90)
my_array = pybel.ob.doubleArray(9)
matrix.GetArray(my_array)

mol = pybel.readstring("smi", "CC(=O)Cl")
mol.make3D()
print mol.write("xyz")

# 7
#
# C          1.05861       -0.06922       -0.08203
# C          2.56267       -0.02107       -0.02878
# O          3.14464        0.63176        0.83385
# Cl         3.31960       -0.96102       -1.27795
# H          0.69578       -0.68047       -0.91193
# H          0.67435        0.94707       -0.20685
# H          0.68295       -0.49475        0.85271
#

mol.OBMol.Rotate(my_array)
print mol.write("xyz")

# 7
#
# C          1.05861       -0.08203        0.06922
# C          2.56267       -0.02878        0.02107
# O          3.14464        0.83385       -0.63176
# Cl         3.31960       -1.27795        0.96102
# H          0.69578       -0.91193        0.68047
# H          0.67435       -0.20685       -0.94707
# H          0.68295        0.85271        0.49475

On 20 November 2010 15:02, Anders Christensen <[email protected]> wrote:
> Dear all,
>
> I am trying to use the Rotate() function through the python API.
> However, the method want as argument, something in the for of "double
> const [9]" (there are also other overloads, but the problem is the
> same). In what format do I pass a list/vector/matrix to Rotate()?
> Ideally, I want to use the output from RotAboutAxisByAngle(), but I
> can't just pass the resulting matrix3x3. However, I can get the
> elements of the generated rotation matrix through something along the
> lines of the following hoops+loops:
>
> some_rotation_matrix = openbabel.matrix3x3(1)
> some_rotation_matrix.RotAboutAxisByAngle(openbabel.vector3(1,2,3), 90)
>
> rotation_matrix  =[ [0.0 for i in range(3)] for j in range(3)]
> for i in range(3):
>        for j in range(3):
>                print lol.Get(i,j)
>                rotation_matrix[i][j] = some_rotation_matrix.Get(i,j)
>
> So how can I pass these elements on to Rotate(), in order to give my
> molecule a specific rotation?
>
> Best regards
> Anders
>
> ------------------------------------------------------------------------------
> Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
> Tap into the largest installed PC base & get more eyes on your game by
> optimizing for Intel(R) Graphics Technology. Get started today with the
> Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
> http://p.sf.net/sfu/intelisp-dev2dev
> _______________________________________________
> OpenBabel-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
OpenBabel-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to