Kstars

poleaxis.cpp
1/*
2 SPDX-FileCopyrightText: 2020 Chris Rowland <chris.rowland@cherryfield.me.uk>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "poleaxis.h"
8
9#include <cmath>
10
11
12/******************************************************************
13poleAxis(sp1, sp2, sp3) finds the mount's RA axis of rotation determined
14by three points sampled by fixing the mount's DEC and sampling a point
15a three different RA position.
16
17For each SkyPoint sp, it finds its corresponding x,y,z coordinates,
18which are points on a unit sphere. Those 3 coordinates define a plane.
19That plane intesects the sphere, and the intersection of a plane and a
20sphere is a circle. The center of that circle would be the axis of rotation
21defined by the origial 3 points. So, finding the normal to the plane,
22and pointing in that (normal) direction from the center of the sphere
23(the origin) gives the axis of rotation of the mount.
24
25poleAxis returns the normal. The way to interpret this vector
26is a unit vector (direction) in the x,y,z space. To convert this back to an
27angle useful for polar alignment, the ra and dec angles can be
28retrieved with the primary(V) and secondary(V) functions.
29These can then be turned into an altitude and azimuth angles using methods
30in the SkyPoint class.
31
32Further detail
33
34Definitions: SkyPoint sp contains an hour angle ha and declication dec,
35with the usual convention that dec=0 is the equator, dec=90 is the north pole
36about which the axis spins, and ha is the spin angle
37(positive is counter clockwise when looking north from the center of the sphere)
38where 0-degrees would be pointing "up", e.g. toward the zenith when
39looking at the north pole. The sphere has radius 1.0.
40
41dirCos(sp) will return a 3D vector V whose components x,y,z
42are 3D cartesean coordinate positions given these ha & dec angles
43for points on the surface of a unit sphere.
44The z direction points towards the north pole.
45The y direction points left when looking at the north pole
46The x direction points "up".
47
48primary(V) where V contains the above x,y,z coordinates,
49will return the ha angle pointing to V.
50
51secondary(V) where V contains the above x,y,z coordinates,
52will return the dec angle pointing to V.
53******************************************************************/
54
55Rotations::V3 PoleAxis::dirCos(const dms primary, const dms secondary)
56{
57 return Rotations::V3(
58 static_cast<float>(secondary.cos() * primary.cos()),
59 static_cast<float>(secondary.cos() * primary.sin()),
60 static_cast<float>(secondary.sin()));
61}
62
63Rotations::V3 PoleAxis::dirCos(const SkyPoint sp)
64{
65 return dirCos(sp.ra(), sp.dec());
66}
67
68dms PoleAxis::primary(Rotations::V3 dirCos)
69{
70 dms p;
71 p.setRadians(static_cast<double>(std::atan2(dirCos.y(), dirCos.x())));
72 return p;
73}
74
75dms PoleAxis::secondary(Rotations::V3 dirCos)
76{
77 dms p;
78 p.setRadians(static_cast<double>(std::asin(dirCos.z())));
79 return p;
80}
81
83{
84 return SkyPoint(primary(dc), secondary(dc));
85}
86
88{
89 // convert the three positions to vectors, these define the plane
90 // of the Ha axis rotation
91 Rotations::V3 v1 = PoleAxis::dirCos(p1);
92 Rotations::V3 v2 = PoleAxis::dirCos(p2);
93 Rotations::V3 v3 = PoleAxis::dirCos(p3);
94
95 // the Ha axis direction is the normal to the plane
96 Rotations::V3 p = Rotations::V3::normal(v1, v2, v3);
97
98 // p points to the north or south pole depending on the rotation of the points
99 // the other pole position can be determined by reversing the sign of the Dec and
100 // adding 12hrs to the Ha value.
101 // if we want only the north then this would do it
102 //if (p.z() < 0)
103 // p = -p;
104 return p;
105}
static dms primary(Rotations::V3 dirCos)
primary returns the primary dms value in the directional cosine
Definition poleaxis.cpp:68
static SkyPoint skyPoint(Rotations::V3 dc)
skyPoint returns a skypoint derived from the directional cosine vector
Definition poleaxis.cpp:82
static Rotations::V3 poleAxis(SkyPoint p1, SkyPoint p2, SkyPoint p3)
poleAxis returns the pole axis vector given three SkyPoints with the same mount declination
Definition poleaxis.cpp:87
static Rotations::V3 dirCos(const dms primary, const dms secondary)
dirCos converts primary and secondary angles to a directional cosine
Definition poleaxis.cpp:55
static dms secondary(Rotations::V3 dirCos)
secondary returns the secondary dms angle in the directional cosine
Definition poleaxis.cpp:75
The sky coordinates of a point in the sky.
Definition skypoint.h:45
const CachingDms & dec() const
Definition skypoint.h:269
const CachingDms & ra() const
Definition skypoint.h:263
An angle, stored as degrees, but expressible in many ways.
Definition dms.h:38
double cos() const
Compute the Angle's Cosine.
Definition dms.h:290
virtual void setRadians(const double &Rad)
Set angle according to the argument, in radians.
Definition dms.h:333
double sin() const
Compute the Angle's Sine.
Definition dms.h:258
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.