Okay, smart.., forgot the attachment and took a while to realize it :)

On Thu, 17 Feb 2005 11:21:53 +0100
 "T.A.Wassenaar" <t.a.wassen...@rug.nl> wrote:

Hi Guys,

For those interested, I've made a macro for Povray which allows to transform the Pymol povray output back to model space, or to transform povray models to Pymols camera space.

After #including "pymolmacro.inc" call PYMOL_VIEW() with the eighteen floats from cmd.get_view() to set the transformations. Then Pymol models can be transformed by calling

transform { FROM_PYMOL_VIEW }

and povray models can be transformed with

transform { TO_PYMOL_VIEW }

An example of it, adding a povray density map to the pymol scene can be found at

http://md.chem.rug.nl/~tsjerk/Gallery/density.jpg

I hope to find some time to give more explanation on how I did that. Maybe something for a Wiki ;)

Have fun,

Tsjerk


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
PyMOL-users mailing list
PyMOL-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pymol-users
//
//  PYMOLMACRO.INC v0.1 
//
//  (c)2005 Tsjerk Wassenaar, University of Groningen
//
//  This include file for Povray contains
//  just a few macros which together allow
//  the conversion between the model space
//  (cartesian coordinates) and the Pymol
//  camera space.
//
//  With these macros one can easily combine
//  a Pymol scene with objects defined in the
//  coordinate space of the original
//  structure file.
//
//  The input consists of the output of the
//  get_view() command in Pymol. This output
//  consists of 18 floating point numbers
//  defining a rotation matrix and shift
//  vectors for the origin of rotation and
//  for the camera position.
//
//  The macro PYMOL_VIEW loads a
//  view obtained from Pymol.
//
//  It #declares two transformation statements:
//
//  FROM_PYMOL_VIEW
//  TO_PYMOL_VIEW
//
//  The first can be used to transform the Pymol
//  scene back to model (normal) space, the latter
//  is used to transform other objects to appear in
//  the scene on the correct position.
//
//  
//
//  Tsjerk A. Wassenaar
//  February 16, 2005
//

// Determinant of a matrix
//------------------------
#macro DET( m11, m12, m13, m21, m22, m23, m31, m32, m33 )

  #local a = m11 * ( m22*m33 - m23*m32 ); 
  #local b = m12 * ( m21*m33 - m23*m31 ); 
  #local c = m13 * ( m21*m32 - m22*m31 );

  (a - b + c)

#end // of DET()


// The inverse of a matrix
//------------------------
#macro INV( m11, m12, m13, m21, m22, m23, m31, m32, m33 )

  #local invdet = 1/DET( m11, m12, m13, m21, m22, m23, m31, m32, m33 );
	
  #local t11 = invdet * ( m22*m33 - m23*m32 ); 
  #local t12 = invdet * ( m21*m33 - m23*m31 ); 
  #local t13 = invdet * ( m21*m32 - m22*m31 ); 
  #local t21 = invdet * ( m12*m33 - m13*m32 ); 
  #local t22 = invdet * ( m11*m33 - m13*m31 ); 
  #local t23 = invdet * ( m11*m32 - m12*m31 );
  #local t31 = invdet * ( m12*m23 - m13*m22 );
  #local t32 = invdet * ( m11*m23 - m13*m21 );
  #local t33 = invdet * ( m11*m22 - m12*m21 );

  < t11, t12, t13, t21, t22, t23, t31, t32, t33, 0, 0, 0 >

#end // of INV()

#macro PYMOL_VIEW(r11, r12, r13,     // 3x3 Rotation matrix ( Model space to Camera space )
		   r21, r22, r23, 
		   r31, r32, r33,
		   c1,  c2,  c3,     // Camera position ( Model space )
		   o1,  o2,  o3,     // Origin of rotation ( Model space )
		   s1,  s2,  or)     // Slab near and far, orthoscopic flag ( discarded )

  #declare TO_PYMOL_VIEW = transform {
    translate -< o1, o2, o3 >
    matrix < r11, r12, r13,
	     r21, r22, r23, 
	     r31, r32, r33, 
	      c1,  c2,  c3 >
  }

  #declare FROM_PYMOL_VIEW = transform {
    translate -< c1, c2, c3>
    matrix INV( r11, r12, r13, r21, r22, r23, r31, r32, r33 )
    translate  < o1, o2, o3>
  }

#end

Reply via email to