Skip to content

Angle2D/Arc2D/SmallestArc2D render wrong under canvas scale #545

Description

@bewuwy

Problem

Angle2D (and Arc2D / SmallestArc2D, which wrap it) only sends its origin through Projection2D. The start and end angles (points[i].angle() in Arc2D.svelte) are world angles and are used as given, while the vectors themselves are drawn along their projected on-screen directions. Under a non-uniform Canvas2D scale (scaleX !== scaleY) the arc ends therefore do not land on the drawn vectors.

SmallestArc2D's label position is the world-space bisector times distance, and Latex2D projects it. The arc radius (distance) is a screen-space size that is not projected, so the label drifts off the arc whenever the scale is not 1, even when it is uniform.

Expected

  • The arc starts and ends on the on-screen direction of each vector.
  • The label sits on the drawn arc.
  • Output at scale 1 is unchanged.

Suggested approach

  • Add a world angle → screen angle mapping to Projection2D (atan2(sy·sinθ, sx·cosθ), lifted so winding is kept for negative and multi-turn angles), with unit tests.
  • Use it in Angle2D for the start and end angles and the arrowhead rotation. Keep distance, width and headLength as screen-space sizes, as documented in Angle2D now.
  • Compute SmallestArc2D's label position in screen space and pass it back through projection.toWorld.

Context

Found in the review of #515 (the Projection2D seam, #491) and deferred from that PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions