Skip to content
This repository was archived by the owner on Sep 15, 2023. It is now read-only.

Commit dd6d281

Browse files
committed
Add JavaDocs for TargetGroupScorer
1 parent 83d031e commit dd6d281

File tree

1 file changed

+63
-22
lines changed

1 file changed

+63
-22
lines changed
Lines changed: 63 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,72 @@
11
package com.kylecorry.frc.vision;
22

33
public class TargetGroupScorer {
4-
public static double widthRatioScore(TargetGroup target, double idealRatio) {
5-
return Scorer.score(target.getFirstTarget().getWidth() / target.getSecondTarget().getWidth(), idealRatio);
6-
}
74

8-
public static double heightRatioScore(TargetGroup target, double idealRatio) {
9-
return Scorer.score(target.getFirstTarget().getHeight() / target.getSecondTarget().getHeight(), idealRatio);
10-
}
5+
/**
6+
* Calculate a score from 0 to 100 for the ratio of the widths of the targets.
7+
*
8+
* @param target The target group.
9+
* @param idealRatio The ideal ratio of the first individual target width over the second individual target width.
10+
* @return A score from 0 to 100.
11+
*/
12+
public static double widthRatioScore(TargetGroup target, double idealRatio) {
13+
return Scorer.score(target.getFirstTarget().getWidth() / target.getSecondTarget().getWidth(), idealRatio);
14+
}
1115

12-
public static double topAlignmentScore(TargetGroup target) {
13-
return Scorer.score(((target.getSecondTarget().getPosition().y - target.getFirstTarget().getPosition().y)
14-
/ target.getFirstTarget().getHeight()) + 1, 1);
15-
}
16+
/**
17+
* Calculate a score from 0 to 100 for the ratio of the heights of the targets.
18+
*
19+
* @param target The target group.
20+
* @param idealRatio The ideal ratio of the first individual target height over the second individual target height.
21+
* @return A score from 0 to 100.
22+
*/
23+
public static double heightRatioScore(TargetGroup target, double idealRatio) {
24+
return Scorer.score(target.getFirstTarget().getHeight() / target.getSecondTarget().getHeight(), idealRatio);
25+
}
1626

17-
public static double leftAlignmentScore(TargetGroup target) {
18-
return Scorer.score(((target.getSecondTarget().getPosition().x - target.getFirstTarget().getPosition().x)
19-
/ target.getFirstTarget().getWidth()) + 1, 1);
20-
}
27+
/**
28+
* Calculates a score from 0 to 100 for the targets being aligned to the top of the bounding box drawn around the target group.
29+
*
30+
* @param target The target group.
31+
* @return a score from 0 to 100.
32+
*/
33+
public static double topAlignmentScore(TargetGroup target) {
34+
return Scorer.score(((target.getSecondTarget().getPosition().y - target.getFirstTarget().getPosition().y)
35+
/ target.getFirstTarget().getHeight()) + 1, 1);
36+
}
2137

22-
public static double targetWidthToGroupWidthScore(TargetGroup target, double idealRatio) {
23-
return Scorer.score(target.getFirstTarget().getWidth() / (target.getSecondTarget().getPosition().x
24-
+ target.getSecondTarget().getWidth() - target.getFirstTarget().getPosition().x), idealRatio);
25-
}
38+
/**
39+
* Calculates a score from 0 to 100 for the targets being aligned to the left of the bounding box drawn around the target group.
40+
*
41+
* @param target The target group.
42+
* @return a score from 0 to 100.
43+
*/
44+
public static double leftAlignmentScore(TargetGroup target) {
45+
return Scorer.score(((target.getSecondTarget().getPosition().x - target.getFirstTarget().getPosition().x)
46+
/ target.getFirstTarget().getWidth()) + 1, 1);
47+
}
2648

27-
public static double targetHeightToGroupHeightScore(TargetGroup target, double idealRatio) {
28-
return Scorer.score(target.getFirstTarget().getHeight() / (target.getSecondTarget().getPosition().y
29-
+ target.getSecondTarget().getHeight() - target.getFirstTarget().getPosition().y), idealRatio);
30-
}
49+
/**
50+
* Calculate a score from 0 to 100 for the ratio of the width of the first target and the target group width.
51+
*
52+
* @param target The target group.
53+
* @param idealRatio The ideal ratio of the first individual target width over the target group width.
54+
* @return A score from 0 to 100.
55+
*/
56+
public static double targetWidthToGroupWidthScore(TargetGroup target, double idealRatio) {
57+
return Scorer.score(target.getFirstTarget().getWidth() / (target.getSecondTarget().getPosition().x
58+
+ target.getSecondTarget().getWidth() - target.getFirstTarget().getPosition().x), idealRatio);
59+
}
60+
61+
/**
62+
* Calculate a score from 0 to 100 for the ratio of the height of the first target and the target group height.
63+
*
64+
* @param target The target group.
65+
* @param idealRatio The ideal ratio of the first individual target height over the target group height.
66+
* @return A score from 0 to 100.
67+
*/
68+
public static double targetHeightToGroupHeightScore(TargetGroup target, double idealRatio) {
69+
return Scorer.score(target.getFirstTarget().getHeight() / (target.getSecondTarget().getPosition().y
70+
+ target.getSecondTarget().getHeight() - target.getFirstTarget().getPosition().y), idealRatio);
71+
}
3172
}

0 commit comments

Comments
 (0)