Skip to content

Commit

Permalink
[api]: Fix build failure
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagohm committed May 22, 2024
1 parent 617bf57 commit 31d1391
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}

Expand Down Expand Up @@ -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
}

Expand Down
15 changes: 9 additions & 6 deletions nebulosa-math/src/main/kotlin/nebulosa/math/Point2D.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 31d1391

Please sign in to comment.