Kstars

rotations.h
1/*
2 SPDX-FileCopyrightText: 2021 Hy Murveit <hy@murveit.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <QPointF>
10
11namespace Rotations
12{
13
14// Like QVector3D but double precision.
15class V3
16{
17 public:
18 V3(double x, double y, double z) : X(x), Y(y), Z(z) {};
19 V3() : X(0.0), Y(0.0), Z(0.0) {};
20 double x() const
21 {
22 return X;
23 }
24 double y() const
25 {
26 return Y;
27 }
28 double z() const
29 {
30 return Z;
31 }
32 static V3 normal(const V3 &v1, const V3 &v2, const V3 &v3);
33 double length();
34 private:
35 double X, Y, Z;
36};
37
38// Convert degrees to radians and vica versa.
39double d2r(double degrees);
40double r2d(double radians);
41
42// With 2 args, get the axis of rotation defined by 2 points on a sphere
43// (the 3rd point is assumed to be the center of the sphere)
44// So the rotation is along the geodesic defined by the two points and the center.
45// With all three args, find the axis defined by those 3 points.
46V3 getAxis(const V3 &p1, const V3 &p2, const V3 &p3 = V3(0.0, 0.0, 0.0));
47
48// Gets the angle between 2 points on a sphere from the point of view of the
49// center of the sphere.
50double getAngle(const V3 &p1, const V3 &p2);
51
52// Rotates the point around the unit vector axis (must be a unit vector to work)
53// by degrees.
54V3 rotateAroundAxis(const V3 &point, const V3 &axis, double degrees);
55V3 rotateAroundY(const V3 &point, double degrees);
56V3 rotateAroundZ(const V3 &point, double degrees);
57
58// Converts the AzAlt (azimuth is in .x(), altitude in .y())
59// to an xyz point, and vica versa.
60V3 azAlt2xyz(const QPointF &azAlt);
61QPointF xyz2azAlt(const V3 &xyz);
62
63// Converts an xyz point to HA and DEC (ha is in .x(), dec in .y())
64// and vica versa.
65QPointF xyz2haDec(const V3 &xyz, double latitude);
66V3 haDec2xyz(const QPointF &haDec, double latitude);
67
68// Rotate the az/alt point. Used when assisting the user to correct a polar alignment error.
69// Input is the point to be rotated, Azimuth = azAltPoint.x(), Altitude = azAltPoint.y().
70// azAltRotation: the rotation angles, which correspond to the error in polar alignment
71// that we would like to correct at the pole. The returned QPointF is the rotated azimuth
72// and altitude coordinates.
73QPointF rotateRaAxis(const QPointF &azAltPoint, const QPointF &azAltRotation);
74
75} // namespace rotations
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:49:21 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.