skspatial.objects.Vector.side_vector

Vector.side_vector(other: Union[ndarray, Sequence]) int[source]

Find the side of the vector where another vector is directed.

Both vectors must be 2D.

Parameters:
otherarray_like

Other 2D vector.

Returns:
int

1 if the other vector is to the right. 0 if the other is parallel. -1 if the other is to the left.

Raises:
ValueError

If the vectors are not 2D.

Examples

>>> from skspatial.objects import Vector
>>> vector_target = Vector([0, 1])

The vector is parallel to the target vector.

>>> vector_target.side_vector([0, 2])
0
>>> vector_target.side_vector([0, -5])
0

The vector is to the right of the target vector.

>>> vector_target.side_vector([1, 1])
1
>>> vector_target.side_vector([1, -10])
1

The vector is to the left of the target vector.

>>> vector_target.side_vector([-3, 4])
-1

The vectors are not 2D.

>>> Vector([1]).side_vector([2])
Traceback (most recent call last):
...
ValueError: The vectors must be 2D.
>>> Vector([1, 0, 0]).side_vector([1, 2, 3])
Traceback (most recent call last):
...
ValueError: The vectors must be 2D.