Skip to content

Add Tkinter 3D canvas with semi-transparent stiffened cylinder visualization#208

Draft
audunarn wants to merge 11 commits into
masterfrom
vibe/tkinter-3d-drawing-dcb7a7
Draft

Add Tkinter 3D canvas with semi-transparent stiffened cylinder visualization#208
audunarn wants to merge 11 commits into
masterfrom
vibe/tkinter-3d-drawing-dcb7a7

Conversation

@audunarn

Copy link
Copy Markdown
Owner

Summary

  • Add pure Tkinter 3D canvas implementation as alternative to matplotlib 3D drawing
  • Visualize single semi-transparent stiffened cylinder with inside structure
  • Color-code stiffeners by plate thickness with legend

Features Implemented

  • Tkinter3DCanvas: Complete 3D rendering on Tkinter Canvas with camera, projection, and mouse interaction
  • Semi-transparent cylinder shell: Opacity=0.4 to see internal structure
  • Inside longitudinal stiffeners: 8 stiffeners with alternating thicknesses (10mm/15mm, 20mm/25mm)
  • Inside ring girders: 4 girders with alternating thicknesses (15mm/20mm, 25mm/30mm)
  • Color coding: Red gradient from light (#ffcccc) to dark (#ff0000) based on plate thickness
  • Legend frame: Shows thickness-color mapping on the right side
  • Camera controls: Fit, Reset, Top, Side, Front, Iso view buttons
  • Mouse interaction: Drag to orbit, wheel to zoom

Thickness Color Scheme

  • 10mm: #ffcccc (light red)
  • 15mm: #ff9999 (medium-light red)
  • 20mm: #ff6666 (medium red)
  • 25mm: #ff3333 (dark red)
  • 30mm: #ff0000 (solid red)

Usage

Run the demo:

python anystruct/tkinter_3d_canvas.py

Technical Details

  • No external dependencies (pure Python + Tkinter)
  • Backface culling for performance
  • Adaptive detail levels during interaction
  • Depth sorting for correct rendering order
  • Geometry caching for efficient redraws

mistral-vibe and others added 11 commits June 15, 2026 08:17
…tion

This commit adds a pure Tkinter-based 3D drawing module as an alternative
to matplotlib 3D drawing. The implementation includes:

- Point3D: 3D point class with vector operations
- Camera3D: 3D camera with orbit controls and perspective projection
- Tkinter3DCanvas: Canvas widget supporting 3D drawing primitives
- Drawing functions for cylinders, longitudinal stiffeners, and ring stiffeners
- Mouse interaction for rotation and zoom
- Demo function showing a stiffened cylinder with 8 longitudinal and 4 ring stiffeners

Two versions are provided:
- tkinter_3d_canvas.py: Uses numpy for matrix operations (faster)
- tkinter_3d_canvas_simple.py: Pure Python implementation without dependencies

To run the demo:
  python anystruct/tkinter_3d_canvas_simple.py

Mouse controls:
- Left-click and drag: Rotate camera
- Scroll wheel: Zoom in/out
- Buttons: Reset view, Top/Side/Iso views

Co-authored-by: audunarn <audunarn@users.noreply.github.com>
Co-authored-by: audunarn <audunarn@users.noreply.github.com>
Co-authored-by: audunarn <audunarn@users.noreply.github.com>
…window

Co-authored-by: audunarn <audunarn@users.noreply.github.com>
Co-authored-by: audunarn <audunarn@users.noreply.github.com>
…in front have negative z

Co-authored-by: audunarn <audunarn@users.noreply.github.com>
…implify demo

Co-authored-by: audunarn <audunarn@users.noreply.github.com>
Co-authored-by: audunarn <audunarn@users.noreply.github.com>
This implementation includes:
- Proper camera basis calculation with world_to_camera transformation
- Caching of primitives for performance
- Backface culling
- Depth sorting (painter's algorithm)
- Adaptive detail levels (fast vs full quality)
- Support for cylinders, longitudinal stiffeners, and ring stiffeners
- Mouse interaction: drag to orbit, wheel to zoom
- Camera controls: fit, reset, top, side, front, iso views
- Automatic scene fitting

Co-authored-by: audunarn <audunarn@users.noreply.github.com>
…tions

The demo now shows 8 different configurations:
1. Cylinder with outside stiffeners (opaque)
2. Cylinder with inside stiffeners (opaque)
3. Cylinder with outside stiffeners (transparent)
4. Cylinder with inside stiffeners (transparent)
5. Cylinder with outside girders (ring stiffeners)
6. Cylinder with inside girders (ring stiffeners)
7. Cylinder with both outside stiffeners and girders
8. Cylinder with both inside stiffeners and girders

Examples are arranged in a grid with descriptive labels.

Co-authored-by: audunarn <audunarn@users.noreply.github.com>
…ization

- Implement pure Tkinter 3D canvas with camera, projection, and rendering
- Add semi-transparent cylinder shell (opacity=0.4) to see inside structure
- Add 8 longitudinal stiffeners inside with alternating thicknesses (10mm/15mm, 20mm/25mm)
- Add 4 ring girders inside with alternating thicknesses (15mm/20mm, 25mm/30mm)
- Color-code stiffeners by plate thickness using red gradient
- Add legend frame showing thickness-color mapping
- Support mouse interaction: drag to orbit, wheel to zoom
- Include control buttons: Fit, Reset, Top, Side, Front, Iso views

Thickness color scheme:
- 10mm: #ffcccc (light red)
- 15mm: #ff9999 (medium-light red)
- 20mm: #ff6666 (medium red)
- 25mm: #ff3333 (dark red)
- 30mm: #ff0000 (solid red)

Co-authored-by: audunarn <audunarn@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants