# OOF2: The Manual

## Name

Point — Python point class

## Python Synopsis

import oof2.common.primitives

class Point:`def __init__(self, x, y)`

`def __getitem__(self, i)`

`def __setitem__(self, i, val)`

`def __mul__(self, other)`

`def __rmul__(self, other)`

`def __div__(self, factor)`

`def __add__(self, other)`

`def __sub__(self, other)`

`def cross(self, other)`

`def __cmp__(self, other)`

`def __lt__(self, other)`

`def __gt__(self, other)`

`def __eq__(self, other)`

`def __ne__(self, other)`

`def __hash__(self)`

## Description

`Point`

is a pure Python class for
representing points on a plane. It is equivalent to the C++
`Coord`

class. The reason for having two classes is that there are
situations in which it's desirable to avoid the overhead of
calling C++ functions from Python, and in which the extra
memory required to store a Python object is not important.

## Methods

`__getitem__(i), __setitem__(i, val)`

A single component can be extracted with
`__getitem__`

and set with
`__setitem__`

. `point[0]`

is the x component and `point[1]`

is the y
component.

`__mul__, __add__, etc.`

The standard arithmetic operators are defined for
`Points`

. They can be added or
subtracted from one another, and multiplied or divided by
integers or floating point numbers. Multiplying two
`Points`

produces their dot product.