diff --git a/api/src/main/kotlin/nebulosa/api/calibration/CalibrationFrameEntity.kt b/api/src/main/kotlin/nebulosa/api/calibration/CalibrationFrameEntity.kt index cfc214269..631dc5b9e 100644 --- a/api/src/main/kotlin/nebulosa/api/calibration/CalibrationFrameEntity.kt +++ b/api/src/main/kotlin/nebulosa/api/calibration/CalibrationFrameEntity.kt @@ -1,6 +1,9 @@ package nebulosa.api.calibration -import io.objectbox.annotation.* +import io.objectbox.annotation.Convert +import io.objectbox.annotation.Entity +import io.objectbox.annotation.Id +import io.objectbox.annotation.Index import nebulosa.api.beans.converters.database.FrameTypePropertyConverter import nebulosa.api.beans.converters.database.PathPropertyConverter import nebulosa.api.database.BoxEntity diff --git a/nebulosa-guiding-internal/src/main/kotlin/nebulosa/guiding/internal/GuideCalibrator.kt b/nebulosa-guiding-internal/src/main/kotlin/nebulosa/guiding/internal/GuideCalibrator.kt index fe19b05c5..336196527 100644 --- a/nebulosa-guiding-internal/src/main/kotlin/nebulosa/guiding/internal/GuideCalibrator.kt +++ b/nebulosa-guiding-internal/src/main/kotlin/nebulosa/guiding/internal/GuideCalibrator.kt @@ -677,12 +677,12 @@ internal class GuideCalibrator(private val guider: MultiStarGuider) { @JvmStatic private fun mountCoords(camera: Point, x: Angle, y: Angle): Point { - val hyp = camera.distance + val length = camera.length val cameraTheta = camera.angle val yAngleError = ((x - y) + PIOVERTWO).normalized - PI val xAngle = cameraTheta - x val yAngle = cameraTheta - (x + yAngleError) - return Point(hyp * xAngle.cos, hyp * yAngle.sin) + return Point(length * xAngle.cos, length * yAngle.sin) } } } diff --git a/nebulosa-guiding-internal/src/main/kotlin/nebulosa/guiding/internal/GuidePoint.kt b/nebulosa-guiding-internal/src/main/kotlin/nebulosa/guiding/internal/GuidePoint.kt index 54a4e921d..bb9a53f51 100644 --- a/nebulosa-guiding-internal/src/main/kotlin/nebulosa/guiding/internal/GuidePoint.kt +++ b/nebulosa-guiding-internal/src/main/kotlin/nebulosa/guiding/internal/GuidePoint.kt @@ -1,30 +1,8 @@ package nebulosa.guiding.internal -import nebulosa.math.Angle import nebulosa.math.Point2D -import nebulosa.math.rad -import kotlin.math.atan2 -import kotlin.math.hypot interface GuidePoint : Point2D { val valid: Boolean - - fun dX(point: Point2D): Double { - return x - point.x - } - - fun dY(point: Point2D): Double { - return y - point.y - } - - val distance - get() = hypot(x, y) - - val angle - get() = atan2(y, x).rad - - fun angle(point: Point2D): Angle { - return atan2(dY(point), dX(point)).rad - } } diff --git a/nebulosa-guiding-internal/src/main/kotlin/nebulosa/guiding/internal/MultiStarGuider.kt b/nebulosa-guiding-internal/src/main/kotlin/nebulosa/guiding/internal/MultiStarGuider.kt index 6462014ae..8992bcc7e 100644 --- a/nebulosa-guiding-internal/src/main/kotlin/nebulosa/guiding/internal/MultiStarGuider.kt +++ b/nebulosa-guiding-internal/src/main/kotlin/nebulosa/guiding/internal/MultiStarGuider.kt @@ -264,7 +264,7 @@ class MultiStarGuider : InternalGuider { return if (lockPosition(newLockPosition)) { // Update average distance right away so GetCurrentDistance // reflects the increased distance from the dither. - val dist = cameraDelta.distance + val dist = cameraDelta.length val distRA = abs(mountDelta.x) avgDistance += dist avgDistanceLong += dist @@ -276,7 +276,7 @@ class MultiStarGuider : InternalGuider { ditherRecenterDir[0] = if (mountDelta.x < 0.0) 1.0 else -1.0 ditherRecenterDir[1] = if (mountDelta.y < 0.0) 1.0 else -1.0 // Make each step a bit less than the full search region distance to avoid losing the star. - val f = (searchRegion * 0.7) / ditherRecenterRemaining.distance + val f = (searchRegion * 0.7) / ditherRecenterRemaining.length ditherRecenterStep.set(f * ditherRecenterRemaining.x, f * ditherRecenterRemaining.y) } @@ -1107,21 +1107,21 @@ class MultiStarGuider : InternalGuider { private fun transformMountCoordinatesToCameraCoordinates(mount: Point, camera: Point): Boolean { if (!mount.valid) return false - val distance = mount.distance + val length = mount.length var mountTheta = mount.angle if (abs(guideCalibrator.yAngleError) > PIOVERTWO) mountTheta = -mountTheta val xAngle = mountTheta + guideCalibrator.xAngle - camera.set(xAngle.cos * distance, xAngle.sin * distance) + camera.set(xAngle.cos * length, xAngle.sin * length) return true } private fun transformCameraCoordinatesToMountCoordinates(camera: Point, mount: Point): Boolean { if (!camera.valid) return false - val distance = camera.distance + val length = camera.length val cameraTheta = camera.angle val xAngle = cameraTheta - guideCalibrator.xAngle val yAngle = cameraTheta - (guideCalibrator.xAngle + guideCalibrator.yAngleError) - mount.set(xAngle.cos * distance, yAngle.sin * distance) + mount.set(xAngle.cos * length, yAngle.sin * length) return true } diff --git a/nebulosa-math/src/main/kotlin/nebulosa/math/Point2D.kt b/nebulosa-math/src/main/kotlin/nebulosa/math/Point2D.kt index 2fb90a0bd..988209142 100644 --- a/nebulosa-math/src/main/kotlin/nebulosa/math/Point2D.kt +++ b/nebulosa-math/src/main/kotlin/nebulosa/math/Point2D.kt @@ -16,13 +16,16 @@ interface Point2D { val length get() = hypot(x, y) - fun distance(other: Point2D): Double { - return hypot(x - other.x, y - other.y) - } + val angle + get() = atan2(y, x) - fun angle(other: Point2D): Angle { - return atan2(other.y - y, other.x - x) - } + fun dX(point: Point2D) = x - point.x + + fun dY(point: Point2D) = y - point.y + + fun distance(other: Point2D) = hypot(x - other.x, y - other.y) + + fun angle(other: Point2D): Angle = atan2(other.y - y, other.x - x) data class XY(override val x: Double, override val y: Double) : Point2D diff --git a/nebulosa-nova/src/main/kotlin/nebulosa/nova/astrometry/ELPMPP02.kt b/nebulosa-nova/src/main/kotlin/nebulosa/nova/astrometry/ELPMPP02.kt index 9061cdeca..6487f5867 100644 --- a/nebulosa-nova/src/main/kotlin/nebulosa/nova/astrometry/ELPMPP02.kt +++ b/nebulosa-nova/src/main/kotlin/nebulosa/nova/astrometry/ELPMPP02.kt @@ -6,7 +6,6 @@ import nebulosa.io.bufferedResource import nebulosa.math.Matrix3D import nebulosa.math.Vector3D import nebulosa.math.normalized -import nebulosa.math.pmod import nebulosa.time.InstantOfTime import kotlin.math.atan2 import kotlin.math.cos diff --git a/nebulosa-nova/src/main/kotlin/nebulosa/nova/astrometry/FixedStar.kt b/nebulosa-nova/src/main/kotlin/nebulosa/nova/astrometry/FixedStar.kt index 6bfe76dd9..15ba0e91a 100644 --- a/nebulosa-nova/src/main/kotlin/nebulosa/nova/astrometry/FixedStar.kt +++ b/nebulosa-nova/src/main/kotlin/nebulosa/nova/astrometry/FixedStar.kt @@ -50,8 +50,7 @@ data class FixedStar( // unit vector "u1", divided by the speed of light. val lightTime = u1.dot(observer.position) / SPEED_OF_LIGHT_AU_DAY val position = (positionAndVelocity.position + positionAndVelocity.velocity * - (observer.time.tdb.whole - epoch.tdb.whole + lightTime + observer.time.tdb.fraction - epoch.tdb.fraction) - - observer.position) + (observer.time.tdb.whole - epoch.tdb.whole + lightTime + observer.time.tdb.fraction - epoch.tdb.fraction) - observer.position) return PositionAndVelocity(position, observer.velocity - positionAndVelocity.velocity) }