Files
qt5-legatus-legacy/Lts/Viewer/SituationMap/MathUtils/simple_helper.h
T
2026-08-13 18:33:10 +02:00

131 lines
3.5 KiB
C++
Executable File

/**
* @RDE_HEADER@
* Helper functions related to CoordinateTranslation
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
// Own
#include "situation_map_export.h"
#include <Map/point3D.h>
// Qt
#include <QPointF>
#include <QPolygonF>
// ESRI
//----------------------------------------------------------------------------
namespace SituationMap
{
namespace MathUtils
{
/**
@brief Rotate a 2 dimensional point
@param p point to rotate
@param center center point of rotation
@param sinA sinus of rotation angle
@param cosA cosinus of rotation angle
*/
QPointF SITUATIONMAP_EXPORT rotate(const QPointF &p, const QPointF &center, qreal sinA, qreal cosA);
/**
@brief Rotate a 2 dimensional point
@param p point to rotate
@param center center point of rotation
@param phi rotation angle in rad
*/
QPointF SITUATIONMAP_EXPORT rotate(const QPointF &p, const QPointF &center, qreal phi);
/**
* @brief Get math angle in radiant from orientation vector
* @param oVec orientation vector, must be normalized to length 1
* @return mathematical angle in rad
*/
qreal SITUATIONMAP_EXPORT getMathAngle(const QPointF &oVec);
/**
* @brief Get math angle in radiant from sinus and cosinus
* @param sinPhi sinus of angle, is equal to y component of orientation vector
* @param cosPhi cosinus of angle, is equal to x component of orientation vector
* @return mathematical angle in rad
*/
qreal SITUATIONMAP_EXPORT getMathAngle(qreal sinPhi, qreal cosPhi);
double SITUATIONMAP_EXPORT getAngleDegreeNorth(const QPointF &p1, const QPointF &p2);
/**
* @brief Get North angle from Math angle
* @param mathematical orientated angle in degree
* @return north (0° = 12h) orientated angle in degree
*/
qreal SITUATIONMAP_EXPORT getAngleDegree2North(qreal angleDeg);
/**
* @brief Get North angle from Math angle
* @param mathematical orientated angle in degree
* @return math (0° = 3h) orientated angle in degree
*/
qreal SITUATIONMAP_EXPORT getAngleDegree2Math(qreal angleDeg);
/**
* @brief Get the position on a given line (for positioning a text)
* @param p1 startPoint of line
* @param p2 endPoint of line
* @param position_0_to_1 value from 0.0 up to 1.0.
* 0.0 -> 0% -> startPoint
* 0.5 -> 50% -> middle between startPoint and endPoint
* 1.0 -> 100% -> endPoint
* @return position between start and end.
*/
QPointF SITUATIONMAP_EXPORT getPointOnLine(const QPointF &p1, const QPointF &p2, double position_0_to_1);
Point3D SITUATIONMAP_EXPORT getPointOnLine(const Point3D &p1, const Point3D &p2, double position_0_to_1);
/**
* @brief getCircleSectorPolygon
* @param centerPoint [geo coordinates]
* @param radius [m]
* @param rotationAngleDeg (orientation of segment)
* @param centralAngleDeg
* @return polygon describing the circle sector
*/
QPolygonF SITUATIONMAP_EXPORT getCircleSectorPolygon(const QPointF &centerPoint, qreal radius, double rotationAngleDeg, double centralAngleDeg);
/**
* @brief Rotate a point around with another point as center.
* @param pToBeRotated Point to be rotated
* @param center Center
* @param angleDegree Angle in degree (clockwise).
*/
void SITUATIONMAP_EXPORT rotatePoint(QPointF &pToBeRotated,
const QPointF &center,
double angleDegree);
QList<QPointF> SITUATIONMAP_EXPORT mineFieldCenterLineToOutline(const QList<QPointF> &centerLine,
double width);
} // namespace MathUtils
} // namespace SituationMap