# Coordinate Transformations

The following utility functions provide mechanisms for spatial transformations for mbuild compounds:

Move a Compound such that a position overlaps with another.

Computes an affine transformation that maps the from_positions to the respective to_positions, and applies this transformation to the compound.

Parameters
move_thismb.Compound

The Compound to be moved.

from_positionsnp.ndarray, shape=(n, 3), dtype=float

Original positions.

to_positionsnp.ndarray, shape=(n, 3), dtype=float

New positions.

If from_positions and to_positions are Ports, create a bond between the two anchor atoms.

mbuild.coordinate_transform.translate(compound, pos)[source]

Translate a compound by a vector.

Parameters
compoundmb.Compound

The compound being translated.

posnp.ndarray, shape=(3,), dtype=float

The vector to translate the compound by.

mbuild.coordinate_transform.translate_to(compound, pos)[source]

Translate a compound to a coordinate.

Parameters
compoundmb.Compound

The compound being translated.

posnp.ndarray, shape=(3,), dtype=float

The coordinate to translate the compound to.

mbuild.coordinate_transform.rotate(compound, theta, around)[source]

Rotate a compound around an arbitrary vector.

Parameters
compoundmb.Compound

The compound being rotated.

thetafloat

The angle by which to rotate the compound, in radians.

aroundnp.ndarray, shape=(3,), dtype=float

The vector about which to rotate the compound.

mbuild.coordinate_transform.spin(compound, theta, around)[source]

Rotate a compound in place around an arbitrary vector.

Parameters
compoundmb.Compound

The compound being rotated.

thetafloat

The angle by which to rotate the compound, in radians.

aroundnp.ndarray, shape=(3,), dtype=float

The axis about which to spin the compound.

mbuild.coordinate_transform.x_axis_transform(compound, new_origin=None, point_on_x_axis=None, point_on_xy_plane=None)[source]

Move a compound such that the x-axis lies on specified points.

Parameters
compoundmb.Compound

The compound to move.

new_originmb.Compound or list-like of size 3, default=[0.0, 0.0, 0.0]

Where to place the new origin of the coordinate system.

point_on_x_axismb.Compound or list-like of size 3, default=[1, 0, 0]

A point on the new x-axis.

point_on_xy_planemb.Compound or list-like of size 3, default=[1, 0, 0]

A point on the new xy-plane.

mbuild.coordinate_transform.y_axis_transform(compound, new_origin=None, point_on_y_axis=None, point_on_xy_plane=None)[source]

Move a compound such that the y-axis lies on specified points.

Parameters
compoundmb.Compound

The compound to move.

new_originmb.Compound or like-like of size 3, default=[0, 0, 0]

Where to place the new origin of the coordinate system.

point_on_y_axismb.Compound or list-like of size 3, default=[0, 1, 0]

A point on the new y-axis.

point_on_xy_planemb.Compound or list-like of size 3, default=[0, 1, 0]

A point on the new xy-plane.

mbuild.coordinate_transform.z_axis_transform(compound, new_origin=None, point_on_z_axis=None, point_on_zx_plane=None)[source]

Move a compound such that the z-axis lies on specified points.

Parameters
compoundmb.Compound

The compound to move.

new_originmb.Compound or list-like of size 3, default=[0, 0, 0]

Where to place the new origin of the coordinate system.

point_on_z_axismb.Compound or list-like of size 3, default=[0, 0, 1]

A point on the new z-axis.

point_on_zx_planemb.Compound or list-like of size 3, default=[0, 0, 1]

A point on the new xz-plane.