skspatial.objects.Vector.is_parallel¶
- Vector.is_parallel(other: Union[ndarray, Sequence], **kwargs: float) bool [source]¶
Check if the vector is parallel to another.
Two nonzero vectors \(u\) and \(v\) are parallel if
\[\texttt{abs}(\texttt{cosine_similarity}(u, v)) = 1\]The zero vector is parallel to all vectors.
- Parameters
- otherarray_like
Other vector.
- kwargsdict, optional
Additional keywords passed to
math.isclose()
.
- Returns
- bool
True if the vector is parallel; false otherwise.
Examples
>>> from skspatial.objects import Vector
>>> Vector([0, 1]).is_parallel([1, 0]) False
>>> Vector([1, 1]).is_parallel([1, 1]) True
>>> Vector([-1, 5]).is_parallel([2, -10]) True
>>> Vector([1, 2, 3]).is_parallel([3, 6, 9]) True
>>> Vector([1, 2, 3, 4]).is_parallel([-2, -4, -6, -8]) True
The zero vector is parallel to all vectors.
>>> Vector([1, 2, 3]).is_parallel([0, 0, 0]) True