psychopy.tools.mathtools.distance

psychopy.tools.mathtools.distance(v0, v1, out=None, dtype=None)[source]

Get the distance between vectors/coordinates.

The behaviour of this function depends on the format of the input arguments:

  • If v0 and v1 are 1D, the distance is returned as a scalar and out is ignored.

  • If v0 and v1 are 2D, an array of distances between corresponding row vectors are returned.

  • If either v0 and v1 are 1D and 2D, an array of distances between each row of the 2D vector and the 1D vector are returned.

Parameters:
  • v0 (array_like) – Vectors to compute the distance between.

  • v1 (array_like) – Vectors to compute the distance between.

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

Distance between vectors v0 and v1.

Return type:

ndarray


Back to top