How should we handle transformations, projections and space
?
#4750
Labels
coordinate spaces
i.e. space attribute, transformations between coordinate spaces, project
Makie
Backend independent issues (Makie core)
planning
For discussion and planning development
transformation
related to `Transformation` objects
Current Siuation
Pipeline (From user data to pixels)
(Conversions don't really matter here, they are just included for completion sake.)
0. * float32convert - make data Float32 compatible
* float32convert is an odd one out:
Ownership:
space
AttributeOriginally
space
only affected projections::data
uses pipeline with defaultview, projection
of camera:pixel
useview, projection
that map pixel units to clip space:clip
use constantview, projection = I
:relative
use constantview, projection
scaling 0..1 -> -1..1Notes:
:data
may sometimes refer to "world" space and sometimes to user space (i.e. between 1.3 and 2.1)space = :data
. There is Code with the same restriction for model, but it maybe used less...Related Issues/PRs/Problems/Requests
vlines
, see Add mixed coordinate spaces #1730, Compose different spaces – data, relative, pixel, ... #4407space = :transformed
to address the coordinate space between 2.1 and 2.2, see Addspace=:transformed
#2766mouseposition()
in pre 2.1 scene space, i.e. without scene transformations applied, see Implement mouseposition(::Axis) to account for axis scales #4090project()
Cleanup projection code #3013Proposal
I don't like the idea of adding
space = :transformed
anymore. Transformations can make sense regardless of the projection we are using. For exampletranslate!()
makes just as much sense in pixel space as it does in "data" space. There may also be valid transform functions in other (projection) spaces. With that we would need various versions of:transformed
, i.e.:data_transformed
,:pixel_transformed
, ... I don't like that.My preferred alternative would be to split transformations and projections. This means making transformations (not including float32convert) completely independent of
space
. They would always be applied. If that's not desired they would need to be adjusted to identity transforms. You can already overwrite the transformations of a plot to do that:We could push this more to the foreground, i.e. document it more and advertise it as the way to handle
space = :transformed
. Maybe also add more convenience here, e.g. something liketransformation = :inherit/:inherit_func/:inherit_model/:identity
?With that
project()
could look like this:which conceptually is a
projection * (transformation * data)
. To keep the implementation simple and clean I think ainverse_project() = inv(transform) * (inv(projection) * data)
would be good. Some helper function for individual steps also seem useful, i.e.:apply_transform(transform_func, data)
- only transform functionapply_transform(transformation, data)
- transform function and modelapply_matrix(mat, data[, TargetType])
- convert to Point4, apply 4x4 Matrix, convert back to TargetTypeMixed spaces would get simplified in some sense, because separating transformations from projections/space gives us a pass to ignore them. It would be on the user to make sure that the transformations are compatible with mixed spaces (i.e. not mix dimensions)
High level functions would still have to handle what kind of transformations they apply themselves. Some may always or never want to apply transformations. Some may want a kwarg to choose.
ray_assisted_pick
/position_on_plot
already has anapply_transform::Bool
option, which we could use elsewhere.I also want to rename
space = :data
because it's unclear what that means. But it's also not clear to me what to call it. Maybe:camera
as it uses projections based on the camera?:world
seems weird since we have model and view space. All of them might be confusing with how transformations are separate...The text was updated successfully, but these errors were encountered: