# psychopy.tools.mathtools.perp¶

psychopy.tools.mathtools.perp(v, n, norm=True, out=None, dtype=None)[source]

Project v to be a perpendicular axis of n.

Parameters
• v (array_like) – Vector to project [x, y, z], may be Nx3.

• n (array_like) – Normal vector [x, y, z], may be Nx3.

• norm (bool) – Normalize the resulting axis. Default is True.

• 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

Perpendicular axis of n from v.

Return type

ndarray

Examples

Determine the local up (y-axis) of a surface or plane given normal:

normal = [0., 0.70710678, 0.70710678]
up = [1., 0., 0.]

yaxis = perp(up, normal)


Do a cross product to get the x-axis perpendicular to both:

xaxis = cross(yaxis, normal)