psychopy.tools.mathtools.orthogonalize

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

Orthogonalize a vector relative to a normal vector.

This function ensures that v is perpendicular (or orthogonal) to n.

Parameters:
  • v (array_like) – Vector to orthogonalize, can be Nx2, Nx3, or Nx4. If a 2D array is specified, rows are treated as separate vectors.

  • n (array_like) – Normal vector, must have same shape as v.

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

Orthogonalized vector v relative to normal vector n.

Return type:

ndarray

Warning

If v and n are the same, the direction of the perpendicular vector is indeterminate. The resulting vector is degenerate (all zeros).


Back to top