-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
John Doe
committed
Jul 25, 2018
1 parent
722b771
commit cb27835
Showing
5 changed files
with
18 additions
and
18 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
...leCollisionDetectionShape.class/instance/circleAt.mustIntersectRectangleAt.withExtent..st
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
utility | ||
circleAt: circlePos mustIntersectRectangleAt: rectanglePos withExtent: extent | ||
^ ((self absDistanceFrom: circlePos to: rectanglePos) x <= (extent x / 2) or: | ||
[(self absDistanceFrom: circlePos to: rectanglePos) y <= (extent y / 2)]) | ||
circleAt: circlePos mustIntersectRectangleAt: rectanglePos withExtent: rectangleExtent | ||
^ ((self absDistanceFrom: circlePos to: rectanglePos) x <= (rectangleExtent x / 2) or: | ||
[(self absDistanceFrom: circlePos to: rectanglePos) y <= (rectangleExtent y / 2)]) |
6 changes: 3 additions & 3 deletions
6
...nDetectionShape.class/instance/circleAt.withRadius.canIntersectRectangleAt.withExtent..st
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
utility | ||
circleAt: circlePos withRadius: radius canIntersectRectangleAt: rectanglePos withExtent: extent | ||
^ (self absDistanceFrom: circlePos to: rectanglePos) x < (extent x / 2 + radius) and: | ||
[(self absDistanceFrom: circlePos to: rectanglePos) y < (extent y / 2 + radius)] | ||
circleAt: circlePos withRadius: circleRadius canIntersectRectangleAt: rectanglePos withExtent: rectangleExtent | ||
^ (self absDistanceFrom: circlePos to: rectanglePos) x < (rectangleExtent x / 2 + circleRadius) and: | ||
[(self absDistanceFrom: circlePos to: rectanglePos) y < (rectangleExtent y / 2 + circleRadius)] |
10 changes: 5 additions & 5 deletions
10
...tectionShape.class/instance/circleAt.withRadius.isCollidingWithRectangleAt.withExtent..st
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
utility | ||
circleAt: circlePos withRadius: radius isCollidingWithRectangleAt: rectanglePos withExtent: extent | ||
circleAt: circlePos withRadius: circleRadius isCollidingWithRectangleAt: rectanglePos withExtent: rectangleExtent | ||
(self circleAt: circlePos | ||
withRadius: radius | ||
withRadius: circleRadius | ||
canIntersectRectangleAt: rectanglePos | ||
withExtent: extent) | ||
withExtent: rectangleExtent) | ||
ifFalse: [^ false]. | ||
(self circleAt: circlePos | ||
mustIntersectRectangleAt: rectanglePos | ||
withExtent: extent) | ||
withExtent: rectangleExtent) | ||
ifTrue: [^ true]. | ||
^ self circleAt: circlePos withRadius: radius isIntersectingRectangleAt: rectanglePos withExtent: extent | ||
^ self circleAt: circlePos withRadius: circleRadius isIntersectingRectangleAt: rectanglePos withExtent: rectangleExtent |
6 changes: 3 additions & 3 deletions
6
...etectionShape.class/instance/circleAt.withRadius.isIntersectingRectangleAt.withExtent..st
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
utility | ||
circleAt: circlePos withRadius: radius isIntersectingRectangleAt: rectanglePos withExtent: extent | ||
circleAt: circlePos withRadius: circleRadius isIntersectingRectangleAt: rectanglePos withExtent: rectangleExtent | ||
"Because we calculated circleDistance we can now imagine the rectangle center in 0 @ 0, | ||
the circle center at circleDistance and the rectangle corner at (aMorph extent)." | ||
^ ((self absDistanceFrom: circlePos to: rectanglePos) squaredDistanceTo: extent / 2) <= | ||
radius squared | ||
^ ((self absDistanceFrom: circlePos to: rectanglePos) squaredDistanceTo: rectangleExtent / 2) <= | ||
circleRadius squared |
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