toio.position module

Utility functions for cube position and cube location.

class toio.position.Point(x: int = 0, y: int = 0)[source]

Bases: object

A point on 2 dimensions

x: int = 0
y: int = 0
static new() Point[source]
distance(other: Point) float[source]
flatten()[source]
__init__(x: int = 0, y: int = 0) None
class toio.position.CubeLocation(point: Point, angle: int = 0)[source]

Bases: object

A Position and angle of a cube on 2 dimensions

point: Point

Point of a cube

angle: int = 0

Angle of a cube (degree)

static new() CubeLocation[source]
get_boundary_point(target: CubeLocation) CubeLocation[source]

Obtains the point where a line passing through two points intersects the coordinate axis in the first quadrant.

flatten()[source]
__init__(point: Point, angle: int = 0) None
class toio.position.MatRect(top_left: Point, bottom_right: Point, name: str | None = None)[source]

Bases: object

A toio mat

top_left: Point

Top-left point of a mat

bottom_right: Point

Bottom-right point of a mat

name: str | None = None

Mat name

static new() MatRect[source]
center() Point[source]
__str__() str[source]

Return str(self).

flatten()[source]
__init__(top_left: Point, bottom_right: Point, name: str | None = None) None
class toio.position.CoordinateSystemABC(origin: Point = Point(x=0, y=0))[source]

Bases: object

abstract __init__(origin: Point = Point(x=0, y=0))[source]
abstract set_origin(origin: Point) None[source]
abstract to_native_angle(angle: int | float) int | float[source]
abstract to_native_x(x: int | float) int | float[source]
abstract to_native_y(y: int | float) int | float[source]
abstract from_native_angle(angle: int | float) int | float[source]
abstract from_native_x(x: int | float) int | float[source]
abstract from_native_y(y: int | float) int | float[source]
to_native_point(pos: Point) Point[source]
to_native_location(location: CubeLocation) CubeLocation[source]
from_native_point(pos: Point) Point[source]
from_native_location(location: CubeLocation) CubeLocation[source]
class toio.position.DefaultCoordinateSystem(origin: Point)[source]

Bases: CoordinateSystemABC

Default coordinate system

No coordinate transformation No angle transformation

__init__(origin: Point)[source]
set_origin(origin: Point) None[source]
to_native_angle(angle: int | float) int | float[source]
to_native_x(x: int | float) int | float[source]
to_native_y(y: int | float) int | float[source]
from_native_angle(angle: int | float) int | float[source]
from_native_x(x: int | float) int | float[source]
from_native_y(y: int | float) int | float[source]
class toio.position.RelativeCubeLocation(relative_location: CubeLocation, coordinate_system: CoordinateSystemABC)[source]

Bases: object

Location of the cube in the relative coordinate system

relative_location: CubeLocation

Relative location of a cube

coordinate_system: CoordinateSystemABC

Coordinate system

static new() RelativeCubeLocation[source]

Create new RelativeCubeLocation

Returns:

new relative cube location instance

Return type:

RelativeCubeLocation

to_absolute_point() Point[source]

Get the point of the cube on the absolute coordinate system

Returns:

Point of the absolute coordinate system

Return type:

Point

to_absolute_location() CubeLocation[source]

Get the location of the cube on the absolute coordinate system

Returns:

CubeLocation of the absolute coordinate system

Return type:

CubeLocation

from_absolute_point(abs_point: Point) Point[source]

Set the relative point from the absolute point

Parameters:

abs_point (CubePoint) – Point on the absolute coordinate system

Returns:

Point on the relative coordinate system

Return type:

Point

from_absolute_location(abs_location: CubeLocation) CubeLocation[source]

Set the relative location from the absolute location

Parameters:

abs_location (CubeLocation) – Location on the absolute coordinate system

Returns:

Location on the relative coordinate system

Return type:

CubeLocation

change_coordinate_system(new_coordinate_system: CoordinateSystemABC) None[source]

Change the coordinate system The location is updated to the coordinates in the new coordinate system

__init__(relative_location: CubeLocation, coordinate_system: CoordinateSystemABC) None
class toio.position.ToioMat[source]

Bases: object

Definitions of official toio mats

ToioCollectionMatRing = MatRect(top_left=Point(x=45, y=45), bottom_right=Point(x=455, y=455), name='Toio Collection (ring)')
ToioCollectionMatColoredTiles = MatRect(top_left=Point(x=545, y=45), bottom_right=Point(x=955, y=455), name='Toio Collection (colored tiles)')
PicotonsPlayMatFront = MatRect(top_left=Point(x=59, y=2088), bottom_right=Point(x=437, y=2285), name='Picotons (front)')
PicotonsPlayMatBack = MatRect(top_left=Point(x=59, y=2303), bottom_right=Point(x=437, y=2499), name='Picotons (back)')
PicotonsControlMat = MatRect(top_left=Point(x=764, y=2093), bottom_right=Point(x=953, y=2290), name='Picotons (control)')
PicotonsAutoplayMat = MatRect(top_left=Point(x=554, y=2093), bottom_right=Point(x=742, y=2290), name='Picotons (auto play)')
SimpleMat = MatRect(top_left=Point(x=98, y=142), bottom_right=Point(x=402, y=358), name='Simple mat')
GesundroidMat = MatRect(top_left=Point(x=1050, y=45), bottom_right=Point(x=1460, y=455), name='Gesundroid')
mats = (MatRect(top_left=Point(x=45, y=45), bottom_right=Point(x=455, y=455), name='Toio Collection (ring)'), MatRect(top_left=Point(x=545, y=45), bottom_right=Point(x=955, y=455), name='Toio Collection (colored tiles)'), MatRect(top_left=Point(x=59, y=2088), bottom_right=Point(x=437, y=2285), name='Picotons (front)'), MatRect(top_left=Point(x=59, y=2303), bottom_right=Point(x=437, y=2499), name='Picotons (back)'), MatRect(top_left=Point(x=764, y=2093), bottom_right=Point(x=953, y=2290), name='Picotons (control)'), MatRect(top_left=Point(x=554, y=2093), bottom_right=Point(x=742, y=2290), name='Picotons (auto play)'), MatRect(top_left=Point(x=98, y=142), bottom_right=Point(x=402, y=358), name='Simple mat'), MatRect(top_left=Point(x=1050, y=45), bottom_right=Point(x=1460, y=455), name='Gesundroid'))