-
Notifications
You must be signed in to change notification settings - Fork 0
Fuel Distance #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Fuel Distance #36
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
79e4c27
Yoni - split to module
YoniKiriaty 56e6c96
Yoni - added rebuilt map
YoniKiriaty 464a081
Yoni - solid
YoniKiriaty 339629d
Yoni - added units and conversions
YoniKiriaty ef0d5d1
Yoni - prettier
YoniKiriaty af8e283
Yoni - distance
YoniKiriaty 1fe3ae2
Yoni - simplified split
YoniKiriaty f11fa26
Yoni - made it so its hard for conflicts
YoniKiriaty 18e1a6e
Yoni - i forgor
YoniKiriaty f7eaa49
Yoni - fixed according to CR
YoniKiriaty 51667ff
Yoni - made it an interface
YoniKiriaty 0e44841
Yoni - average
YoniKiriaty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...outing/backend/src/fuel/fuel-averaging.ts → ...d/src/fuel/calculations/fuel-averaging.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/scouting/backend/src/fuel/fuel-match.ts → ...ckend/src/fuel/calculations/fuel-match.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // בס"ד | ||
| import { convertPixelToCentimeters, distanceFromHub } from "@repo/rebuilt_map"; | ||
| import type { FuelEvents, FuelObject } from "./fuel-object"; | ||
| import { calculateAverage } from "@repo/array-functions"; | ||
|
|
||
| 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 = <T extends number>( | ||
| fuels: FuelObject[], | ||
| distances: T[], | ||
| ): Record<T, FuelObject> => | ||
| Object.assign( | ||
| {}, | ||
| ...distances.map((distance) => ({ | ||
| [distance]: averageFuel( | ||
| fuels.filter((fuel) => | ||
| fuel.positions.every( | ||
| (position) => | ||
| distanceFromHub(convertPixelToCentimeters(position)) < distance, | ||
| ), | ||
| ), | ||
| ), | ||
| })), | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
File renamed without changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // בס"ד | ||
| export * from "./map"; | ||
| export * from "./units"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "name": "@repo/rebuilt_map", | ||
| "version": "0.1.0", | ||
| "type": "module", | ||
| "private": true, | ||
| "exports": { | ||
| ".": "./index.ts" | ||
| }, | ||
| "dependencies": {}, | ||
| "devDependencies": { | ||
| "typescript": "latest" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // בס"ד | ||
| 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: Point = { | ||
| x: 1654, | ||
| y: 807, | ||
| }; | ||
| const CENTER_HUB_POINT_CENTIMETERS: Point = { | ||
| x: 462.534, | ||
| y: 403.5, | ||
| }; | ||
|
|
||
| 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, | ||
| }); | ||
|
|
||
| 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); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.