-
Notifications
You must be signed in to change notification settings - Fork 0
Fuel Based On Position #47
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
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7b51668
Yoni - better stuff
YoniKiriaty 2c142a4
Yoni - shot stats
YoniKiriaty fd41ebc
Yoni - added interpolation
YoniKiriaty 8a10a2a
Yoni - moved bps and shi
YoniKiriaty 1dc0c43
Yoni - finished prototype
YoniKiriaty 236b1bd
Yoni - qual 10
YoniKiriaty af0fa7a
Yoni - fixed conflicts
YoniKiriaty 9e4817a
Yoni - added isEmpty
YoniKiriaty da0665a
Yoni - changed name to shot
YoniKiriaty 92bf1b3
Yoni - fixed according to CR
YoniKiriaty 5e70e3b
Yoni - corrected length
YoniKiriaty 778fda7
Yoni - reversed list going in average to make it in the right order
YoniKiriaty 6e049c2
Yoni - fixed comments
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
There are no files selected for viewing
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
35 changes: 35 additions & 0 deletions
35
apps/scouting/backend/src/fuel/calculations/interpolation.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // בס"ד | ||
|
|
||
| import { isEmpty } from "@repo/array-functions"; | ||
| import type { Point } from "@repo/scouting_types"; | ||
|
|
||
| const QUADRATIC_EXPONENT = 2; | ||
| const interpolateTwoPointQuadratic = (x: number, p1: Point, p2: Point) => { | ||
| // Assumes p1 is the "peak" (e.g., distance 0) | ||
| const a = (p2.y - p1.y) / p2.x ** QUADRATIC_EXPONENT; | ||
| return a * x ** QUADRATIC_EXPONENT + p1.y; | ||
| }; | ||
|
|
||
| const ONE_ITEM = 1; | ||
| const DEFAULT_EMPTY_VALUE = 0; | ||
| const LENGTH_THAT_DOESNT_INCLUDE_TWO_ITEMS = 1; | ||
| export const interpolateQuadratic = ( | ||
| x: number, | ||
| points: Point[], | ||
| emptyValue = DEFAULT_EMPTY_VALUE, | ||
| ): number => { | ||
| if (isEmpty(points)) { | ||
| return emptyValue; | ||
| } | ||
|
|
||
| const [first, second] = points; | ||
YoniKiriaty marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if (first.x >= x || points.length === LENGTH_THAT_DOESNT_INCLUDE_TWO_ITEMS) { | ||
| return first.y; | ||
| } | ||
| if (x < second.x) { | ||
| return interpolateQuadratic(x, points.slice(ONE_ITEM)); | ||
| } | ||
|
|
||
| return interpolateTwoPointQuadratic(x, first, second); | ||
| }; | ||
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 |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ import { getFormsCollection } from "./forms-router"; | |
| import { StatusCodes } from "http-status-codes"; | ||
| import { castItem } from "@repo/type-utils"; | ||
| import type { | ||
| BPS, | ||
| Match, | ||
| ScoutingForm, | ||
| SectionTeamData, | ||
|
|
@@ -26,7 +27,7 @@ import type { | |
| import { ACCURACY_DISTANCES, teamsProps } from "@repo/scouting_types"; | ||
| import { groupBy } from "fp-ts/lib/NonEmptyArray"; | ||
| import { calculateSum, isEmpty, mapObject } from "@repo/array-functions"; | ||
| import { createFuelObject, type BPS } from "../fuel/fuel-object"; | ||
| import { createFuelObject } from "../fuel/fuel-object"; | ||
| import { splitByDistances } from "../fuel/distance-split"; | ||
| import { calculateFuelStatisticsOfShift } from "../fuel/fuel-general"; | ||
|
|
||
|
|
@@ -124,9 +125,10 @@ export const getAllBPS = (): BPS[] => [ | |
| score: [1000, 2000, 3000], | ||
| // eslint-disable-next-line @typescript-eslint/no-magic-numbers | ||
| shoot: [1000, 1400, 2000, 3000], | ||
| positions: [{ x: 300, y: 200 }], | ||
| }, | ||
| ], | ||
| match: { type: "qualification", number: 8 }, | ||
| match: { type: "qualification", number: 10 }, | ||
|
Comment on lines
125
to
+131
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if this is for trial remove
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its for until the bps gets merged, as this is used in other stuff in the code it shouldnt be removed |
||
| }, | ||
| ]; | ||
|
|
||
|
|
||
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
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.