Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
I wanted to put some of my thoughts on bounding boxes into writing/code.
What uses bounding boxes?
Other uses/influences:
Since limits are used for plotted data pretty much everywhere we should just have a common scene bounding box, derived from plot bounding boxes.
About coordinate spaces
Generally bounding boxes are needed in the space their data is in:
Some require transformations down the pipeline:
Moving up the pipeline is less clear:
Plots should probably have space conversion for their bounding boxes. Scenes should either filter (e.g. only consider :data space plots for a :data space bounding box) or transform only :data, :transformed and :world space into each other as data in those spaces depend on things the scene (may) control.
About accurate bounding boxes / marker bounding boxes
So I think we want a fast and an accurate version of
boundingbox()
. Fast can include marker bounding boxes if they are cheap, while accurate always includes them.I'm not sure how fast the fast version should be/needs to be. E.g. should bounding boxes in other spaces just transform the data space bounding box or transform data and then calculate a new bounding box?
About caching / Lazy bounding boxes
Bounding Boxes are generally not something we need to process asap
And also something we need regardless of whether they changed
To avoid lots of redundant calculations bounding boxes should be cached and lazy. It would be nice to have an
on_bounding_box_change
though.Other Notes
vlines
(...) should not result in y (...) limits changes in Axis etc. Imo this should not discard a dimension of the bounding box, as that dimension still affects the bounds of the plot/visualization. This should be handled by the Axis instead. Maybe that dimension should beInf
, if that's not impractical...plot.transformed = apply_transform(transform_func(plot), plot.converted)
would give us cheaper/more accurate bounding boxes in:transformed
spaceSummary of Goals
boundingbox(obj, mode = :fast/:accurate)
data_limits
for fast bounding boxesboundingbox(plot, space)
transform to the given spaceboundingbox(scene, space)
only regard plots in that spaceboudningbox(scene, space)
transform plot bboxes to the given space, but only for :data, :transformed and :world space plots (ignoring :pixel, :relative and :clip space plots and returning invalid bbox if the passed space is one of those)boundingbox(obj, index)
Type of change
Delete options that do not apply:
Checklist