summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/surfacechart/chartmodifier.cpp26
-rw-r--r--src/datavisualization/engine/surface3drenderer.cpp3
2 files changed, 18 insertions, 11 deletions
diff --git a/examples/surfacechart/chartmodifier.cpp b/examples/surfacechart/chartmodifier.cpp
index db242253..3b5d56ca 100644
--- a/examples/surfacechart/chartmodifier.cpp
+++ b/examples/surfacechart/chartmodifier.cpp
@@ -77,27 +77,33 @@ void ChartModifier::toggleSqrtSin(bool enable)
if (enable) {
qDebug() << "Create Sqrt&Sin surface, (" << m_xCount << ", " << m_zCount << ")";
- float stepZ = 16.0f / float(m_zCount);
- float stepX = 16.0f / float(m_xCount);
+ float minX = -10.0;
+ float maxX = 10.0;
+ float minZ = -10.0;
+ float maxZ = 10.0;
+ float stepX = (maxX - minX) / float(m_xCount - 1);
+ float stepZ = (maxZ - minZ) / float(m_zCount - 1);
QSurfaceDataArray *dataArray = new QSurfaceDataArray;
dataArray->reserve(m_zCount);
- for (float i = -8.0f + stepZ / 2.0f ; i < 8.0f ; i += stepZ) {
+ for (float i = 0; i < m_zCount; i++) {
QSurfaceDataRow *newRow = new QSurfaceDataRow(m_xCount);
- int index = 0;
- for (float j = -8.0f + stepX / 2.0f; j < 8.0f; j += stepX) {
- float R = qSqrt(i * i + j * j) + 0.01f;
- float y = (qSin(R) / R + 0.24f) * 1.61f;
- (*newRow)[index++].setPosition(QVector3D(j, y, i));
+ for (float j = 0; j < m_xCount; j++) {
+ float x = j * stepX + minX;
+ float z = i * stepZ + minZ;
+ float R = qSqrt(x * x + z * z) + 0.01f;
+ float y = (qSin(R) / R + 0.24f) * 1.61f + 1.0f;
+ (*newRow)[j].setPosition(QVector3D(x, y, z));
+ qDebug() << x << y << z;
}
*dataArray << newRow;
}
- m_chart->axisY()->setRange(0.0, 2.0);
+ m_chart->axisY()->setRange(1.0, 3.0);
m_chart->axisX()->setLabelFormat("%.2f");
m_chart->axisZ()->setLabelFormat("%.2f");
- resetArrayAndSliders(dataArray, -8.0, 8.0, -8.0, 8.0);
+ resetArrayAndSliders(dataArray, minZ, maxZ, minX, maxX);
m_activeSample = ChartModifier::SqrtSin;
} else {
diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp
index 64ceb47e..6238777e 100644
--- a/src/datavisualization/engine/surface3drenderer.cpp
+++ b/src/datavisualization/engine/surface3drenderer.cpp
@@ -1973,7 +1973,8 @@ QVector3D Surface3DRenderer::normalize(int x, int z)
{
float resX = (m_dataArray.at(z)->at(x).x() - m_minVisibleColumnValue)
/ (m_visibleColumnRange / 2.0f) - 1.0f;
- float resY = m_dataArray.at(z)->at(x).y() / (m_heightNormalizer / 2.0f) - 1.0f; // TODO min
+ float resY = (m_dataArray.at(z)->at(x).y() - float(m_axisCacheY.min()))
+ / (m_heightNormalizer / 2.0f) - 1.0f;
float resZ = (m_dataArray.at(z)->at(x).z() - m_minVisibleRowValue)
/ (m_visibleRowRange / -2.0f) + 1.0f;