hazy-frames 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg xmlns="http://www.w3.org/2000/svg" width="99" height="20">
3
+ <linearGradient id="b" x2="0" y2="100%">
4
+ <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
5
+ <stop offset="1" stop-opacity=".1"/>
6
+ </linearGradient>
7
+ <mask id="a">
8
+ <rect width="99" height="20" rx="3" fill="#fff"/>
9
+ </mask>
10
+ <g mask="url(#a)">
11
+ <path fill="#555" d="M0 0h63v20H0z"/>
12
+ <path fill="#9f9f9f" d="M63 0h36v20H63z"/>
13
+ <path fill="url(#b)" d="M0 0h99v20H0z"/>
14
+ </g>
15
+ <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
16
+ <text x="31.5" y="15" fill="#010101" fill-opacity=".3">coverage</text>
17
+ <text x="31.5" y="14">coverage</text>
18
+ <text x="80" y="15" fill="#010101" fill-opacity=".3">97.1%</text>
19
+ <text x="80" y="14">97.1%</text>
20
+ </g>
21
+ </svg>
@@ -0,0 +1,213 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # platformio files
10
+ .platformio
11
+
12
+ # Distribution / packaging
13
+ .Python
14
+ build/
15
+ develop-eggs/
16
+ dist/
17
+ downloads/
18
+ eggs/
19
+ .eggs/
20
+ lib/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ wheels/
26
+ share/python-wheels/
27
+ *.egg-info/
28
+ .installed.cfg
29
+ *.egg
30
+ MANIFEST
31
+
32
+ # PyInstaller
33
+ # Usually these files are written by a python script from a template
34
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
35
+ *.manifest
36
+ *.spec
37
+
38
+ # Installer logs
39
+ pip-log.txt
40
+ pip-delete-this-directory.txt
41
+
42
+ # Unit test / coverage reports
43
+ htmlcov/
44
+ .tox/
45
+ .nox/
46
+ .coverage
47
+ .coverage.*
48
+ .cache
49
+ nosetests.xml
50
+ coverage.xml
51
+ *.cover
52
+ *.py.cover
53
+ .hypothesis/
54
+ .pytest_cache/
55
+ cover/
56
+
57
+ # Translations
58
+ *.mo
59
+ *.pot
60
+
61
+ # Django stuff:
62
+ *.log
63
+ local_settings.py
64
+ db.sqlite3
65
+ db.sqlite3-journal
66
+
67
+ # Flask stuff:
68
+ instance/
69
+ .webassets-cache
70
+
71
+ # Scrapy stuff:
72
+ .scrapy
73
+
74
+ # Sphinx documentation
75
+ docs/_build/
76
+
77
+ # PyBuilder
78
+ .pybuilder/
79
+ target/
80
+
81
+ # Jupyter Notebook
82
+ .ipynb_checkpoints
83
+
84
+ # IPython
85
+ profile_default/
86
+ ipython_config.py
87
+
88
+ # pyenv
89
+ # For a library or package, you might want to ignore these files since the code is
90
+ # intended to run in multiple environments; otherwise, check them in:
91
+ # .python-version
92
+
93
+ # pipenv
94
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
95
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
96
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
97
+ # install all needed dependencies.
98
+ #Pipfile.lock
99
+
100
+ # UV
101
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
102
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
103
+ # commonly ignored for libraries.
104
+ #uv.lock
105
+
106
+ # poetry
107
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
108
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
109
+ # commonly ignored for libraries.
110
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
111
+ #poetry.lock
112
+ #poetry.toml
113
+
114
+ # pdm
115
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
116
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
117
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
118
+ #pdm.lock
119
+ #pdm.toml
120
+ .pdm-python
121
+ .pdm-build/
122
+
123
+ # pixi
124
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
125
+ #pixi.lock
126
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
127
+ # in the .venv directory. It is recommended not to include this directory in version control.
128
+ .pixi
129
+
130
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
131
+ __pypackages__/
132
+
133
+ # Celery stuff
134
+ celerybeat-schedule
135
+ celerybeat.pid
136
+
137
+ # SageMath parsed files
138
+ *.sage.py
139
+
140
+ # Environments
141
+ .env
142
+ .envrc
143
+ .venv
144
+ env/
145
+ venv/
146
+ ENV/
147
+ env.bak/
148
+ venv.bak/
149
+
150
+ # Spyder project settings
151
+ .spyderproject
152
+ .spyproject
153
+
154
+ # Rope project settings
155
+ .ropeproject
156
+
157
+ # mkdocs documentation
158
+ /site
159
+
160
+ # mypy
161
+ .mypy_cache/
162
+ .dmypy.json
163
+ dmypy.json
164
+
165
+ # Pyre type checker
166
+ .pyre/
167
+
168
+ # pytype static type analyzer
169
+ .pytype/
170
+
171
+ # Cython debug symbols
172
+ cython_debug/
173
+
174
+ # PyCharm
175
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
176
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
177
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
178
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
179
+ #.idea/
180
+
181
+ # Abstra
182
+ # Abstra is an AI-powered process automation framework.
183
+ # Ignore directories containing user credentials, local state, and settings.
184
+ # Learn more at https://abstra.io/docs
185
+ .abstra/
186
+
187
+ # Visual Studio Code
188
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
189
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
190
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
191
+ # you could uncomment the following to ignore the entire vscode folder
192
+ # .vscode/
193
+
194
+ # Ruff stuff:
195
+ .ruff_cache/
196
+
197
+ # PyPI configuration file
198
+ .pypirc
199
+
200
+ # Cursor
201
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
202
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
203
+ # refer to https://docs.cursor.com/context/ignore-files
204
+ .cursorignore
205
+ .cursorindexingignore
206
+
207
+ # Marimo
208
+ marimo/_static/
209
+ marimo/_lsp/
210
+ __marimo__/
211
+
212
+ # Streamlit
213
+ .streamlit/secrets.toml
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Littie28
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,253 @@
1
+ Metadata-Version: 2.4
2
+ Name: hazy-frames
3
+ Version: 0.1.0
4
+ Summary: Hierarchical coordinate frames - crystal clear transforms
5
+ Project-URL: Homepage, https://github.com/Littie28/hazy-frames
6
+ Project-URL: Repository, https://github.com/Littie28/hazy-frames
7
+ Project-URL: Issues, https://github.com/Littie28/hazy-frames/issues
8
+ Author: Littie28
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: 3d,coordinate-systems,frames,geometry,transformations
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Requires-Python: >=3.12
21
+ Requires-Dist: numpy>=2.3.4
22
+ Requires-Dist: scipy>=1.16.3
23
+ Provides-Extra: examples
24
+ Description-Content-Type: text/markdown
25
+
26
+ # hazy-frames
27
+
28
+ [![Python Version](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
29
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
30
+ [![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)
31
+ ![Coverage](./.github/badges/coverage.svg)
32
+ ![Tests](https://img.shields.io/badge/tests-117%20passed-success)
33
+
34
+ **Hierarchical coordinate frames - crystal clear transforms**
35
+
36
+ A Python library for managing hierarchical reference frames and frame-aware geometric primitives with efficient transformation caching, inspired by [optiland](https://github.com/HarrisonKramer/optiland).
37
+
38
+ ## Features
39
+
40
+ - **Hierarchical Frame System**: Build complex frame hierarchies with parent-child relationships
41
+ - **Frame-Aware Primitives**: `Point` and `Vector` classes that carry frame information
42
+ - **Automatic Transformations**: Transform primitives between any frames in the hierarchy
43
+ - **Efficient Caching**: Transformation matrices are cached for performance
44
+ - **Proper Geometric Semantics**: Type-safe arithmetic operations (e.g., Point - Point = Vector)
45
+ - **Flexible Transformations**: Support for rotation (Euler angles, matrices), translation, and scaling
46
+ - **Global Reference Frame**: Singleton global frame for world coordinates
47
+
48
+ ## Installation
49
+
50
+ Install directly from GitHub:
51
+
52
+ ```bash
53
+ pip install git+https://github.com/Littie28/hazy-frames.git
54
+ ```
55
+
56
+ Or download the wheel from [releases](https://github.com/Littie28/hazy-frames/releases/latest):
57
+
58
+ ```bash
59
+ pip install hazy_frames-0.1.0-py3-none-any.whl
60
+ ```
61
+
62
+ For development:
63
+
64
+ ```bash
65
+ # Clone the repository
66
+ git clone https://github.com/Littie28/hazy-frames.git
67
+ cd hazy-frames
68
+
69
+ # Install with development dependencies
70
+ uv sync --group dev
71
+ ```
72
+
73
+ ## Quick Start
74
+
75
+ ```python
76
+ from hazy import Frame, Point, Vector
77
+
78
+ # Create a frame hierarchy
79
+ world = Frame.get_global()
80
+ robot = Frame(parent=world, name="robot")
81
+ robot.translate(x=5, y=0, z=0).rotate_euler(z=90, degrees=True)
82
+
83
+ camera = robot.make_child(name="camera") # different initialization methods
84
+ camera.translate(x=0, y=0, z=1)
85
+
86
+ # Create frame-aware primitives
87
+ point_in_camera = Point(1, 0, 0, frame=camera)
88
+
89
+ # Transform between frames
90
+ point_in_world = point_in_camera.to_frame(world)
91
+ point_in_robot = point_in_camera.to_frame(robot)
92
+
93
+ print(f"Camera: {point_in_camera}")
94
+ print(f"World: {point_in_world}")
95
+ print(f"Robot: {point_in_robot}")
96
+ ```
97
+
98
+ ## Core Concepts
99
+
100
+ ### Frames
101
+
102
+ Frames represent coordinate systems and can be organized hierarchically:
103
+
104
+ ```python
105
+ # Create frames
106
+ root = Frame.make_root(name="root")
107
+ parent = root.make_child("parent")
108
+ child = Frame(parent=parent, name="child")
109
+
110
+ # Apply transformations (chainable)
111
+ child.translate(x=10, y=5, z=0)
112
+ child.rotate_euler(x=45, y=0, z=90, degrees=True)
113
+ child.scale(2.0) # uniform scaling
114
+ child.scale((1.0, 2.0, 1.5)) # non-uniform scaling
115
+
116
+ # Freeze frames to prevent modifications
117
+ child.freeze()
118
+ ```
119
+
120
+ Transformations are applied in **S->R->T order** (Scale, Rotation, Translation) when converting from local to parent coordinates.
121
+
122
+ ### Points and Vectors
123
+
124
+ Points represent positions, vectors represent directions/displacements:
125
+
126
+ ```python
127
+ # Create primitives
128
+ origin = Point(0, 0, 0, frame=child)
129
+ direction = Vector(1, 0, 0, frame=child)
130
+
131
+ # Proper geometric arithmetic
132
+ point_a = Point(1, 2, 3, frame=child)
133
+ point_b = Point(4, 5, 6, frame=child)
134
+
135
+ displacement = point_b - point_a # Returns Vector
136
+ new_point = point_a + displacement # Returns Point
137
+
138
+ # Vectors support additional operations
139
+ vec = Vector(1, 0, 0, frame=child)
140
+ vec.normalize() # Normalize in-place
141
+ magnitude = vec.magnitude
142
+
143
+ # Cross product
144
+ vec1 = Vector(1, 0, 0, frame=child)
145
+ vec2 = Vector(0, 1, 0, frame=child)
146
+ perpendicular = vec1.cross(vec2) # Vector(0, 0, 1)
147
+ ```
148
+
149
+ ### Frame Transformations
150
+
151
+ ```python
152
+ # Get transformation matrices
153
+ T_to_parent = frame.transform_to_parent # 4x4 matrix
154
+ T_from_parent = frame.transform_from_parent # Inverse
155
+ T_to_global = frame.transform_to_global # To world frame
156
+ T_to_target = frame.transform_to(target_frame) # To any frame
157
+
158
+ # Transform primitives
159
+ point_global = point_local.to_global()
160
+ point_target = point_local.to_frame(target_frame)
161
+
162
+ # Batch transformations for efficiency
163
+ points_array = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
164
+ transformed = frame.batch_transform_points_global(points_array)
165
+ ```
166
+
167
+ ### Unit Vectors and Origin
168
+
169
+ Frames provide convenient accessors for unit vectors and origin:
170
+
171
+ ```python
172
+ # Unit vectors in frame's local coordinates
173
+ x_axis = frame.x_axis
174
+ y_axis = frame.y_axis
175
+ z_axis = frame.z_axis
176
+
177
+ # Unit vectors in global coordinates
178
+ x_global = frame.x_axis_global
179
+ y_global = frame.y_axis_global
180
+ z_global = frame.z_axis_global
181
+
182
+ # Frame origin
183
+ origin_local = frame.origin # Point(0, 0, 0) in frame
184
+ origin_global = frame.origin_global # Origin in global coords
185
+ ```
186
+
187
+ ## API Overview
188
+
189
+ ### Frame Class
190
+
191
+ | Method/Property | Description |
192
+ |----------------|-------------|
193
+ | `translate(x, y, z)` | Add translation to frame |
194
+ | `rotate_euler(x, y, z, seq, degrees)` | Add Euler angle rotation |
195
+ | `rotate(matrix)` | Add rotation from 3x3 matrix |
196
+ | `scale(factor)` | Add scaling (uniform or non-uniform) |
197
+ | `freeze()`/`unfreeze()` | Prevent/allow modifications |
198
+ | `transform_to_parent` | 4x4 transformation matrix to parent |
199
+ | `transform_to_global` | 4x4 transformation matrix to global |
200
+ | `transform_to(target)` | 4x4 transformation matrix to target frame |
201
+ | `point(x, y, z)` | Create Point in this frame |
202
+ | `vector(x, y, z)` | Create Vector in this frame |
203
+
204
+ ### Point Class
205
+
206
+ | Method/Property | Description |
207
+ |----------------|-------------|
208
+ | `to_frame(target)` | Transform to target frame |
209
+ | `to_global()` | Transform to global frame |
210
+ | `x`, `y`, `z` | Coordinate components |
211
+ | `Point + Vector` | Returns Point (displacement) |
212
+ | `Point - Point` | Returns Vector (difference) |
213
+ | `Point - Vector` | Returns Point (reverse displacement) |
214
+
215
+ ### Vector Class
216
+
217
+ | Method/Property | Description |
218
+ |----------------|-------------|
219
+ | `to_frame(target)` | Transform to target frame |
220
+ | `to_global()` | Transform to global frame |
221
+ | `x`, `y`, `z` | Vector components |
222
+ | `magnitude` | Vector length |
223
+ | `normalize()` | Normalize to unit length (in-place) |
224
+ | `cross(other)` | Cross product with another vector |
225
+ | `Vector + Vector` | Returns Vector (sum) |
226
+ | `Vector - Vector` | Returns Vector (difference) |
227
+ | `Vector + Point` | Returns Point (displacement) |
228
+
229
+ ## Development
230
+
231
+ ### Running Tests
232
+
233
+ ```bash
234
+ # Run all tests
235
+ pytest
236
+
237
+ # Run with coverage
238
+ pytest --cov=src/hazy --cov-report=html
239
+
240
+ # Run specific test markers
241
+ pytest -m unit
242
+ pytest -m integration
243
+
244
+ # Watch mode for development
245
+ pytest-watcher
246
+ ```
247
+ ## License
248
+
249
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
250
+
251
+ ## Contributing
252
+
253
+ Contributions are welcome! Please feel free to submit a Pull Request.