From fddc555bab22c1dd70493961df1c6c2b42ba8aa7 Mon Sep 17 00:00:00 2001 From: AgustinVallejo Date: Tue, 23 May 2023 10:55:33 -0600 Subject: [PATCH] Avoiding label overlap, see https://github.com/phetsims/keplers-laws/issues/26 --- js/keplers-laws/view/EllipticalOrbitNode.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/js/keplers-laws/view/EllipticalOrbitNode.ts b/js/keplers-laws/view/EllipticalOrbitNode.ts index 73d9bd4..472ff31 100644 --- a/js/keplers-laws/view/EllipticalOrbitNode.ts +++ b/js/keplers-laws/view/EllipticalOrbitNode.ts @@ -334,7 +334,7 @@ export default class EllipticalOrbitNode extends Path { // const semiAxis = new ArrowShape( 0, 0, -radiusX, 0, {} ); semiAxis.moveTo( 0, 0 ).lineTo( 0, radiusY ); semiAxisPath.shape = semiAxis; - aLabelNode.center = new Vector2( -radiusX / 2, 10 ); + aLabelNode.center = new Vector2( -radiusX / 2, 15 ); aLabelNode.rotation = this.orbit.w; bLabelNode.center = new Vector2( -15, radiusY / 2 ); bLabelNode.rotation = this.orbit.w; @@ -346,14 +346,15 @@ export default class EllipticalOrbitNode extends Path { // Strings of the foci const bodyPosition = this.orbit.createPolar( -this.orbit.nu ).times( scale ); const stringsShape = new Shape().moveTo( -radiusC, 0 ).lineTo( ( bodyPosition.x + radiusC ), bodyPosition.y ); - stringsShape.moveTo( radiusC, 0 ).lineTo( ( bodyPosition.x + radiusC ), bodyPosition.y ); + stringsShape.lineTo( radiusC, 0 ); stringsPath.shape = stringsShape; const labelsYPosition = bodyPosition.y / 2; const offsetVector = new Vector2( 0, 15 ).rotated( bodyPosition.angle ); + const offsetVector2 = new Vector2( 0, 15 ).rotated( Math.atan2( bodyPosition.y, bodyPosition.x + 2 * radiusC ) ); stringLabelNode1.center = new Vector2( ( bodyPosition.x / 2 + radiusC ), labelsYPosition ).add( offsetVector ); stringLabelNode1.rotation = this.orbit.w; - stringLabelNode2.center = new Vector2( ( bodyPosition.x / 2 ), labelsYPosition ).add( offsetVector ); + stringLabelNode2.center = new Vector2( ( ( bodyPosition.x - 2 * radiusC ) / 2 + radiusC ), labelsYPosition ).add( offsetVector2 ); stringLabelNode2.rotation = this.orbit.w; radiusLabelNode.center = new Vector2( ( bodyPosition.x / 2 ), labelsYPosition ).add( offsetVector ); radiusLabelNode.rotation = this.orbit.w;