spatial-transform
Transform hierarchies in 3D space
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.2%) to scientific vocabulary
Keywords
Repository
Transform hierarchies in 3D space
Basic Info
Statistics
- Stars: 6
- Watchers: 1
- Forks: 2
- Open Issues: 0
- Releases: 0
Topics
Metadata Files
README.md
spatial-transform
Lightweight libary for creating hierarchies in a 3D space, like Unity, Unreal, Blender or any other 3D application.
Properties like positions, rotations, directions and scales can be easily accessed and are calculated based on the parents space for the world space. Individual transforms can be attatched and detatched at any point and have some more comfort methods for easy modifications.
Why and intention
This libary is a side product of my master thesis, in order to extract conveniently local and world data features from a humanoid skeleton hierarchy. I could not find any libary that could do that, without bloat or the features I required for extraction or modification.
Installation
batch
pip install spatial-transform
## Notes
- Pose is the class for all local space properties and operations. There is no awareness about other related space or hierarchy.
- Transform extend the Pose class to add hierarchical wareness and provides additional properties and methods for the world space.
- Euler is a class with static members only for converting euler angle into quaternions or matrices. It supports diffrent rotation orders and can be used to convert between
- The package PyGLM is used for matrix, quaternion and vector calculations.
- Same coordination space as openGL and GLM is used. Which is: Right-Handed, - Y+ is up, Z- is forward and positive rotations are counter clockwise.
Examples
Create and attach transforms
``` python from SpatialTransform import Transform, Euler
defining the transforms
hips = Transform('Hips', position=(0,2,0)) LeftLegUpper = Transform('LeftLegUpper', position=(+0.2,0,0)) LeftLegLower = Transform('LeftLegLower', position=(0,-1,0)) LeftLegFoot = Transform('LeftLegFoot', position=(0,-1,0)) RightLegUpper = Transform('RightLegUpper', position=(-0.2,0,0)) RightLegLower = Transform('RightLegLower', position=(0,-1,0)) RightLegFoot = Transform('RightLegFoot', position=(0,-1,0))
defining the hierarchy
hips.attach(LeftLegUpper) LeftLegUpper.attach(LeftLegLower) LeftLegLower.attach(LeftLegFoot)
hips.attach(RightLegUpper) RightLegUpper.attach(RightLegLower) RightLegLower.attach(RightLegFoot)
show the created hierarchy
hips.printTree() print('\nWorld positions, local positions, joint directions:') for item, index, depth in hips.layout(): print(f'{item.PositionWorld} {item.Position} {item.ForwardWorld} {item.Name}')
--------------------------- OUTPUT ---------------------------
Hips
+- LeftLegUpper
| +- LeftLegLower
| +- LeftLegFoot
+- RightLegUpper
+- RightLegLower
+- RightLegFoot
World positions, local positions, joint direction:
vec3( 0, 2, 0 ) vec3( 0, 2, 0 ) Hips
vec3( 0.2, 2, 0 ) vec3( 0.2, 0, 0 ) LeftLegUpper
vec3( 0.2, 1, 0 ) vec3( 0, -1, 0 ) LeftLegLower
vec3( 0.2, 0, 0 ) vec3( 0, -1, 0 ) LeftLegFoot
vec3( -0.2, 2, 0 ) vec3( -0.2, 0, 0 ) RightLegUpper
vec3( -0.2, 1, 0 ) vec3( 0, -1, 0 ) RightLegLower
vec3( -0.2, 0, 0 ) vec3( 0, -1, 0 ) RightLegFoot
```
Interacting with transforms
``` python from SpatialTransform import Transform
the basic properties of the transform as position, scale and rotation can be changed by setting the value
but the inverse-properties are read only
root = Transform() root.PositionWorld = (1,2,3) root.Scale = .1 # accepts either a single value or a tuple of three root.RotationWorld = (1, 0, 0, 0) # rotations are in quaternions
the rotation can be also read and changed with extra methods for simplified usage
root.setEuler((0, 90, 0)) root.getEuler(order='ZYX') root.lookAtWorld((1, 1, 1))
some methods do update the transform and keep childrens spatially unchanged
root.clearParent(keep=['position', 'rotation', 'scale']) root.clearChildren(keep=['position', 'rotation', 'scale']) root.applyPosition() root.applyRotation(recursive=True) root.appyScale(recursive=True)
the transform provide two methods to convert arbitrary points and direction from and to the spaces
root.pointToWorld((5,4,3)) root.directionToLocal((2,3,4)) ```
Fluent interface usage
``` python from SpatialTransform import Transform
because almost every method on the "Transform" object returns itself,
the previous code of creating and attaching can also be written like:
hips = Transform('Hips', position=(0,2,0)).attach( Transform('LeftLegUpper', position=(+0.2,0,0)).attach( Transform('LeftLegLower', position=(0,-1,0)).attach( Transform('LeftLegFoot', position=(0,-1,0)) ) ), Transform('RightLegUpper', position=(-0.2,0,0)).attach( Transform('RightLegLower', position=(0,-1,0)).attach( Transform('RightLegFoot', position=(0,-1,0)) ) ) )
multiple actions on a transform can be performed on a single line
feets = hips.setEuler((0, 180, 0)).applyRotation().filter('Foot')
show the created hierarchy
hips.printTree() print('\nPositions:') for item, index, depth in hips.layout(): print(f'{item.PositionWorld} {item.Position} {item.Name}')
--------------------------- OUTPUT ---------------------------
Hips
+- LeftLegUpper
| +- LeftLegLower
| +- LeftLegFoot
+- RightLegUpper
+- RightLegLower
+- RightLegFoot
Positions:
vec3( 0, 2, 0 ) vec3( 0, 2, 0 ) Hips
vec3( -0.2, 2, 1.74846e-08 ) vec3( -0.2, 0, 1.74846e-08 ) LeftLegUpper
vec3( -0.2, 1, 1.74846e-08 ) vec3( 0, -1, 0 ) LeftLegLower
vec3( -0.2, 0, 1.74846e-08 ) vec3( 0, -1, 0 ) LeftLegFoot
vec3( 0.2, 2, -1.74846e-08 ) vec3( 0.2, 0, -1.74846e-08 ) RightLegUpper
vec3( 0.2, 1, -1.74846e-08 ) vec3( 0, -1, 0 ) RightLegLower
vec3( 0.2, 0, -1.74846e-08 ) vec3( 0, -1, 0 ) RightLegFoot
```
Euler angles conversions
``` python
the package also provides the static class 'Euler'
the 'Transform' does also rely on that to convert between rotation representations
from SpatialTransform import Euler
rotations are in radians here
matrix = Euler.toMatFrom((1, 2, .5), order='YZX', extrinsic=True) quaternion = Euler.toQuatFrom((1, 2, .5), order='YZX', extrinsic=True)
angles1 = Euler.fromMatTo(matrix, order='XYZ', extrinsic=False) angles2 = Euler.fromQuatTo(quaternion, order='XYZ', extrinsic=False)
print(angles1 - angles2)
--------------------------- OUTPUT ---------------------------
vec3( 0, 0, 0 )
```
Owner
- Login: Wasserwecken
- Kind: user
- Location: Weingarten, Germany
- Website: https://mustachebracket.de/
- Repositories: 3
- Profile: https://github.com/Wasserwecken
.NET Software engineer. Currently student to get into graphics programming
Citation (CITATION.cff)
cff-version: 1.2.0
message: "You may want to cite this software like below."
title: "Transform hierarchies in 3D space"
date-released: 2022-12-16
authors:
- family-names: Dolch
given-names: Eric
repository-code: "https://github.com/Wasserwecken/spatial-transform"
GitHub Events
Total
- Issues event: 1
- Watch event: 1
- Push event: 16
Last Year
- Issues event: 1
- Watch event: 1
- Push event: 16
Committers
Last synced: about 2 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Eric Dolch | e****h@g****m | 192 |
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 1
- Total pull requests: 1
- Average time to close issues: about 13 hours
- Average time to close pull requests: about 1 hour
- Total issue authors: 1
- Total pull request authors: 1
- Average comments per issue: 1.0
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 1
- Pull requests: 0
- Average time to close issues: about 13 hours
- Average time to close pull requests: N/A
- Issue authors: 1
- Pull request authors: 0
- Average comments per issue: 1.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- mycroftjr (1)
Pull Request Authors
- gonchar (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 1,337 last-month
- Total dependent packages: 1
- Total dependent repositories: 1
- Total versions: 46
- Total maintainers: 1
pypi.org: spatial-transform
Transform hierarchies in 3D space.
- Homepage: https://github.com/Wasserwecken/spatial-transform
- Documentation: https://spatial-transform.readthedocs.io/
- License: MIT License
-
Latest release: 1.3.2
published 7 months ago
Rankings
Maintainers (1)
Dependencies
- actions/checkout v3 composite
- actions/setup-python v4 composite
- pypa/gh-action-pypi-publish release/v1 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- pypa/gh-action-pypi-publish release/v1 composite
- PyGLM ==2.7.0
