Point module

class Point.Point(x, y)

Bases: object

Point storing x and y coordinates with associated distance functions.

Attributes
xfloat

The point’s x value.

yfloat

The point’s y value.

Methods

set_x(x_new)

Sets the x value of the point.

set_y(y_new)

Sets the y value of the point

get_x()

Gets the x value of the point

get_y()

Gets the y value of the point

simple_distance(point)

Finds the simple distance between this point and another point.

manhattan_distance(point)

Finds the manhattan distance between this point and another point.

get()

Return the point coordinates in tuple form.

Returns
tuple

A tuple in the form (x, y)

get_x()

Gets the x value of the point

Returns
float

The x value of the point

get_y()

Gets the y value of the point

Returns
float

The y value of the point

manhattan_distance(point)

Finds the manhattan distance between this point and another point, which is the total displacement in x and y.

Parameters
pointPoint

The point to find the distance between.

Returns
float

The manhattan distance between this point and another point.

set(x_new, y_new)

Move the point by assigning a new x and y coordinates.

Parameters
x_newfloat

The new x coordinate for this point

y_newfloat

Thew new y coordinate for this point

set_x(x_new)

Sets the value of x for a point.

Parameters
x_newfloat

The new x value of the point.

set_y(y_new)

Sets the value of y for a point.

Parameters
y_new

The new y value of the point.

simple_distance(point)

Finds the distance between this point and another point.

Parameters
pointPoint

The point to find the distance between.

Returns
float

The simple distance between this point and another point.

Notes

\[d = \sqrt{(x_2 - x_1) + (y_2 - y_1)}\]
static to_list(points)

Returns a list of lists given a list of Points i.e. [Point(1, 2), Point(3, 4), Point(5, 6)] to [[1, 2], [3, 4], [5, 6]]

Parameters
pointslist of Points

The points in list of Points form

Returns
List of lists

The list of lists

static to_point(coordinate_list)

Given a list [x, y], return the associated Point

Parameters
coordinate_listList of float

A list of the form [x, y]

Returns
Point :

The Point with x-coordinate x and y-coordinate y

static to_points(points)

Returns a list of Points given a list of lists i.e. [[1, 2], [3, 4], [5, 6]] to [Point(1, 2), Point(3, 4), Point(5, 6)]

Parameters
pointslist of lists

The points in list of list form

Returns
List of points

The list of points