skspatial.objects.Vector.different_direction¶
- Vector.different_direction(**kwargs: float) Vector [source]¶
Return a simple vector that is in a different direction.
This is useful for finding a vector perpendicular to the original, by taking the cross product of the original with the one in a different direction.
- Parameters:
- kwargsdict, optional
Additional keywords passed to
Vector.is_zero()
andVector.is_parallel()
.Vector.is_zero()
is used to ensure the input vector is not the zero vector, andVector.is_parallel()
is used to ensure the new vector is not parallel to the input.
- Returns:
- Vector
A unit vector in a different direction from the original.
- Raises:
- ValueError
If the vector is the zero vector.
Examples
>>> from skspatial.objects import Vector
>>> Vector([1]).different_direction() Vector([-1]) >>> Vector([100]).different_direction() Vector([-1]) >>> Vector([-100]).different_direction() Vector([1]) >>> Vector([1, 0]).different_direction() Vector([0., 1.]) >>> Vector([1, 1]).different_direction() Vector([1., 0.]) >>> Vector([1, 1, 1, 1]).different_direction() Vector([1., 0., 0., 0.])