 # psychopy.tools.mathtools.ortho3Dto2D¶

psychopy.tools.mathtools.ortho3Dto2D(p, orig, normal, up, right=None, dtype=None)[source]

Get the planar coordinates of an orthogonal projection of a 3D point onto a 2D plane.

This function gets the nearest point on the plane which a 3D point falls on the plane.

Parameters:
• p (array_like) – Point to be projected on the plane.

• orig (array_like) – Origin of the plane to test [x, y, z].

• normal (array_like) – Normal vector of the plane [x, y, z], must be normalized.

• up (array_like) – Normalized up (+Y) direction of the plane’s coordinate system. Must be perpendicular to normal.

• right (array_like, optional) – Perpendicular right (+X) axis. If not provided, the axis will be computed via the cross product between normal and up.

• 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:

Coordinates on the plane [X, Y] where the 3D point projects towards perpendicularly.

Return type:

ndarray

Examples

This function can be used with `intersectRayPlane()` to find the location on the plane the ray intersects:

```# plane information
planeOrigin = [0, 0, 0]
planeNormal = [0, 0, 1]  # must be normalized
planeUpAxis = perp([0, 1, 0], planeNormal)  # must also be normalized

# ray
rayDir = [0, 0, -1]
rayOrigin = [0, 0, 5]

# get the intersect in 3D world space
pnt = intersectRayPlane(rayOrigin, rayDir, planeOrigin, planeNormal)

# get the 2D coordinates on the plane the intersect occurred
planeX, planeY = ortho3Dto2D(pnt, planeOrigin, planeNormal, planeUpAxis)
```