Package pyj2d :: Module vector :: Class Vector2

Class Vector2

object --+
         |
        Vector2

Vector2 - 2-dimensional vector.
Instance Methods
 
__init__(self, *args, **kwargs)
x.__init__(...) initializes x; see help(type(x)) for signature
 
__str__(self)
str(x)
 
__repr__(self)
repr(x)
 
__getitem__(self, index)
 
__setitem__(self, index, val)
 
__delitem__(self, index)
 
__getslice__(self, start, stop)
 
__setslice__(self, lower, upper, val)
 
__iter__(self)
 
__len__(self)
 
__bool__(self)
 
__nonzero__(self)
 
dot(self, vector)
Return dot product with other vector.
 
cross(self, vector)
Return cross product with other vector.
 
magnitude(self)
Return magnitude of vector.
 
magnitude_squared(self)
Return squared magnitude of vector.
 
length(self)
Return length of vector.
 
length_squared(self)
Return squared length of vector.
 
normalize(self)
Return normalized vector.
 
normalize_ip(self)
Normalized this vector.
 
is_normalized(self)
Check whether vector is normalized.
 
scale_to_length(self, length)
Scale vector to length.
 
reflect(self, vector)
Return reflected vector at given vector.
 
reflect_ip(self, vector)
Derive reflected vector at given vector in place.
 
distance_to(self, vector)
Return distance to given vector.
 
distance_squared_to(self, vector)
Return squared distance to given vector.
 
lerp(self, vector, t)
Return vector linear interpolated by t to the given vector.
 
slerp(self, vector, t)
Return vector spherical interpolated by t to the given vector.
 
elementwise(self)
Elementwice operation.
 
rotate(self, angle)
Return vector rotated by angle in degrees.
 
rotate_rad(self, angle)
Return vector rotated by angle in radians.
 
rotate_ip(self, angle)
Rotate vector by angle in degrees.
 
rotate_ip_rad(self, angle)
Rotate vector by angle in radians.
 
angle_to(self, vector)
Return angle to given vector.
 
as_polar(self)
Return radial distance and azimuthal angle.
 
from_polar(self, coordinate)
Set vector with polar coordinate tuple.
 
update(self, *args, **kwargs)
Update vector.
 
__pos__(self)
 
__neg__(self)
 
__add__(self, other)
 
__sub__(self, other)
 
__mul__(self, other)
 
__div__(self, other)
 
__truediv__(self, other)
 
__floordiv__(self, other)
 
__eq__(self, other)
 
__ne__(self, other)
 
__gt__(self, other)
 
__ge__(self, other)
 
__lt__(self, other)
 
__le__(self, other)
 
__radd__(self, other)
 
__rsub__(self, other)
 
__rmul__(self, other)
 
__rdiv__(self, other)
 
__rtruediv__(self, other)
 
__rfloordiv__(self, other)
 
__iadd__(self, other)
 
__isub__(self, other)
 
__imul__(self, other)
 
__idiv__(self, other)
 
__itruediv__(self, other)
 
__ifloordiv__(self, other)

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Class Variables
  x = property(_get_x, _set_x, _del_x)
  y = property(_get_y, _set_y, _del_y)
Properties

Inherited from object: __class__

Method Details

__init__(self, *args, **kwargs)
(Constructor)

 
x.__init__(...) initializes x; see help(type(x)) for signature
Overrides: object.__init__
(inherited documentation)

__str__(self)
(Informal representation operator)

 
str(x)
Overrides: object.__str__
(inherited documentation)

__repr__(self)
(Representation operator)

 
repr(x)
Overrides: object.__repr__
(inherited documentation)