From 79e4c276f8821ff4d92e66ba030b693cad585bea Mon Sep 17 00:00:00 2001 From: YoniKiriaty Date: Wed, 4 Feb 2026 15:29:38 +0200 Subject: [PATCH 01/11] Yoni - split to module --- .../backend/src/fuel/{ => calculations}/fuel-averaging.ts | 2 +- .../backend/src/fuel/{ => calculations}/fuel-match.ts | 2 +- apps/scouting/backend/src/fuel/fuel-object.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename apps/scouting/backend/src/fuel/{ => calculations}/fuel-averaging.ts (98%) rename apps/scouting/backend/src/fuel/{ => calculations}/fuel-match.ts (93%) diff --git a/apps/scouting/backend/src/fuel/fuel-averaging.ts b/apps/scouting/backend/src/fuel/calculations/fuel-averaging.ts similarity index 98% rename from apps/scouting/backend/src/fuel/fuel-averaging.ts rename to apps/scouting/backend/src/fuel/calculations/fuel-averaging.ts index ee0e334..6ed8b87 100644 --- a/apps/scouting/backend/src/fuel/fuel-averaging.ts +++ b/apps/scouting/backend/src/fuel/calculations/fuel-averaging.ts @@ -1,6 +1,6 @@ // בס"ד import type { Match, ShootEvent } from "@repo/scouting_types"; -import type { BPS, FuelObject } from "./fuel-object"; +import type { BPS, FuelObject } from "../fuel-object"; import { calculateSum, firstElement, lastElement } from "@repo/array-functions"; const EMPTY_INTERVAL_DURATION = 0; diff --git a/apps/scouting/backend/src/fuel/fuel-match.ts b/apps/scouting/backend/src/fuel/calculations/fuel-match.ts similarity index 93% rename from apps/scouting/backend/src/fuel/fuel-match.ts rename to apps/scouting/backend/src/fuel/calculations/fuel-match.ts index 137a434..7f8fead 100644 --- a/apps/scouting/backend/src/fuel/fuel-match.ts +++ b/apps/scouting/backend/src/fuel/calculations/fuel-match.ts @@ -1,6 +1,6 @@ // בס"ד import type { ShootEvent } from "@repo/scouting_types"; -import type { BPS, FuelObject } from "./fuel-object"; +import type { BPS, FuelObject } from "../fuel-object"; const getIncludedShots = (section: number[], shot: ShootEvent) => { return section.filter( diff --git a/apps/scouting/backend/src/fuel/fuel-object.ts b/apps/scouting/backend/src/fuel/fuel-object.ts index 41f5578..9dd7182 100644 --- a/apps/scouting/backend/src/fuel/fuel-object.ts +++ b/apps/scouting/backend/src/fuel/fuel-object.ts @@ -1,8 +1,8 @@ // בס"ד import type { GameObject } from "../game-object"; import type { Match, Point, ShootEvent } from "@repo/scouting_types"; -import { calculateFuelByAveraging } from "./fuel-averaging"; -import { calculateFuelByMatch } from "./fuel-match"; +import { calculateFuelByAveraging } from "./calculations/fuel-averaging"; +import { calculateFuelByMatch } from "./calculations/fuel-match"; export interface BPS { events: { shoot: number[]; score: number[] }[]; From 56e6c9678c5f6a169e3c6ba9181e8d07fe1c9226 Mon Sep 17 00:00:00 2001 From: YoniKiriaty Date: Wed, 4 Feb 2026 16:12:58 +0200 Subject: [PATCH 02/11] Yoni - added rebuilt map --- .../backend/src/fuel/distance-split.ts | 38 +++++++++++++++ apps/scouting/backend/src/fuel/fuel-object.ts | 2 +- .../src/scouter/components/ScoreMap.tsx | 44 ++++++++++-------- packages/array-functions/index.ts | 5 ++ .../rebuilt-map}/blue-field-4418.png | Bin .../rebuilt-map}/full-field-4418.png | Bin packages/rebuilt-map/index.ts | 10 ++++ packages/rebuilt-map/package.json | 13 ++++++ .../rebuilt-map}/red-field-4418.png | Bin 9 files changed, 91 insertions(+), 21 deletions(-) create mode 100644 apps/scouting/backend/src/fuel/distance-split.ts rename {apps/scouting/frontend/public => packages/rebuilt-map}/blue-field-4418.png (100%) rename {apps/scouting/frontend/public => packages/rebuilt-map}/full-field-4418.png (100%) create mode 100644 packages/rebuilt-map/index.ts create mode 100644 packages/rebuilt-map/package.json rename {apps/scouting/frontend/public => packages/rebuilt-map}/red-field-4418.png (100%) diff --git a/apps/scouting/backend/src/fuel/distance-split.ts b/apps/scouting/backend/src/fuel/distance-split.ts new file mode 100644 index 0000000..7e3dc86 --- /dev/null +++ b/apps/scouting/backend/src/fuel/distance-split.ts @@ -0,0 +1,38 @@ +// בס"ד +import type { Point } from "@repo/scouting_types"; +import type { FuelEvents, FuelObject } from "./fuel-object"; +import { calculateAverage } from "@repo/array-functions"; + +const hubPosition = { x: 1, y: 2 }; +export const distanceFromHub = (point: Point): number => { + return Math.sqrt(Math.pow(point.x, 2) + Math.pow(point.y, 2)); +}; + +const averageFuel = (fuels: FuelObject[]): FuelObject => { + const averageOfKey = (key: FuelEvents) => + calculateAverage(fuels, (value) => value[key]); + return { + scored: averageOfKey("scored"), + shot: averageOfKey("shot"), + missed: averageOfKey("missed"), + positions: fuels.flatMap((fuel) => fuel.positions), + }; +}; + +export const splitByDistances = ( + fuels: FuelObject[], + distances: T[], +): Record => { + const distancedFuels = distances.map((distance) => ({ + distance, + fuel: fuels.filter((fuel) => + fuel.positions.every((position) => distanceFromHub(position) < distance), + ), + })); + + return Object.assign( + distancedFuels.map((distancedFuel) => ({ + [distancedFuel.distance]: averageFuel(distancedFuel.fuel), + })), + ); +}; diff --git a/apps/scouting/backend/src/fuel/fuel-object.ts b/apps/scouting/backend/src/fuel/fuel-object.ts index 9dd7182..4ae4698 100644 --- a/apps/scouting/backend/src/fuel/fuel-object.ts +++ b/apps/scouting/backend/src/fuel/fuel-object.ts @@ -9,7 +9,7 @@ export interface BPS { match: Match; } -type FuelEvents = "scored" | "shot" | "missed"; +export type FuelEvents = "scored" | "shot" | "missed"; export type FuelObject = GameObject< FuelEvents, { diff --git a/apps/scouting/frontend/src/scouter/components/ScoreMap.tsx b/apps/scouting/frontend/src/scouter/components/ScoreMap.tsx index 4b562ad..40e9da8 100644 --- a/apps/scouting/frontend/src/scouter/components/ScoreMap.tsx +++ b/apps/scouting/frontend/src/scouter/components/ScoreMap.tsx @@ -10,6 +10,13 @@ import { type Touch, } from "react"; import type { Alliance, Point } from "@repo/scouting_types"; +import { + ALLIANCE_ZONE_WIDTH_PIXELS, + FIELD_HEIGHT_PIXELS, + TWO_THIRDS_FIELD_WIDTH_PIXELS, + blueField, + redField, +} from "@repo/rebuilt_map"; import { pipe } from "fp-ts/lib/function"; interface ScoreMapProps { @@ -19,17 +26,14 @@ interface ScoreMapProps { mapZone: Alliance; } -const ALLIANCE_ZONE_WIDTH_PIXELS = 395; -const TWO_THIRDS_WIDTH_PIXELS = 1010; -const HEIGHT_PIXELS = 652; const alliancizePosition = (alliance: Alliance, position: Point): Point => { if (alliance === "red") { return position; } return { - x: TWO_THIRDS_WIDTH_PIXELS - position.x, - y: HEIGHT_PIXELS - position.y, + x: TWO_THIRDS_FIELD_WIDTH_PIXELS - position.x, + y: FIELD_HEIGHT_PIXELS - position.y, }; }; @@ -41,8 +45,8 @@ const switchZone = (point: Point) => { }; const normalizePosition = (point: Point, bounds: Point) => ({ - x: (point.x * TWO_THIRDS_WIDTH_PIXELS) / bounds.x, - y: (point.y * HEIGHT_PIXELS) / bounds.y, + x: (point.x * TWO_THIRDS_FIELD_WIDTH_PIXELS) / bounds.x, + y: (point.y * FIELD_HEIGHT_PIXELS) / bounds.y, }); const dotRadius = 10; @@ -77,12 +81,12 @@ const getRobotPosition = ( y: boundedY + imageRect.top - containerRect.top, }, normalizedPoint: { - x: boundedX, - y: boundedY - }, - imageSize: { - x: imageRect.width, - y: imageRect.height + x: boundedX, + y: boundedY, + }, + imageSize: { + x: imageRect.width, + y: imageRect.height, }, }; }; @@ -103,18 +107,18 @@ export const ScoreMap: FC = ({ } const containerElement = containerRef.current; const imageElement = imageRef.current; - if (!(containerElement&&imageElement)) { + if (!(containerElement && imageElement)) { return; } const containerRect = containerElement.getBoundingClientRect(); const imageRect = imageElement.getBoundingClientRect(); const touch = event.targetTouches[firstTouchIndex]; - const { mapPoint: dotPoint, normalizedPoint, imageSize } = getRobotPosition( - touch, - imageRect, - containerRect, - ); + const { + mapPoint: dotPoint, + normalizedPoint, + imageSize, + } = getRobotPosition(touch, imageRect, containerRect); setMapPoint(dotPoint); @@ -136,7 +140,7 @@ export const ScoreMap: FC = ({ > { setHolding(true); diff --git a/packages/array-functions/index.ts b/packages/array-functions/index.ts index 520bc90..1a9cceb 100644 --- a/packages/array-functions/index.ts +++ b/packages/array-functions/index.ts @@ -7,6 +7,11 @@ export const calculateSum = ( ): number => arr.reduce((sum, value) => sum + transformation(value), startingSumValue); +export const calculateAverage = ( + arr: T[], + transformation: (value: T) => number, +): number => calculateSum(arr, transformation) / arr.length; + const FIRST_ELEMENT_ID = 0; const LAST_ELEMENT_BACKWARDS_INDEX = 1; export const firstElement = (arr: T[]): T => arr[FIRST_ELEMENT_ID]; diff --git a/apps/scouting/frontend/public/blue-field-4418.png b/packages/rebuilt-map/blue-field-4418.png similarity index 100% rename from apps/scouting/frontend/public/blue-field-4418.png rename to packages/rebuilt-map/blue-field-4418.png diff --git a/apps/scouting/frontend/public/full-field-4418.png b/packages/rebuilt-map/full-field-4418.png similarity index 100% rename from apps/scouting/frontend/public/full-field-4418.png rename to packages/rebuilt-map/full-field-4418.png diff --git a/packages/rebuilt-map/index.ts b/packages/rebuilt-map/index.ts new file mode 100644 index 0000000..e742c7a --- /dev/null +++ b/packages/rebuilt-map/index.ts @@ -0,0 +1,10 @@ +// בס"ד + +import blue from "./blue-field-4418.png"; +export const blueField = blue; +import red from "./red-field-4418.png"; +export const redField = red; + +export const ALLIANCE_ZONE_WIDTH_PIXELS = 395; +export const TWO_THIRDS_FIELD_WIDTH_PIXELS = 1010; +export const FIELD_HEIGHT_PIXELS = 652; diff --git a/packages/rebuilt-map/package.json b/packages/rebuilt-map/package.json new file mode 100644 index 0000000..2675ada --- /dev/null +++ b/packages/rebuilt-map/package.json @@ -0,0 +1,13 @@ +{ + "name": "@repo/rebuilt_map", + "version": "0.1.0", + "type": "module", + "private": true, + "exports": { + ".": "./index.ts" + }, + "dependencies": {}, + "devDependencies": { + "typescript": "latest" + } +} diff --git a/apps/scouting/frontend/public/red-field-4418.png b/packages/rebuilt-map/red-field-4418.png similarity index 100% rename from apps/scouting/frontend/public/red-field-4418.png rename to packages/rebuilt-map/red-field-4418.png From 464a0817e68661b18c6a1daf66768e0aa875f938 Mon Sep 17 00:00:00 2001 From: YoniKiriaty Date: Wed, 4 Feb 2026 16:14:52 +0200 Subject: [PATCH 03/11] Yoni - solid --- .../rebuilt-map/{ => images}/blue-field-4418.png | Bin .../rebuilt-map/{ => images}/full-field-4418.png | Bin .../rebuilt-map/{ => images}/red-field-4418.png | Bin packages/rebuilt-map/index.ts | 4 ++-- 4 files changed, 2 insertions(+), 2 deletions(-) rename packages/rebuilt-map/{ => images}/blue-field-4418.png (100%) rename packages/rebuilt-map/{ => images}/full-field-4418.png (100%) rename packages/rebuilt-map/{ => images}/red-field-4418.png (100%) diff --git a/packages/rebuilt-map/blue-field-4418.png b/packages/rebuilt-map/images/blue-field-4418.png similarity index 100% rename from packages/rebuilt-map/blue-field-4418.png rename to packages/rebuilt-map/images/blue-field-4418.png diff --git a/packages/rebuilt-map/full-field-4418.png b/packages/rebuilt-map/images/full-field-4418.png similarity index 100% rename from packages/rebuilt-map/full-field-4418.png rename to packages/rebuilt-map/images/full-field-4418.png diff --git a/packages/rebuilt-map/red-field-4418.png b/packages/rebuilt-map/images/red-field-4418.png similarity index 100% rename from packages/rebuilt-map/red-field-4418.png rename to packages/rebuilt-map/images/red-field-4418.png diff --git a/packages/rebuilt-map/index.ts b/packages/rebuilt-map/index.ts index e742c7a..417e371 100644 --- a/packages/rebuilt-map/index.ts +++ b/packages/rebuilt-map/index.ts @@ -1,8 +1,8 @@ // בס"ד -import blue from "./blue-field-4418.png"; +import blue from "./images/blue-field-4418.png"; export const blueField = blue; -import red from "./red-field-4418.png"; +import red from "./images/red-field-4418.png"; export const redField = red; export const ALLIANCE_ZONE_WIDTH_PIXELS = 395; From 339629db27ea94bf30a2ad1fa0809ba8e909ad06 Mon Sep 17 00:00:00 2001 From: YoniKiriaty Date: Wed, 4 Feb 2026 16:30:06 +0200 Subject: [PATCH 04/11] Yoni - added units and conversions --- .../backend/src/fuel/distance-split.ts | 12 ++++----- packages/rebuilt-map/index.ts | 11 ++------ packages/rebuilt-map/map.ts | 5 ++++ packages/rebuilt-map/units.ts | 26 +++++++++++++++++++ 4 files changed, 38 insertions(+), 16 deletions(-) create mode 100644 packages/rebuilt-map/map.ts create mode 100644 packages/rebuilt-map/units.ts diff --git a/apps/scouting/backend/src/fuel/distance-split.ts b/apps/scouting/backend/src/fuel/distance-split.ts index 7e3dc86..46cb464 100644 --- a/apps/scouting/backend/src/fuel/distance-split.ts +++ b/apps/scouting/backend/src/fuel/distance-split.ts @@ -1,13 +1,8 @@ // בס"ד -import type { Point } from "@repo/scouting_types"; +import { convertFromPixelsToCentimeters, distanceFromHub } from "@repo/rebuilt_map"; import type { FuelEvents, FuelObject } from "./fuel-object"; import { calculateAverage } from "@repo/array-functions"; -const hubPosition = { x: 1, y: 2 }; -export const distanceFromHub = (point: Point): number => { - return Math.sqrt(Math.pow(point.x, 2) + Math.pow(point.y, 2)); -}; - const averageFuel = (fuels: FuelObject[]): FuelObject => { const averageOfKey = (key: FuelEvents) => calculateAverage(fuels, (value) => value[key]); @@ -26,7 +21,10 @@ export const splitByDistances = ( const distancedFuels = distances.map((distance) => ({ distance, fuel: fuels.filter((fuel) => - fuel.positions.every((position) => distanceFromHub(position) < distance), + fuel.positions.every( + (position) => + distanceFromHub(convertFromPixelsToCentimeters(position)) < distance, + ), ), })); diff --git a/packages/rebuilt-map/index.ts b/packages/rebuilt-map/index.ts index 417e371..7e8d6a2 100644 --- a/packages/rebuilt-map/index.ts +++ b/packages/rebuilt-map/index.ts @@ -1,10 +1,3 @@ // בס"ד - -import blue from "./images/blue-field-4418.png"; -export const blueField = blue; -import red from "./images/red-field-4418.png"; -export const redField = red; - -export const ALLIANCE_ZONE_WIDTH_PIXELS = 395; -export const TWO_THIRDS_FIELD_WIDTH_PIXELS = 1010; -export const FIELD_HEIGHT_PIXELS = 652; +export * from "./map"; +export * from "./units"; diff --git a/packages/rebuilt-map/map.ts b/packages/rebuilt-map/map.ts new file mode 100644 index 0000000..02cbd68 --- /dev/null +++ b/packages/rebuilt-map/map.ts @@ -0,0 +1,5 @@ +// בס"ד +import blue from "./images/blue-field-4418.png"; +export const blueField = blue; +import red from "./images/red-field-4418.png"; +export const redField = red; diff --git a/packages/rebuilt-map/units.ts b/packages/rebuilt-map/units.ts new file mode 100644 index 0000000..e187ab2 --- /dev/null +++ b/packages/rebuilt-map/units.ts @@ -0,0 +1,26 @@ +// בס"ד +import type { Point } from "@repo/scouting_types"; + +export const ALLIANCE_ZONE_WIDTH_PIXELS = 395; +export const TWO_THIRDS_FIELD_WIDTH_PIXELS = 1010; +export const FIELD_HEIGHT_PIXELS = 652; + +const FIELD_SIZE_CENTIMETERS = { x: 1654, y: 807 }; +const CENTER_HUB_POINT_CENTIMETERS = { + x: 462.534, + y: 403.5, +}; + +export const convertFromPixelsToCentimeters = (point: Point): Point => ({ + x: (point.x / TWO_THIRDS_FIELD_WIDTH_PIXELS) * FIELD_SIZE_CENTIMETERS.x, + y: (point.y / FIELD_HEIGHT_PIXELS) * FIELD_SIZE_CENTIMETERS.y, +}); + +export const distanceFromHub = (point: Point): number => { + const difference = { + x: point.x - CENTER_HUB_POINT_CENTIMETERS.x, + y: point.y - CENTER_HUB_POINT_CENTIMETERS.y, + }; + // eslint-disable-next-line @typescript-eslint/no-magic-numbers + return Math.sqrt(Math.pow(difference.x, 2) + Math.pow(difference.y, 2)); +}; From ef0d5d149befc4b2b9a7312fc9d5974689f40c5e Mon Sep 17 00:00:00 2001 From: YoniKiriaty Date: Wed, 4 Feb 2026 16:33:19 +0200 Subject: [PATCH 05/11] Yoni - prettier --- apps/scouting/backend/src/fuel/distance-split.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/scouting/backend/src/fuel/distance-split.ts b/apps/scouting/backend/src/fuel/distance-split.ts index 46cb464..c93671f 100644 --- a/apps/scouting/backend/src/fuel/distance-split.ts +++ b/apps/scouting/backend/src/fuel/distance-split.ts @@ -1,5 +1,8 @@ // בס"ד -import { convertFromPixelsToCentimeters, distanceFromHub } from "@repo/rebuilt_map"; +import { + convertFromPixelsToCentimeters, + distanceFromHub, +} from "@repo/rebuilt_map"; import type { FuelEvents, FuelObject } from "./fuel-object"; import { calculateAverage } from "@repo/array-functions"; From af8e28347830baa6ad1b962313e7bc6f3e0da7a3 Mon Sep 17 00:00:00 2001 From: YoniKiriaty Date: Wed, 4 Feb 2026 16:37:50 +0200 Subject: [PATCH 06/11] Yoni - distance --- packages/rebuilt-map/units.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/rebuilt-map/units.ts b/packages/rebuilt-map/units.ts index e187ab2..13e521e 100644 --- a/packages/rebuilt-map/units.ts +++ b/packages/rebuilt-map/units.ts @@ -16,11 +16,11 @@ export const convertFromPixelsToCentimeters = (point: Point): Point => ({ y: (point.y / FIELD_HEIGHT_PIXELS) * FIELD_SIZE_CENTIMETERS.y, }); -export const distanceFromHub = (point: Point): number => { - const difference = { - x: point.x - CENTER_HUB_POINT_CENTIMETERS.x, - y: point.y - CENTER_HUB_POINT_CENTIMETERS.y, - }; - // eslint-disable-next-line @typescript-eslint/no-magic-numbers - return Math.sqrt(Math.pow(difference.x, 2) + Math.pow(difference.y, 2)); -}; +const distanceFromDifference = (difference: Point): number => + Math.sqrt(difference.x * difference.x + difference.y * difference.y); + +const distance = (p1: Point, p2: Point): number => + distanceFromDifference({ x: p1.x - p2.x, y: p1.y - p2.y }); + +export const distanceFromHub = (point: Point): number => + distance(point, CENTER_HUB_POINT_CENTIMETERS); From 1fe3ae2cd6f136fda8c2ac96daefd613d7c9ba94 Mon Sep 17 00:00:00 2001 From: YoniKiriaty Date: Wed, 4 Feb 2026 16:45:00 +0200 Subject: [PATCH 07/11] Yoni - simplified split --- .../backend/src/fuel/distance-split.ts | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/apps/scouting/backend/src/fuel/distance-split.ts b/apps/scouting/backend/src/fuel/distance-split.ts index c93671f..cd7283c 100644 --- a/apps/scouting/backend/src/fuel/distance-split.ts +++ b/apps/scouting/backend/src/fuel/distance-split.ts @@ -20,20 +20,18 @@ const averageFuel = (fuels: FuelObject[]): FuelObject => { export const splitByDistances = ( fuels: FuelObject[], distances: T[], -): Record => { - const distancedFuels = distances.map((distance) => ({ - distance, - fuel: fuels.filter((fuel) => - fuel.positions.every( - (position) => - distanceFromHub(convertFromPixelsToCentimeters(position)) < distance, +): Record => + Object.assign( + {}, + ...distances.map((distance) => ({ + [distance]: averageFuel( + fuels.filter((fuel) => + fuel.positions.every( + (position) => + distanceFromHub(convertFromPixelsToCentimeters(position)) < + distance, + ), + ), ), - ), - })); - - return Object.assign( - distancedFuels.map((distancedFuel) => ({ - [distancedFuel.distance]: averageFuel(distancedFuel.fuel), })), ); -}; From f11fa2627635c4a32c5b0e26f60cbd3540b73b24 Mon Sep 17 00:00:00 2001 From: YoniKiriaty Date: Wed, 4 Feb 2026 17:13:56 +0200 Subject: [PATCH 08/11] Yoni - made it so its hard for conflicts --- packages/rebuilt-map/units.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/rebuilt-map/units.ts b/packages/rebuilt-map/units.ts index 13e521e..ae217ac 100644 --- a/packages/rebuilt-map/units.ts +++ b/packages/rebuilt-map/units.ts @@ -5,7 +5,10 @@ export const ALLIANCE_ZONE_WIDTH_PIXELS = 395; export const TWO_THIRDS_FIELD_WIDTH_PIXELS = 1010; export const FIELD_HEIGHT_PIXELS = 652; -const FIELD_SIZE_CENTIMETERS = { x: 1654, y: 807 }; +const FIELD_SIZE_CENTIMETERS = { + x: 1654, + y: 807, +}; const CENTER_HUB_POINT_CENTIMETERS = { x: 462.534, y: 403.5, From 18e1a6e474b1a01e63943e0b995243a6517619b6 Mon Sep 17 00:00:00 2001 From: YoniKiriaty Date: Wed, 4 Feb 2026 17:14:35 +0200 Subject: [PATCH 09/11] Yoni - i forgor --- packages/rebuilt-map/units.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/rebuilt-map/units.ts b/packages/rebuilt-map/units.ts index ae217ac..60c164b 100644 --- a/packages/rebuilt-map/units.ts +++ b/packages/rebuilt-map/units.ts @@ -23,7 +23,10 @@ const distanceFromDifference = (difference: Point): number => Math.sqrt(difference.x * difference.x + difference.y * difference.y); const distance = (p1: Point, p2: Point): number => - distanceFromDifference({ x: p1.x - p2.x, y: p1.y - p2.y }); + distanceFromDifference({ + x: p1.x - p2.x, + y: p1.y - p2.y, + }); export const distanceFromHub = (point: Point): number => distance(point, CENTER_HUB_POINT_CENTIMETERS); From f7eaa499fcc38e8233b7ca3a185018eb6186200a Mon Sep 17 00:00:00 2001 From: YoniKiriaty Date: Wed, 4 Feb 2026 20:46:47 +0200 Subject: [PATCH 10/11] Yoni - fixed according to CR --- apps/scouting/backend/src/fuel/distance-split.ts | 8 ++------ packages/rebuilt-map/units.ts | 6 +++--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/apps/scouting/backend/src/fuel/distance-split.ts b/apps/scouting/backend/src/fuel/distance-split.ts index cd7283c..771f0ac 100644 --- a/apps/scouting/backend/src/fuel/distance-split.ts +++ b/apps/scouting/backend/src/fuel/distance-split.ts @@ -1,8 +1,5 @@ // בס"ד -import { - convertFromPixelsToCentimeters, - distanceFromHub, -} from "@repo/rebuilt_map"; +import { convertPixelToCentimeters, distanceFromHub } from "@repo/rebuilt_map"; import type { FuelEvents, FuelObject } from "./fuel-object"; import { calculateAverage } from "@repo/array-functions"; @@ -28,8 +25,7 @@ export const splitByDistances = ( fuels.filter((fuel) => fuel.positions.every( (position) => - distanceFromHub(convertFromPixelsToCentimeters(position)) < - distance, + distanceFromHub(convertPixelToCentimeters(position)) < distance, ), ), ), diff --git a/packages/rebuilt-map/units.ts b/packages/rebuilt-map/units.ts index 60c164b..c86a78a 100644 --- a/packages/rebuilt-map/units.ts +++ b/packages/rebuilt-map/units.ts @@ -5,16 +5,16 @@ export const ALLIANCE_ZONE_WIDTH_PIXELS = 395; export const TWO_THIRDS_FIELD_WIDTH_PIXELS = 1010; export const FIELD_HEIGHT_PIXELS = 652; -const FIELD_SIZE_CENTIMETERS = { +const FIELD_SIZE_CENTIMETERS: Point = { x: 1654, y: 807, }; -const CENTER_HUB_POINT_CENTIMETERS = { +const CENTER_HUB_POINT_CENTIMETERS: Point = { x: 462.534, y: 403.5, }; -export const convertFromPixelsToCentimeters = (point: Point): Point => ({ +export const convertPixelToCentimeters = (point: Point): Point => ({ x: (point.x / TWO_THIRDS_FIELD_WIDTH_PIXELS) * FIELD_SIZE_CENTIMETERS.x, y: (point.y / FIELD_HEIGHT_PIXELS) * FIELD_SIZE_CENTIMETERS.y, }); From 51667ff2aed8620266b391b2e0d6c94ca276c5bc Mon Sep 17 00:00:00 2001 From: YoniKiriaty Date: Wed, 4 Feb 2026 20:53:54 +0200 Subject: [PATCH 11/11] Yoni - made it an interface --- .../scouting/frontend/src/scouter/components/ScoreMap.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/scouting/frontend/src/scouter/components/ScoreMap.tsx b/apps/scouting/frontend/src/scouter/components/ScoreMap.tsx index 40e9da8..6b53525 100644 --- a/apps/scouting/frontend/src/scouter/components/ScoreMap.tsx +++ b/apps/scouting/frontend/src/scouter/components/ScoreMap.tsx @@ -55,11 +55,17 @@ const dotDiameter = dotRadius * radiusToDiameterRatio; const firstTouchIndex = 0; export const defaultPoint: Point = { x: 0, y: 0 }; + +interface RobotPositionInfo { + mapPoint: Point; + normalizedPoint: Point; + imageSize: Point; +} const getRobotPosition = ( touch: Touch, imageRect: DOMRect, containerRect: DOMRect, -) => { +): RobotPositionInfo => { const x = touch.clientX - imageRect.left; const y = touch.clientY - imageRect.top;