Skip to main content

LIRPy

Largest Interior Rectangle for Python

This was originally made for a stupid Minecraft project for the purpose of making as few Baritone selections as possible when designating a cylinder, but it should work in any other context as well.

I also hate numpy with a passion for mysterious reasons I can't even explain to myself. Therefore, this project doesn't use it.

Background

When I'm not breaking games for work, I tend to play engineering games, and one of the first such games I got into was Minecraft. I play it off and on, and I tend to get into mega-projects, which often end up with me getting bored and having a bot called Baritone do most of the work.

I needed a tool to generate Baritone selection AABBs (which are defined by opposing corner coordinates) for cylinders of arbitrary radius and depth. The easiest possible way would be to generate selections for every single voxel column. This would not be practical due to the sheer number of selections needing to be made.

So, after doing some research, I determined what I needed was an axis-aligned largest interior rectangle library.

Other Options

Other solutions I've looked at:

So I made my own system, with blackjack and classy sex workers.

Caveats

I am no mathematician, so this is nowhere within ten light-years of optimized, and there are probably a dozen papers dense with calculus describing new and exciting ways of doing that. I didn't take calculus in uni.

This works well enough for my purposes, but PRs with improvements are absolutely welcome.

Installation

Requires Python >= 3.10

pip install lirpy

Development

Requires Python >= 3.10 and poetry

Example:

$ python -m lirpy -472 58 570 -r 7 -d 1 --dump-steps
Center: -472 58 570
Radius: 7
Depth: 0
Along axis: -Y
Step 0:
       █       
    ███████    
   █████████   
  ███████████  
 █████████████ 
 █████████████ 
 █████████████ 
███████████████
 █████████████ 
 █████████████ 
 █████████████ 
  ███████████  
   █████████   
    ███████    
       █       
Step 1:
       █       
    ███████    
               
  █         █  
 ██         ██ 
 ██         ██ 
 ██         ██ 
███         ███
 ██         ██ 
 ██         ██ 
 ██         ██ 
  █         █  
               
    ███████    
       █       
Step 2:
       █       
    ███████    
               
  █         █  
            ██ 
            ██ 
            ██ 
█           ███
            ██ 
            ██ 
            ██ 
  █         █  
               
    ███████    
       █       
Step 3:
       █       
    ███████    
               
  █         █  
               
               
               
█             █
               
               
               
  █         █  
               
    ███████    
       █       
Step 4:
       █       
               
               
  █         █  
               
               
               
█             █
               
               
               
  █         █  
               
    ███████    
       █       
Step 5:
       █       
               
               
  █         █  
               
               
               
█             █
               
               
               
  █         █  
               
               
       █       
Step 6:
               
               
               
  █         █  
               
               
               
█             █
               
               
               
  █         █  
               
               
       █       
Step 7:
               
               
               
            █  
               
               
               
█             █
               
               
               
  █         █  
               
               
       █       
Step 8:
               
               
               
               
               
               
               
█             █
               
               
               
  █         █  
               
               
       █       
Step 9:
               
               
               
               
               
               
               
              █
               
               
               
  █         █  
               
               
       █       
Step 10:
               
               
               
               
               
               
               
               
               
               
               
  █         █  
               
               
       █       
Step 11:
               
               
               
               
               
               
               
               
               
               
               
            █  
               
               
       █       
Step 12:
               
               
               
               
               
               
               
               
               
               
               
               
               
               
       █       
Step 13:
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
#sel clear
#sel 1 -462 58 579
#sel 2 -454 58 589
#sel 1 -464 58 581
#sel 2 -463 58 587
#sel 1 -453 58 581
#sel 2 -452 58 587
#sel 1 -461 58 578
#sel 2 -455 58 578
#sel 1 -461 58 590
#sel 2 -455 58 590
#sel 1 -458 58 577
#sel 2 -458 58 577
#sel 1 -463 58 580
#sel 2 -463 58 580
#sel 1 -453 58 580
#sel 2 -453 58 580
#sel 1 -465 58 584
#sel 2 -465 58 584
#sel 1 -451 58 584
#sel 2 -451 58 584
#sel 1 -463 58 588
#sel 2 -463 58 588
#sel 1 -453 58 588
#sel 2 -453 58 588
#sel 1 -458 58 591
#sel 2 -458 58 591

Metadata

Release files for lirpy 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lirpy 0.0.1
File Size Uploaded Provenance
lirpy-0.0.1.tar.gz 5.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for lirpy 0.0.1
File Interpreter ABI Platform
lirpy-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.0 kB

Release files / lirpy-0.0.1.tar.gz

Download URL lirpy-0.0.1.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7d7ff52f00c95d1fe132ab5257fe415dd85df5b69591853f9b7a93aae727ea22
BLAKE2b-256 checksum
How to use checksums
bc23456d8d39e74e015248d1de6092299ecc4b6bbbb652c18512cedc4cb6750f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / lirpy-0.0.1-py3-none-any.whl

Download URL lirpy-0.0.1-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
26653752b813b28562d25957e613fa13a957770ad3c1e44c34a43aecc5c7bfe2
BLAKE2b-256 checksum
How to use checksums
4183cab981b5f808aaefb96326491f8991f0f16deb11b5544de59a9c5e7386fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Security for lirpy 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page