## TL;DR

Cartesian meshes seems to be the standard in Julia (Meshes.jl, Rotations.jl…). I read files using 4x4 matrices, should I:

- define my own transformation in CoordinateTransformations.jl that takes a Point3 in and a 4x4 and return a Point3 (don’t know how to do it),
- stick to homogeneous coordinates everywhere,
- find a way to decompose the 4x4 matrix into a composition of 3x3 matrices (don’t know how to do it for rotation*scaling) ?

## Longer version with details

I am building a visualization library for 3d plants called PlantGeom.jl (not registered yet). The design is mainly based on AmapStudio and OpenAlea if anyone is interested.

Now we have a (quite) standard file format called OPF (Open Plant Format) for exchange of plants between platforms and models. The file is divided into mainly two parts: reference meshes, and the topology description. The reference meshes are just a list of meshes with an ID (+materials). The topology is a tree-like structure where each node is typically an organ (a leaf, a phytomer…). The node holds the information about which reference mesh is used to represent the organ in 3d (its ID) + an homogeneous (4x4) transformation matrix that is applied to the mesh to get the effective mesh of the organ in the plant world. This design was adopted because plants usually have a limited number of organs, and only their scale and position changes (so having reference mesh * homogeneous matrix saves a lot of space).

Now PlantGeom is not meant for reading OPF files only, I plan to develop functionalities for building plants from scratch too, using reference meshes, and letting the user use transformations to place the organs in the plant.

I am far from a specialist on 3D, so I try to use existing packages as much as possible. I found out that Meshes.jl is becoming the new standard for meshes, and that CoordinateTransformations.jl and Rotations.jl for transformations. So i try using them.

Now here is my problem: the OPF files uses homogeneous transformation matrices in the 4x3 form (I transform them into 4x4 when parsing). But I feel that the design around the other packages is more oriented toward Cartesian matrices (3x3) (or at least Rotation.jl do). (Any idea why?)

I would prefer to stick to whatever is the standard in the Julia community to avoid spending a lot of time on the 3D aspects now and mostly to benefit from the future improvements in those packages “freely” + other packages eventually.

At the moment each node in my tree-like data structure (see MultiScaleTreeGraph.jl for more info) holds a geometry attribute that is a mutable struct with the reference mesh (an immutable struct), the transformation, and optionally the resulting mesh (computed only when needed) + some other unimportant stuff (see geometry struct).

So here is what came to my mind as possible solutions:

- use cartesian points and cartesian transformations, except when we have a 4x4 matrix (from reading an OPF file). In this case put the 4x4 matrix in a
`LinearMap()`

. - use homogenous matrices and points everywhere. Meaning when we apply a new transformation, we just update the homogenous matrix direclty.
- decompose the 4x4 matrix and use a composition of 3x3 transformations. This could be elegant but I couldn’t find out how to properly extract the rotation/scaling matrices from the 4x4 matrix.

Point 1 is appealing because then I can save memory space with all my points (only 3 values instead of 4) + I can use Rotations.jl and CoordinateTransformations.jl (and bonus: my transformations are reversible!). The downside is I would have to transform my cartesian 3d points into homogeneous points before applying the LinearMap(4x4) transformation, and I don’t know how to do that.

Point 2 is in my opinion the regular way, but maybe not the preferred way ?

Point 3 is appealing too but I would have to define my own transformations, and it would use more memory for my meshes (one value more per point).

Sorry for the long post! Any opinion that could help me find the right way ?