psychopy.tools.mathtools.forwardProject

psychopy.tools.mathtools.forwardProject(objPos, modelView, proj, viewport=None, out=None, dtype=None)[source]

Project a point in a scene to a window coordinate.

This function is similar to gluProject and can be used to find the window coordinate which a point projects to.

Parameters:
  • objPos (array_like) – Object coordinates (x, y, z). If an Nx3 array of coordinates is specified, where each row contains a window coordinate this function will return an array of projected coordinates with the same size.

  • modelView (array_like) – 4x4 combined model and view matrix for returned value to be object coordinates. Specify only the view matrix for a coordinate in the scene.

  • proj (array_like) – 4x4 projection matrix used for rendering.

  • viewport (array_like) – Viewport rectangle for the window [x, y, w, h]. If not specified, the returned values will be in normalized device coordinates.

  • out (ndarray, optional) – Optional output array. Must be same shape and dtype as the expected output if out was not specified.

  • dtype (dtype or str, optional) – Data type for computations can either be ‘float32’ or ‘float64’. If out is specified, the data type of out is used and this argument is ignored. If out is not provided, ‘float64’ is used by default.

Returns:

Normalized device or viewport coordinates [x, y, z] of the point. The z component is similar to the depth buffer value for the object point.

Return type:

ndarray


Back to top