psychopy.tools.gltools.transformMeshPosOri

psychopy.tools.gltools.transformMeshPosOri(vertices, normals, pos=(0.0, 0.0, 0.0), ori=(0.0, 0.0, 0.0, 1.0))[source]

Transform a mesh.

Transform mesh vertices and normals to a new position and orientation using a position coordinate and rotation quaternion. Values vertices and normals must be the same shape. This is intended to be used when editing raw vertex data prior to rendering. Do not use this to change the configuration of an object while rendering.

Parameters
  • vertices (array_like) – Nx3 array of vertices.

  • normals (array_like) – Nx3 array of normals.

  • pos (array_like, optional) – Position vector to transform mesh vertices. If Nx3, vertices will be transformed by corresponding rows of pos.

  • ori (array_like, optional) – Orientation quaternion in form [x, y, z, w]. If Nx4, vertices and normals will be transformed by corresponding rows of ori.

Returns

Transformed vertices and normals.

Return type

tuple

Examples

Create and re-orient a plane to face upwards:

vertices, textureCoords, normals, faces = createPlane()

# rotation quaternion
qr = quatFromAxisAngle((1., 0., 0.), -90.0)  # -90 degrees about +X axis

# transform the normals and points
vertices, normals = transformMeshPosOri(vertices, normals, ori=qr)

Any create* primitive generating function can be used inplace of createPlane.


Back to top