This module contain the Vec2d class that is used in all of pymunk when a vector is needed.
The Vec2d class is used almost everywhere in pymunk for 2d coordinates and vectors, for example to define gravity vector in a space. However, pymunk is smart enough to convert tuples or tuple like objects to Vec2ds so you usually do not need to explcitily do conversions if you happen to have a tuple:
>>> import pymunk
>>> space = pymunk.Space()
>>> print space.gravity
Vec2d(0.0, 0.0)
>>> space.gravity = 3,5
>>> print space.gravity
Vec2d(3.0, 5.0)
>>> space.gravity += 2,6
>>> print space.gravity
Vec2d(5.0, 11.0)
Bases: _ctypes.Structure
2d vector class, supports vector and scalar operators, and also provides some high level functions.
Gets or sets the angle (in radians) of a vector
Gets or sets the angle (in degrees) of a vector
Returns: | The cross product |
---|
Returns: | The dot product |
---|
Get the angle between the vector and the other in radians
Returns: | The angle |
---|
Get the angle between the vector and the other in degrees
Returns: | The angle (in degrees) |
---|
The squared distance between the vector and other vector It is more efficent to use this method than to call get_distance() first and then do a sqrt() on the result.
Returns: | The squared distance |
---|
Get the squared length of the vector. It is more efficent to use this method instead of first call get_length() or access .length and then do a sqrt().
Returns: | The squared length |
---|
Return the x and y values of this vector as ints
Gets or sets the magnitude of the vector
Normalize the vector and return its length before the normalization
Returns: | The length before the normalization |
---|
Get a normalized copy of the vector Note: This function will return 0 if the length of the vector is 0.
Returns: | A normalized vector |
---|
Create and return a new vector by rotating this vector by angle_radians radians.
Returns: | Rotated vector |
---|
Create and return a new vector by rotating this vector by angle_degrees degrees.
Returns: | Rotade vector |
---|
Structure/Union member
Structure/Union member