No description
  • Nim 96.5%
  • Python 3.5%
Find a file
kai 7c33743034 revert d4fad03d17
revert revert 675ab04f9c

revert Delete CLAUDE.md
2026-07-23 14:39:41 +10:00
reports initial import 2026-03-08 09:12:10 +10:00
src initial import 2026-03-08 09:12:10 +10:00
example_2point.toml initial import 2026-03-08 09:12:10 +10:00
example_3point.toml initial import 2026-03-08 09:12:10 +10:00
example_6point.toml initial import 2026-03-08 09:12:10 +10:00
example_8point.toml initial import 2026-03-08 09:12:10 +10:00
example_asymmetric.toml initial import 2026-03-08 09:12:10 +10:00
example_input.toml initial import 2026-03-08 09:12:10 +10:00
generate_test_files.py initial import 2026-03-08 09:12:10 +10:00
imgui.ini initial import 2026-03-08 09:12:10 +10:00
nim.cfg initial import 2026-03-08 09:12:10 +10:00
README.md initial import 2026-03-08 09:12:10 +10:00
sling initial import 2026-03-08 09:12:10 +10:00
sling.nimble initial import 2026-03-08 09:12:10 +10:00
sling_calc.log initial import 2026-03-08 09:12:10 +10:00
Sling_length_test_data_20251021.csv initial import 2026-03-08 09:12:10 +10:00
stay_8pt.toml initial import 2026-03-08 09:12:10 +10:00
test_case_001.toml initial import 2026-03-08 09:12:10 +10:00
test_case_002.toml initial import 2026-03-08 09:12:10 +10:00
test_case_003.toml initial import 2026-03-08 09:12:10 +10:00
test_case_004.toml initial import 2026-03-08 09:12:10 +10:00
test_case_005.toml initial import 2026-03-08 09:12:10 +10:00
test_case_006.toml initial import 2026-03-08 09:12:10 +10:00
test_case_007.toml initial import 2026-03-08 09:12:10 +10:00
test_case_008.toml initial import 2026-03-08 09:12:10 +10:00
test_case_009.toml initial import 2026-03-08 09:12:10 +10:00
test_case_010.toml initial import 2026-03-08 09:12:10 +10:00
test_case_011.toml initial import 2026-03-08 09:12:10 +10:00
test_case_012.toml initial import 2026-03-08 09:12:10 +10:00
test_case_013.toml initial import 2026-03-08 09:12:10 +10:00
test_case_014.toml initial import 2026-03-08 09:12:10 +10:00
test_case_015.toml initial import 2026-03-08 09:12:10 +10:00
test_case_016.toml initial import 2026-03-08 09:12:10 +10:00
test_case_017.toml initial import 2026-03-08 09:12:10 +10:00
test_case_018.toml initial import 2026-03-08 09:12:10 +10:00
test_case_019.toml initial import 2026-03-08 09:12:10 +10:00
test_case_020.toml initial import 2026-03-08 09:12:10 +10:00
test_case_021.toml initial import 2026-03-08 09:12:10 +10:00
test_case_022.toml initial import 2026-03-08 09:12:10 +10:00
test_case_023.toml initial import 2026-03-08 09:12:10 +10:00
test_case_024.toml initial import 2026-03-08 09:12:10 +10:00
test_case_025.toml initial import 2026-03-08 09:12:10 +10:00
test_cogval.nim initial import 2026-03-08 09:12:10 +10:00
VIEWPORT.md initial import 2026-03-08 09:12:10 +10:00

Sling Length Calculator

A Nim-based CLI tool for calculating required sling lengths for lifting operations.

Phase 1 - Current Features

  • Calculate sling lengths based on COG (Center of Gravity) and pick point locations
  • Support for variable pick points (minimum 2, typically 2-8, no upper limit)
  • Works with any lift configuration: 2-point beams, 3-point triangular, 4-point rectangular, 6-point hexagonal, 8-point octagonal, etc.
  • TOML input file format
  • Configurable minimum sling angle
  • Three logging levels: error, warn, info
  • Automatic logging to file with all operations
  • 3D CAD-style viewport visualization with OpenGL (see VIEWPORT.md)
  • Z-up coordinate system (CAD/engineering convention)
  • Professional PDF report generation with LaTeX (engineering-grade documentation)

