Change notation for arc angles. WARNING meaning changed without API change

This commit is contained in:
Alexander Nozik 2022-09-12 14:05:01 +03:00
parent 890a1bceca
commit 1808a9b7d3
No known key found for this signature in database
GPG Key ID: F7FCF2DD25C71357
5 changed files with 17 additions and 12 deletions

View File

@ -10,7 +10,7 @@ val ktorVersion by extra("2.0.3")
allprojects {
group = "center.sciprog"
version = "0.1.0-dev-3"
version = "0.1.0-dev-4"
}
ksciencePublish{

View File

@ -24,6 +24,7 @@ import kotlin.math.PI
import kotlin.random.Random
import center.sciprog.maps.coordinates.kilometers
import center.sciprog.maps.coordinates.radians
import center.sciprog.maps.coordinates.Angle
private fun GeodeticMapCoordinates.toShortString(): String =
"${(latitude.degrees.value).toString().take(6)}:${(longitude.degrees.value).toString().take(6)}"
@ -92,7 +93,7 @@ fun App() {
drawLine(start = Offset(-10f, 10f), end = Offset(10f, -10f), color = Color.Red)
}
arc(pointOne, 10.0.kilometers, 0f.radians, PI.radians)
arc(pointOne, 10.0.kilometers, (PI/4).radians, -Angle.pi/2)
line(pointOne, pointTwo, id = "line")
text(pointOne, "Home", font = { size = 32f })

View File

@ -108,10 +108,14 @@ public class MapLineFeature(
override fun getBoundingBox(zoom: Double): GmcRectangle = GmcRectangle(a, b)
}
/**
* @param startAngle the angle from parallel downwards for the start of the arc
* @param arcLength arc length
*/
public class MapArcFeature(
public val oval: GmcRectangle,
public val startAngle: Angle,
public val endAngle: Angle,
public val arcLength: Angle,
override val zoomRange: IntRange = defaultZoomRange,
public val color: Color = Color.Red,
) : MapFeature {

View File

@ -134,31 +134,31 @@ public fun MapFeatureBuilder.line(
public fun MapFeatureBuilder.arc(
oval: GmcRectangle,
startAngle: Angle,
endAngle: Angle,
arcLength: Angle,
zoomRange: IntRange = defaultZoomRange,
color: Color = Color.Red,
id: FeatureId? = null,
): FeatureId = addFeature(
id,
MapArcFeature(oval, startAngle, endAngle, zoomRange, color)
MapArcFeature(oval, startAngle, arcLength, zoomRange, color)
)
public fun MapFeatureBuilder.arc(
center: Pair<Double, Double>,
radius: Distance,
startAngle: Angle,
endAngle: Angle,
arcLength: Angle,
zoomRange: IntRange = defaultZoomRange,
color: Color = Color.Red,
id: FeatureId? = null,
): FeatureId = addFeature(
id,
MapArcFeature(
GmcRectangle.square(center.toCoordinates(), radius, radius),
startAngle,
endAngle,
zoomRange,
color
oval = GmcRectangle.square(center.toCoordinates(), radius, radius),
startAngle = startAngle,
arcLength = arcLength,
zoomRange = zoomRange,
color = color
)
)

View File

@ -254,7 +254,7 @@ public actual fun MapView(
addArcRad(
Rect(topLeft, bottomRight),
feature.startAngle.radians.value.toFloat(),
(feature.endAngle - feature.startAngle).radians.value.toFloat()
feature.arcLength.radians.value.toFloat()
)
}