mirror of https://github.com/qt/qtdatavis3d.git
Use qRadiansToDegrees() and qDegreesToRadians() more widely
These document what the arithmetic is actually doing; and save us an ad-hoc use of an approximate value for pi while we're about it. Task-number: QTBUG-58083 Change-Id: I82c5502af724b33ec598c5a9da76537f93a95eac Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
This commit is contained in:
parent
53fcf914e2
commit
af03eef4ab
|
|
@ -353,7 +353,7 @@ void GraphModifier::zoomToSelectedBar()
|
||||||
|
|
||||||
// Rotate the camera so that it always points approximately to the graph center
|
// Rotate the camera so that it always points approximately to the graph center
|
||||||
//! [15]
|
//! [15]
|
||||||
qreal endAngleX = qAtan(qreal(endTarget.z() / endTarget.x())) / M_PI * -180.0 + 90.0;
|
qreal endAngleX = 90.0 - qRadiansToDegrees(qAtan(qreal(endTarget.z() / endTarget.x())));
|
||||||
if (endTarget.x() > 0.0f)
|
if (endTarget.x() > 0.0f)
|
||||||
endAngleX -= 180.0f;
|
endAngleX -= 180.0f;
|
||||||
float barValue = m_graph->selectedSeries()->dataProxy()->itemAt(selectedBar.x(),
|
float barValue = m_graph->selectedSeries()->dataProxy()->itemAt(selectedBar.x(),
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,7 @@ QPoint QBar3DSeries::invalidSelectionPosition()
|
||||||
|
|
||||||
static inline float quaternionAngle(const QQuaternion &rotation)
|
static inline float quaternionAngle(const QQuaternion &rotation)
|
||||||
{
|
{
|
||||||
return qAcos(rotation.scalar()) * 360.0f / M_PI;
|
return qRadiansToDegrees(qAcos(rotation.scalar())) * 2.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
||||||
|
|
@ -1150,7 +1150,7 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
|
||||||
// Need to determine if camera is below graph top
|
// Need to determine if camera is below graph top
|
||||||
float distanceToCenter = activeCamera->position().length()
|
float distanceToCenter = activeCamera->position().length()
|
||||||
/ activeCamera->zoomLevel() / m_autoScaleAdjustment * 100.0f;
|
/ activeCamera->zoomLevel() / m_autoScaleAdjustment * 100.0f;
|
||||||
qreal cameraAngle = qreal(activeCamera->yRotation()) / 180.0 * M_PI;
|
qreal cameraAngle = qDegreesToRadians(qreal(activeCamera->yRotation()));
|
||||||
float cameraYPos = float(qSin(cameraAngle)) * distanceToCenter;
|
float cameraYPos = float(qSin(cameraAngle)) * distanceToCenter;
|
||||||
m_yFlippedForGrid = cameraYPos < (m_scaleYWithBackground - m_oldCameraTarget.y());
|
m_yFlippedForGrid = cameraYPos < (m_scaleYWithBackground - m_oldCameraTarget.y());
|
||||||
} else if (m_useOrthoProjection && activeCamera->yRotation() == 0.0f) {
|
} else if (m_useOrthoProjection && activeCamera->yRotation() == 0.0f) {
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ using namespace QtDataVisualization;
|
||||||
const int numberOfCols = 8;
|
const int numberOfCols = 8;
|
||||||
const int numberOfRows = 8;
|
const int numberOfRows = 8;
|
||||||
const float limit = 8.0f;
|
const float limit = 8.0f;
|
||||||
const float PI = 3.14159f;
|
|
||||||
#define HEDGEHOG
|
#define HEDGEHOG
|
||||||
|
|
||||||
ScatterDataModifier::ScatterDataModifier(Q3DScatter *scatter)
|
ScatterDataModifier::ScatterDataModifier(Q3DScatter *scatter)
|
||||||
|
|
@ -97,18 +96,18 @@ void ScatterDataModifier::addData()
|
||||||
|
|
||||||
for (float i = 0; i < numberOfRows; i++) {
|
for (float i = 0; i < numberOfRows; i++) {
|
||||||
float latAngle = float(i) * latAngleStep + 40.0f;
|
float latAngle = float(i) * latAngleStep + 40.0f;
|
||||||
float radius = qSin(latAngle * PI / 180.0f) * limit;
|
float radius = qSin(qDegreesToRadians(latAngle)) * limit;
|
||||||
float y = qCos(latAngle * PI / 180.0f) * 1.0f;
|
float y = qCos(qDegreesToRadians(latAngle)) * 1.0f;
|
||||||
#ifdef HEDGEHOG
|
#ifdef HEDGEHOG
|
||||||
float angleZ = (qAtan((y * limit / 2.0f) / radius) * 180.0f / PI);
|
float angleZ = qRadiansToDegrees(qAtan((y * limit / 2.0f) / radius));
|
||||||
QQuaternion rotationZ = QQuaternion::fromAxisAndAngle(QVector3D(0.0f, 0.0f, 1.0f), angleZ - 90.0f);
|
QQuaternion rotationZ = QQuaternion::fromAxisAndAngle(QVector3D(0.0f, 0.0f, 1.0f), angleZ - 90.0f);
|
||||||
#endif
|
#endif
|
||||||
for (float j = 0; j < numberOfCols; j++) {
|
for (float j = 0; j < numberOfCols; j++) {
|
||||||
float angle = float(j) * angleStep;
|
float angle = float(j) * angleStep;
|
||||||
float x = qCos(angle * PI / 180.0f) * radius;
|
float x = qCos(qDegreesToRadians(angle)) * radius;
|
||||||
float z = qSin(angle * PI / 180.0f) * radius;
|
float z = qSin(qDegreesToRadians(angle)) * radius;
|
||||||
|
|
||||||
float angleY = (qAtan(z / x) * 180.0f / PI);
|
float angleY = qRadiansToDegrees(qAtan(z / x));
|
||||||
if (x < 0)
|
if (x < 0)
|
||||||
angleY = 180.0f + angleY;
|
angleY = 180.0f + angleY;
|
||||||
if (x > 0 && z < 0)
|
if (x > 0 && z < 0)
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,6 @@
|
||||||
|
|
||||||
#include <QtCore/qmath.h>
|
#include <QtCore/qmath.h>
|
||||||
|
|
||||||
static const double DEG_TO_RAD = M_PI / 180.0;
|
|
||||||
|
|
||||||
Star::Star()
|
Star::Star()
|
||||||
: m_theta(0),
|
: m_theta(0),
|
||||||
m_a(0),
|
m_a(0),
|
||||||
|
|
@ -49,7 +47,7 @@ const void Star::calcXY()
|
||||||
const QVector2D &p = m_center;
|
const QVector2D &p = m_center;
|
||||||
|
|
||||||
qreal beta = -m_angle;
|
qreal beta = -m_angle;
|
||||||
qreal alpha = theta * DEG_TO_RAD;
|
qreal alpha = qDegreesToRadians(theta);
|
||||||
|
|
||||||
// temporaries to save cpu time
|
// temporaries to save cpu time
|
||||||
qreal cosalpha = qCos(alpha);
|
qreal cosalpha = qCos(alpha);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue