class Point(tuple):
Class representing a point on the 2D plane.
Class Method |
|
Constructs a point from polar coordinates. |
Method | __add__ |
Adds the coordinates of a point to another one |
Method | __div__ |
Divides the coordinates by a scalar |
Method | __getnewargs__ |
Return self as a plain tuple. Used by copy and pickle. |
Method | __mul__ |
Multiplies the coordinates by a scalar |
Method | __new__ |
Creates a new point with the given coordinates |
Method | __repr__ |
Returns a nicely formatted representation of the point |
Method | __sub__ |
Subtracts the coordinates of a point to another one |
Method | as |
Returns the polar coordinate representation of the point. |
Method | distance |
Returns the distance of the point from another one. |
Method | interpolate |
Linearly interpolates between the coordinates of this point and another one. |
Method | length |
Returns the length of the vector pointing from the origin to this point. |
Method | normalized |
Normalizes the coordinates of the point s.t. its length will be 1 after normalization. Returns the normalized point. |
Method | sq |
Returns the squared length of the vector pointing from the origin to this point. |
Method | towards |
Returns the point that is at a given distance from this point towards another one. |
Class Variable | __slots__ |
Undocumented |
Class Variable | x |
Undocumented |
Class Variable | y |
Undocumented |
Class Method | _make |
Creates a new point from a sequence or iterable |
Method | _asdict |
Returns a new dict which maps field names to their values |
Method | _replace |
Returns a new point object replacing specified fields with new values |
Class Variable | _fields |
Undocumented |
Constructs a point from polar coordinates.
radius is the distance of the point from the origin; angle is the angle between the X axis and the vector pointing to the point from the origin.
Returns the polar coordinate representation of the point.
Returns | |
the radius and the angle in a tuple. |
Returns the distance of the point from another one.
Example:
>>> p1 = Point(5, 7) >>> p2 = Point(8, 3) >>> p1.distance(p2) 5.0
Linearly interpolates between the coordinates of this point and another one.
Parameters | |
other | the other point |
ratio | the interpolation ratio between 0 and 1. Zero will return this point, 1 will return the other point. |
Normalizes the coordinates of the point s.t. its length will be 1 after normalization. Returns the normalized point.