|
4 | 4 | calculatePreviewMoonGeometry, |
5 | 5 | describePreviewTravelDirection, |
6 | 6 | determinePreviewTravelVector, |
| 7 | + PREVIEW_STAGE_SIZE, |
7 | 8 | PREVIEW_SUN_RADIUS, |
8 | 9 | } from "../src/utils/previewGeometry"; |
9 | 10 |
|
@@ -130,4 +131,54 @@ describe("preview moon geometry", () => { |
130 | 131 | expect(c1Distance).toBeCloseTo(PREVIEW_SUN_RADIUS + c1Geometry.moonRadius, 6); |
131 | 132 | expect(c4Distance).toBeCloseTo(PREVIEW_SUN_RADIUS + c4Geometry.moonRadius, 6); |
132 | 133 | }); |
| 134 | + |
| 135 | + it("keeps moon-size ratio consistent when rendered in compact max-view stage", () => { |
| 136 | + const compactStageSize = 84; |
| 137 | + const compactSunRadius = (compactStageSize * PREVIEW_SUN_RADIUS) / PREVIEW_STAGE_SIZE; |
| 138 | + const fullGeometry = calculatePreviewMoonGeometry({ |
| 139 | + progress: 0.5, |
| 140 | + kindAtLocation: "total", |
| 141 | + contacts: { c1: 0, c2: 0.25, max: 0.5, c3: 0.75, c4: 1 }, |
| 142 | + }); |
| 143 | + const compactGeometry = calculatePreviewMoonGeometry({ |
| 144 | + progress: 0.5, |
| 145 | + kindAtLocation: "total", |
| 146 | + contacts: { c1: 0, c2: 0.25, max: 0.5, c3: 0.75, c4: 1 }, |
| 147 | + stageSize: compactStageSize, |
| 148 | + sunRadius: compactSunRadius, |
| 149 | + }); |
| 150 | + |
| 151 | + const fullRatio = fullGeometry.moonRadius / PREVIEW_SUN_RADIUS; |
| 152 | + const compactRatio = compactGeometry.moonRadius / compactSunRadius; |
| 153 | + expect(compactRatio).toBeCloseTo(fullRatio, 10); |
| 154 | + }); |
| 155 | + |
| 156 | + it("preserves C1/C4 tangency distance in compact max-view stage", () => { |
| 157 | + const compactStageSize = 84; |
| 158 | + const compactSunRadius = (compactStageSize * PREVIEW_SUN_RADIUS) / PREVIEW_STAGE_SIZE; |
| 159 | + const stageCenter = compactStageSize / 2; |
| 160 | + const contacts = { c1: 0, c2: 0.25, max: 0.5, c3: 0.75, c4: 1 }; |
| 161 | + |
| 162 | + const c1Geometry = calculatePreviewMoonGeometry({ |
| 163 | + progress: 0, |
| 164 | + kindAtLocation: "annular", |
| 165 | + contacts, |
| 166 | + stageSize: compactStageSize, |
| 167 | + sunRadius: compactSunRadius, |
| 168 | + }); |
| 169 | + const c4Geometry = calculatePreviewMoonGeometry({ |
| 170 | + progress: 1, |
| 171 | + kindAtLocation: "annular", |
| 172 | + contacts, |
| 173 | + stageSize: compactStageSize, |
| 174 | + sunRadius: compactSunRadius, |
| 175 | + }); |
| 176 | + |
| 177 | + const c1Distance = Math.abs(c1Geometry.moonCenterX - stageCenter); |
| 178 | + const c4Distance = Math.abs(c4Geometry.moonCenterX - stageCenter); |
| 179 | + const expectedDistance = compactSunRadius + c1Geometry.moonRadius; |
| 180 | + |
| 181 | + expect(c1Distance).toBeCloseTo(expectedDistance, 6); |
| 182 | + expect(c4Distance).toBeCloseTo(expectedDistance, 6); |
| 183 | + }); |
133 | 184 | }); |
0 commit comments