[Kst] kdeextragear-2/kst/kst

Rick Chern rchern at interchange.ubc.ca
Fri Jul 23 22:41:12 CEST 2004


CVS commit by rchern: 

Calculate the z value more correctly


  M +4 -3      kstarray.cpp   1.2


--- kdeextragear-2/kst/kst/kstarray.cpp  #1.1:1.2
@@ -19,4 +19,5 @@
 
 #include "kstarray.h"
+#include <math.h>
 
 KstArray::KstArray(const QString &in_tag, KstVectorPtr in_Z, uint nX, uint nY, double minX, double minY, double stepX, double stepY) : KstDataObject() {
@@ -50,7 +51,7 @@ KstArray::~KstArray() {
 //otherwise uses a close position
 bool KstArray::value(double x, double y, double& z) {
-  int x_index = (int)((x - _minX) / _stepX);
-  int y_index = (int)((y - _minY) / _stepY);
-  int index =  (x_index - 1) * _nY + y_index;
+  int x_index = floor((x - _minX) / _stepX);
+  int y_index = floor((y - _minY) / _stepY);
+  int index =  x_index * _nY + y_index;
   if (x_index >= _nX || x_index < 0 || y_index >= _nY || y_index < 0) {
     return false;





More information about the Kst mailing list