-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'pre-gkc' of https://github.com/FRCTeam1987/Robot2024 in…
…to pre-gkc
- Loading branch information
Showing
8 changed files
with
131 additions
and
36 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,51 @@ | ||
package frc.robot.util; | ||
|
||
import edu.wpi.first.math.geometry.Pose2d; | ||
import edu.wpi.first.math.geometry.Translation2d; | ||
|
||
public class RectanglePoseArea { | ||
private final Translation2d bottomLeft; | ||
private final Translation2d topRight; | ||
|
||
/** | ||
* Create a 2D rectangular area for pose calculations. | ||
* | ||
* @param bottomLeft bottom left corner of the rectangle. | ||
* @param topRight top right corner of the rectangle. | ||
*/ | ||
public RectanglePoseArea(Translation2d bottomLeft, Translation2d topRight) { | ||
this.bottomLeft = bottomLeft; | ||
this.topRight = topRight; | ||
} | ||
|
||
public double getMinX() { | ||
return bottomLeft.getX(); | ||
} | ||
|
||
public double getMaxX() { | ||
return topRight.getX(); | ||
} | ||
|
||
public double getMinY() { | ||
return bottomLeft.getY(); | ||
} | ||
|
||
public double getMaxY() { | ||
return topRight.getY(); | ||
} | ||
|
||
public Translation2d getBottomLeftPoint() { | ||
return bottomLeft; | ||
} | ||
|
||
public Translation2d getTopRightPoint() { | ||
return topRight; | ||
} | ||
|
||
public boolean isPoseWithinArea(Pose2d pose) { | ||
return pose.getX() >= bottomLeft.getX() | ||
&& pose.getX() <= topRight.getX() | ||
&& pose.getY() >= bottomLeft.getY() | ||
&& pose.getY() <= topRight.getY(); | ||
} | ||
} |
This file contains 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 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