python-igraph manual

For using igraph from Python

   Home       Trees       Indices       Help   
Package igraph :: Package drawing :: Module utils :: Class Point
[hide private]

Class Point

source code

object --+    
         |    
     tuple --+
             |
            Point

Class representing a point on the 2D plane.

Instance Methods [hide private]
 
__repr__(self)
Returns a nicely formatted representation of the point
source code
 
_asdict(self)
Returns a new dict which maps field names to their values
source code
 
_replace(self, **kwds)
Returns a new point object replacing specified fields with new values
source code
 
__getnewargs__(self)
Return self as a plain tuple.
source code
 
__add__(self, other)
Adds the coordinates of a point to another one
source code
 
__sub__(self, other)
Subtracts the coordinates of a point to another one
source code
 
__mul__(self, scalar)
Multiplies the coordinates by a scalar
source code
 
__rmul__(self, scalar)
Multiplies the coordinates by a scalar
source code
 
__div__(self, scalar)
Divides the coordinates by a scalar
source code
 
as_polar(self)
Returns the polar coordinate representation of the point.
source code
 
distance(self, other)
Returns the distance of the point from another one.
source code
 
interpolate(self, other, ratio=0.5)
Linearly interpolates between the coordinates of this point and another one.
source code
 
length(self)
Returns the length of the vector pointing from the origin to this point.
source code
 
normalized(self)
Normalizes the coordinates of the point s.t.
source code
 
sq_length(self)
Returns the squared length of the vector pointing from the origin to this point.
source code
 
towards(self, other, distance=0)
Returns the point that is at a given distance from this point towards another one.
source code

Inherited from tuple: __contains__, __eq__, __ge__, __getattribute__, __getitem__, __getslice__, __gt__, __hash__, __iter__, __le__, __len__, __lt__, __ne__, count, index

Inherited from object: __delattr__, __format__, __init__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]
 
_make(cls, iterable, new=<built-in method __new__ of type object at 0x1022a7510>, len=<built-in function len>)
Creates a new point from a sequence or iterable
source code
 
FromPolar(cls, radius, angle)
Constructs a point from polar coordinates.
source code
Static Methods [hide private]
a new object with type S, a subtype of T
__new__(cls, x, y)
Creates a new point with the given coordinates
source code
Class Variables [hide private]
  _fields = ('x', 'y')
Properties [hide private]
  x
Alias for field number 0
  y
Alias for field number 1

Inherited from object: __class__

Method Details [hide private]

__new__(cls, x, y)
Static Method

source code 

Creates a new point with the given coordinates

Returns: a new object with type S, a subtype of T
Overrides: object.__new__

__repr__(self)
(Representation operator)

source code 

Returns a nicely formatted representation of the point

Overrides: object.__repr__

__getnewargs__(self)

source code 

Return self as a plain tuple. Used by copy and pickle.

Overrides: tuple.__getnewargs__

__add__(self, other)
(Addition operator)

source code 

Adds the coordinates of a point to another one

Overrides: tuple.__add__

__mul__(self, scalar)

source code 

Multiplies the coordinates by a scalar

Overrides: tuple.__mul__

__rmul__(self, scalar)

source code 

Multiplies the coordinates by a scalar

Overrides: tuple.__rmul__

as_polar(self)

source code 

Returns the polar coordinate representation of the point.

Returns:
the radius and the angle in a tuple.

distance(self, other)

source code 

Returns the distance of the point from another one.

Example:

>>> p1 = Point(5, 7)
>>> p2 = Point(8, 3)
>>> p1.distance(p2)
5.0

interpolate(self, other, ratio=0.5)

source code 

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.

normalized(self)

source code 

Normalizes the coordinates of the point s.t. its length will be 1 after normalization. Returns the normalized point.

FromPolar(cls, radius, angle)
Class Method

source code 

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.


Property Details [hide private]

x

Alias for field number 0

Get Method:
<operator.itemgetter object at 0x103272650>

y

Alias for field number 1

Get Method:
<operator.itemgetter object at 0x103272690>

   Home       Trees       Indices       Help