Skip to content

Commit

Permalink
Merge pull request #56 from Mineinjava/refactor-lineseghitcircle
Browse files Browse the repository at this point in the history
refactor lineseghitcircle
  • Loading branch information
Mineinjava authored Aug 8, 2024
2 parents 144dc0d + 6825f43 commit e42eb49
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static boolean epsilonEquals(double value1, double value2) {
*
* <p>https://stackoverflow.com/a/1084899/13224997
*/
public static boolean LineSegHitCircle(
public static boolean lineSegHitCircle(
Pose2d lineSegStart, Pose2d lineSegEnd, Pose2d circleCenter, double circleRadius) {

Vec2d d = lineSegEnd.vec().subtract(lineSegStart.vec());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public boolean isHit(double radius, Pose2d robotPose, Pose2d oldRobotPose) {
if (this.distanceTo(robotPose) < radius) {
return true;
} else {
return MathUtil.LineSegHitCircle(robotPose, oldRobotPose, this, radius);
return MathUtil.lineSegHitCircle(robotPose, oldRobotPose, this, radius);
}
}

Expand Down
8 changes: 4 additions & 4 deletions quail/src/test/java/quail/util/MathUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void EpsilionEquals() {
@Test
void SkewerCircle() {
assertTrue(
MathUtil.LineSegHitCircle(
MathUtil.lineSegHitCircle(
new Pose2d(0, -1, 0), new Pose2d(0, 1, 0), new Pose2d(0, 0, 0), 0.1),
"skewer");
}
Expand All @@ -53,22 +53,22 @@ void SkewerCircle() {
@Disabled
void PopCircle() { // TODO: Fix the function do make this work
assertTrue(
MathUtil.LineSegHitCircle(new Pose2d(0, 0, 0), new Pose2d(1, 1, 0), new Pose2d(0, 0, 0), 1),
MathUtil.lineSegHitCircle(new Pose2d(0, 0, 0), new Pose2d(1, 1, 0), new Pose2d(0, 0, 0), 1),
"pop");
}

@Test
void InsideCircle() {
assertFalse(
MathUtil.LineSegHitCircle(
MathUtil.lineSegHitCircle(
new Pose2d(-1, -1, 0), new Pose2d(1, 1, 0), new Pose2d(0, 0, 0), 10),
"inside");
}

@Test
void MissCircle() {
assertFalse(
MathUtil.LineSegHitCircle(
MathUtil.lineSegHitCircle(
new Pose2d(-1, -1, 0), new Pose2d(1, 1, 0), new Pose2d(0, -10, 0), 1),
"miss");
}
Expand Down
2 changes: 1 addition & 1 deletion quail/src/test/java/quail/util/geometry/Pose2dTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void IsHit() {
Pose2d oldRobotPose = new Pose2d(2, 2, 0);
double radius = 1.5;
boolean expected =
true; // Assume the circle is hit based on provided MathUtil.LineSegHitCircle behavior
true; // Assume the circle is hit based on provided MathUtil.lineSegHitCircle behavior
boolean result = pose.isHit(radius, robotPose, oldRobotPose);
assertEquals(expected, result);
}
Expand Down

0 comments on commit e42eb49

Please sign in to comment.