Ejemplo n.º 1
0
//TODO: requires values to be added in time order
void DataSeries::addValue(double time, double value, bool scale) {
	if (timestamps.size() > 0 && time < timestamps.last())  {//qDebug() << time << "vs." << timestamps.last();
		qWarning() << time << timestamps.last();
	}
	if (scale) value *= descriptor->factor();
	//qDebug() << descriptor->str() << ": Adding " << value << "at time" << time;
	if (value < _min) {
		_min = value;
		emit newMin(value);
	}
	if (value > _max) {
		_max = value;
		emit newMax(value);
	}
	double _oldavg = _avg;
	if (values.size() > 0) {
		//double t = time - timestamps.last();
		//double v1 = values.last();
		double avgval = value; //v1*t+(value-v1)*t/2;
		_avg += (avgval-_avg)/(values.size()+1);
		//qWarning() << _avg << avgval;
	} else {
		_avg = value;
	}
	values.append(value);
	timestamps.append(time);
	if (_oldavg != _avg) {
		emit newAvg(_avg);
	}
	emit newValue(time,value);
	emit valuesUpdated(timestamps,values);
}
Ejemplo n.º 2
0
void DataSeries::clear() {
	_min = std::numeric_limits<double>::max();
	_max = std::numeric_limits<double>::min();
	_avg = 0;
	timestamps.clear();
	values.clear();
	emit newAvg(0);
	emit newMax(_max);
	emit newMin(_min);
}
Ejemplo n.º 3
0
bool BoundingBox::intersects( std::list<Vector> vectors, BoundingBox &other){
    
    GLfloat rot[3];
    other.getRotation( rot);
    
    Matrix4f transformationMatrix;
    Matrix4f rotationMatrix;
    
    rotationMatrix.rotate( -rotation[0], -rotation[1], -rotation[2]);
    
    rotationMatrix.rotate( rot[0], rot[1], rot[2]);
    
    Matrix4f axis;
    
    GLfloat mins[3], maxes[3];
                        
    for (int i=0; i<NUM_DIMENSIONS; i++) {
        
        Vector v( axis[ i * (NUM_DIMENSIONS +1) ], axis[ i * (NUM_DIMENSIONS +1) +1], axis[i* (NUM_DIMENSIONS +1) +2] );
        
        Matrix matrixVector = rotationMatrix * v;
        Vector newV(matrixVector);
        
        findExtremePoint(vectors, newV, mins + i, maxes + i);
    }
    
    Vector newMin( mins[0], mins[1], mins[2]);
    Vector newMax( maxes[0], maxes[1], maxes[2]);
    
    Vector translate(other.getTranslation());
    transformationMatrix.rotate( rotation[0], rotation[1], rotation[2]);
    transformationMatrix.translate( translation.getX(), translation.getY(), translation.getZ());
    transformationMatrix.rotate( -rot[0], -rot[1], -rot[2]);
    transformationMatrix.translate( -translate.getX(), -translate.getY(), -translate.getZ());

    newMin = transformationMatrix * newMin;
    newMax = transformationMatrix * newMax;
    
    if ( newMax.getX() + EPSILON < other.getMin().getX() || other.getMax().getX() + EPSILON< newMin.getX() )
        return false;
    if ( newMax.getY() + EPSILON < other.getMin().getY() || other.getMax().getY() + EPSILON< newMin.getY() )
        return false;
    if ( newMax.getZ() + EPSILON < other.getMin().getZ() || other.getMax().getZ() + EPSILON< newMin.getZ() )
        return false;
    
    return true;
}