Installation

  1. Ensure you have Nim installed (>= 2.0.8)
  2. Install dependencies:
    nimble install
    

Usage

Basic usage:

./sling --inputFile=example_input.toml

With 3D viewport visualization:

./sling --inputFile=example_input.toml --view

With PDF report generation:

./sling --inputFile=example_input.toml --report

With custom report output directory:

./sling --inputFile=example_input.toml --report --reportPath=./my_reports

With custom log level:

./sling --inputFile=example_input.toml --logLevel=error

Available log levels:

  • error: Only errors printed to console
  • warn: Warnings and errors printed to console
  • info: All messages printed to console (default)

All logs are always written to sling_calc.log regardless of console log level.

Input File Format

Example TOML file:

[project]
name = "Lift Operation XYZ"
date = "2025-10-17"
engineer = "John Doe"

[parameters]
min_sling_angle = 45.0       # Minimum allowable sling angle in degrees

[cog]
x = 1.5
y = 1.2
z = 0.5

[[pick_points]]
name = "P1"
x = 0.0
y = 0.0
z = 1.0

[[pick_points]]
name = "P2"
x = 3.0
y = 0.0
z = 1.0

[[pick_points]]
name = "P3"
x = 3.0
y = 2.5
z = 1.0

[[pick_points]]
name = "P4"
x = 0.0
y = 2.5
z = 1.0

Example Files

The repository includes example files demonstrating different lift configurations:

  • example_input.toml: 4-point symmetrical rectangular lift (COG at center)
  • example_asymmetric.toml: 4-point asymmetrical lift (offset COG)
  • example_2point.toml: 2-point beam lift (simple spreader beam)
  • example_3point.toml: 3-point triangular lift
  • example_6point.toml: 6-point hexagonal lift (for large circular loads)
  • example_8point.toml: 8-point octagonal lift (for very large/heavy loads)

Test any configuration:

./sling --inputFile=example_6point.toml
./sling --inputFile=example_3point.toml --view  # with 3D visualization

Output

The program outputs to console:

  • Hook point coordinates (positioned above COG)
  • Calculated sling length for each pick point
  • Horizontal distance from COG to each pick point
  • Sling angle from vertical for each sling

PDF Reports

When using the --report flag, the program generates professional engineering-grade PDF reports containing:

  • Project Information: Name, date, engineer, number of pick points, minimum angle
  • Coordinate System: CAD/engineering convention documentation (Z-up)
  • Input Parameters: Tables with COG position and all pick point coordinates
  • Calculation Methodology: Step-by-step mathematical formulas with LaTeX formatting
  • Results: Hook point location, sling lengths and angles with color-coded status (green = OK, red = FAIL)
  • Summary: Pass/fail status, angle ranges, hook height, and safety notes

Requirements: pdflatex must be installed and available in PATH. On Arch Linux: sudo pacman -S texlive-basic texlive-latex

Reports are saved to ./reports/ by default (customizable with --reportPath). Auxiliary files (.tex, .aux, .log) are automatically cleaned up after PDF generation.

Phase 2 (Planned)

Future enhancements:

  • Tension and strength calculations
  • Safety checks (COG validation, tipping hazard detection)
  • Standard sling matching (fixed vs adjustable)
  • 3D graphical diagrams in PDF reports
  • Additional CLI flags for parameter overrides

Project Structure

src/
├── sling.nim                 # Main entry point
└── sling_calc/
    ├── types.nim             # Data structures (Pt type with labels)
    ├── logger.nim            # Logging system
    ├── input_parser.nim      # TOML parsing with validation
    ├── calculator.nim        # Core sling calculations (variable pick points)
    ├── viewport.nim          # 3D OpenGL/ImGui visualization
    └── latex_report.nim      # Professional PDF report generation

License

MIT