Skip to content

Commit f5e1383

Browse files
committed
Remove second sin operation in mercator projection
Signed-off-by: Kyle Corry <[email protected]>
1 parent 620844b commit f5e1383

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main/kotlin/com/kylecorry/sol/science/geography/projections/MercatorProjection.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ class MercatorProjection(private val scale: Float = 1f) : IMapProjection {
2323

2424
override fun toPixels(location: Coordinate): Vector2 {
2525
val x = scale * location.longitude.toRadians()
26-
val y = 0.5 * ln((1 + sinDegrees(location.latitude)) / (1 - sinDegrees(location.latitude)))
26+
val sinLat = sinDegrees(location.latitude)
27+
val y = 0.5 * ln((1 + sinLat) / (1 - sinLat))
2728
return Vector2(x.toFloat(), y.toFloat())
2829
}
2930

0 commit comments

Comments
 (0)