Skip to content

Commit

Permalink
invert x and y for rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
jillesvangurp committed Oct 19, 2021
1 parent 569d6d8 commit 49eb2d3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/commonMain/kotlin/com/jillesvangurp/geo/GeoGeometry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -863,8 +863,8 @@ class GeoGeometry {

// basic high school math: given an angle in radians and a distance, calculate x and y ...
val angle = toRadians((heading + degrees) % 360)
val x = cos(angle) * distance
val y = sin(angle) * distance
val x = sin(angle) * distance
val y = cos(angle) * distance

// use the x and y to translate the anchor and get the point on the circle
return GeoGeometry.translate(anchor.latitude, anchor.longitude, y, x)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ class GeoGeometryTest {
fun rotateByZeroDegreesShouldBeSamePoint() {
val anchor = bergstr16Berlin
val point = oranienburgerTor
GeoGeometry.distance(point, GeoGeometry.rotateAround(anchor, point, 0.0)) shouldBeLessThan 100.0
(GeoGeometry.distance(point, GeoGeometry.rotateAround(anchor, point, 180.0)) - 2*GeoGeometry.distance(anchor,point)).absoluteValue shouldBeLessThan 100.0
GeoGeometry.distance(point, GeoGeometry.rotateAround(anchor, point, 0.0)) shouldBeLessThan 1.0
(GeoGeometry.distance(point, GeoGeometry.rotateAround(anchor, point, 180.0)) - 2*GeoGeometry.distance(anchor,point)).absoluteValue shouldBeLessThan 1.0
}

@Test
Expand Down

0 comments on commit 49eb2d3

Please sign in to comment.