phetsims/vector-addition

labels for long vectors are off screen

Closed this issue · 8 comments

Currently, a vector's label is centered along the length of the vector. This works (and looks) great in most cases, for example:

screenshot_1558

But in the Equation screen, it's possible to create some really long vectors. For example, setting the pickers to maximum values results in something like the screenshot below. And in cases like this, you can't see the labels on the sum vector or its component vectors.

@arouinfar do you want to live with this, or change the positioning algorithm for labels?

screenshot_1557

When a vector is selected, we change its label to yellow. So when a vector's label is off screen, there's also no feedback when the vector is selected.

Here's another example, where you can't tell which vector is 'a' vs 'b'.

screenshot_1559

The user could move 'a' and 'b' to see their labels, as in the screenshot below. But because of the constraint that a vector's tail must be on the graph. it's impossible to move 'c' enough to see its label.

screenshot_1560

I discussed with @arouinfar via Zoom.

We don't want to enforce the label to always be on the graph, because that will look lousy for shorter vectors that are placed near the edge of the graph. And we don't mind the user having to move the vectors if they want the labels to be on the graph.

We do want to apply the same fix to all vectors, including component vectors.

We decided to center the label on Math.min( vector.min, MAX_MAGNITUDE ). I've currently set MAX_MAGNITUDE to be the width of the graph, which is 50, and that seems to work nicely. If we want to do more tweaking, I'll add a query parameter.

@arouinfar please review in master or 1.0.0-dev.33.

We might also consider using the diagonal length of the graph for MAX_MAGNITUDE. Using the graph's width will cause the label to not be centered for some vectors that do fit on the graph. For example:

screenshot_1561

@pixelzoom the general approach is working quite nicely.
image

We might also consider using the diagonal length of the graph for MAX_MAGNITUDE

Yes, I agree. Can you update MAX_MAGNITUDE to match the vector shown in #212 (comment)?

Adjusted as requested - this feels better. Also renamed the constant to MAX_LABEL_VECTOR_MAGITUDE.

@arouinfar please verify in master or 1.0.0-dev.34.

👍

Looks great @pixelzoom. This was a really nice polish, thanks for suggesting!