Skip to main content

Find points that make an equally spaced row on a 2D plane

Project description

Find points that make an equally spaced row on a 2D plane.

Fast and simple, works by walking in 4 directions (1,0 0,1 1,1 1,-1) to n steps from a point and checking if the next point exists, until the required row size is reached.

Example usage:
import rowfind
coords = [
(0, 0), (1, 1), (2, 2), (3, 3), (3, 4),
(3, 5), (12, 3), (12, 4), (11, 3), (11, 2),
(11, 1), (10, 3), (5, 3), (6, 2), (7, 1),
(7, 0), (8, 1), (8, 5), (9, 5)
]
row_size = 3
steps = 1
rows = rowfind.find_rows(coords, row_size, steps)

# Where `coords` is a tuple/list of (x, y) coordinates,
# `row_size` is the length of rows to find and `steps`
# is the number of steps to walk before checking a point.
#
# The `steps` parameter can be a single integer, a
# tuple/list of integers or None. If None, it tries all
# possible steps that fit into the plane's bounds.
#
# The return value is a tuple of tuples, where each
# tuple is a group of points that form a row.

# To visualize the results:
print("\n".join(str(row) for row in rows))
graph = rowfind.draw_graph(coords, rows)
print(graph)

Output:
((5, 3), (6, 2), (7, 1))
((11, 1), (11, 2), (11, 3))
((3, 3), (3, 4), (3, 5))
((0, 0), (1, 1), (2, 2))
((1, 1), (2, 2), (3, 3))
((10, 3), (11, 3), (12, 3))
. . . X . . . . O O . . .
. . . X . . . . . . . . O
. . . X . X . . . . X X X
. . X . . . X . . . . X .
. X . . . . . X O . . X .
X . . . . . . O . . . . .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rowfind-0.1.3.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

rowfind-0.1.3-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file rowfind-0.1.3.tar.gz.

File metadata

  • Download URL: rowfind-0.1.3.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for rowfind-0.1.3.tar.gz
Algorithm Hash digest
SHA256 853c695d06beb468044fc486fbc92fcd99df34c6cf8ad4843a641a877da06c43
MD5 bfaf1797005d4f9cf4149daf7a8b5e80
BLAKE2b-256 5ad745f60490b1736cab986ffe48701e112929c1eac9058f2e6b4ffaabd6e05e

See more details on using hashes here.

File details

Details for the file rowfind-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: rowfind-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for rowfind-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7a9f66154f4aba60f9403f11faf13f6e2e814034062efc6c87fe3d20af8f0cf9
MD5 781a0ef2bd4e70fe7a712ebc779b417c
BLAKE2b-256 96d61c297c6d4d99376d6231313348cae367463b41632a73431f8019884bf7a8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page