I am defining geometries in meshes, but to perform computations, I must strip units and vectorize the data using
ustrip.(to.(data))
to create unitless vectors. This process feels cumbersome, possibly indicating unintended library usage. Once the geometry is estimated, I convert the data back to unitized points.
While mesh operations like intersection testing are valuable, the overhead of repeated conversions might be inefficient. Linear algebra operations generally require conversion to static float vectors and reconversion to Quantities. Any tips on how people typically use Unitful and Meshes?
This is probably the case. We use this library daily in very advanced applications and rarely need to strip out the units from the coordinates.
What are you trying to do? Perhaps you can describe the task, and we can help with existing methods.
Computer vision, in particular, pose regression and bundle adjustment. I was trying to define synthetic problems with Meshes.jl and then use those geometries as input to regression methods. Some of the methods in Meshes.jl would be convenient to have, but I’m wondering if the domain is just not a good fit.
If you have a more specific example of the kinds of operations that should be there and aren’t, we can see if a method is missing.
The issue isn’t missing methods; it’s about interfacing with linear algebra functions like SVD, Cholesky, and projective transformations. There seems to be some impedance here since you can’t directly apply linear algebra on Unitful Quantities, nor can you easily perform matrix/vector operations on PointSets without converting them to unitless vectors. While there are transformation functions for geometries in Meshes, it can become cumbersome to define a new function for each transformation needed for PointSet manipulation.
so maybe it’s better just to use vectors of static vectors, but at some point, I would like to do intersection tests, so perhaps somehow just converting to Meshes types for those specific operations and converting back is the way to go. Or maybe GeometryBasics is suited.
Feel free to reach out if you need help with Meshes.jl.
Handling units explicitly might seem inconvenient at first, but it can really pay off in the long-term depending on your goals. A few things to keep in mind:
- Units give you a wider range of coordinates. You can go beyond double precision (e.g.
1e-10nm
is much smaller than 1e-10
)
- Unit-aware algorithms are more robust as they can convert
ft
, m
or any other length unit automatically for end-users
- Visualization of multiple unitful geometries on the same scene is safer in the sense that you will never plot an object of size
1m
next to an object of size 1cm
accidentally
If these features are not relevant to you, that is completely fine. Choose the library that best suits your needs.
I agree with all these points, but a part of the method requires optimization, where units don’t fit naturally. So, I’m just wondering if other users have encountered this issue.