mat33 randomInertiaMatrix() { // generate random valid inertia matrix by first getting valid components // along major axes and then rotating by random amount vec3 principal = randomInertiaPrincipal(); mat33 rot(transformX(randomFloat(-BT_ID_PI, BT_ID_PI)) * transformY(randomFloat(-BT_ID_PI, BT_ID_PI)) * transformZ(randomFloat(-BT_ID_PI, BT_ID_PI))); mat33 inertia; inertia(0, 0) = principal(0); inertia(0, 1) = 0; inertia(0, 2) = 0; inertia(1, 0) = 0; inertia(1, 1) = principal(1); inertia(1, 2) = 0; inertia(2, 0) = 0; inertia(2, 1) = 0; inertia(2, 2) = principal(2); return rot * inertia * rot.transpose(); }
void getDailyGraphPg(int modul, int sensor, struct graphPacket *graph) { char query[1024]; float x_div=0.0; int temp_max,temp_min; float sec; float min,max; int i; float temperature[120]; int num_values[120]; PGresult *pgres; min = 0.0; max = 0.0; memset(graph, 0, sizeof(struct graphPacket)); if(!config.database_pg_activated) return; if(!pgconn) { initDatabase(); } if(!pgconn) return; getMinMaxTemp(modul, sensor, &max, &min); if(max == 0.0 && min == 0.0) // no data, stop return; graph->max[0] = (int)max; graph->max[1] = (max - (int)max)*10; if(graph->max[1] < 0) graph->max[1] = -graph->max[1]; graph->min[0] = (int)min; graph->min[1] = (min - (int)min)*10; if(graph->min[1] < 0) graph->min[1] = -graph->min[1]; temp_max = ((int)(ceilf((float)graph->max[0]/10.0)))*10; temp_min = ((int)(floorf((float)graph->min[0]/10.0)))*10; g_debug("Max: %d,%d Min: %d,%d\t",graph->max[0],graph->max[1],graph->min[0],graph->min[1]); g_debug("Max: %d Min: %d\t",temp_max,temp_min); for(i=0;i<120;i++) { num_values[i] = 0; temperature[i] = 0.0; } sprintf(query,"SELECT date_part('epoch',date-current_date), value FROM modul_%02d%02d WHERE date>current_date ORDER BY date asc",modul,sensor); pgres = PQexec(pgconn, query); if (PQresultStatus(pgres) != PGRES_TUPLES_OK) { g_warning("failed: %s", PQerrorMessage(pgconn)); PQclear(pgres); return; } for (i = 0; i < PQntuples(pgres); i++) { sec = atoi(PQgetvalue(pgres,i,0)); x_div = (float)sec/(60.0*60.0*24.0)*120.0; num_values[(int)x_div]++; temperature[(int)x_div] += atof(PQgetvalue(pgres,i,1)); } PQclear(pgres); graph->numberOfPoints = x_div; // Letzter Wert for(i=0;i<(int)x_div;i++) { if(num_values[i] > 0) { graph->temperature_history[i] = transformY( temperature[i]/((float)num_values[i]), temp_max, temp_min); } else if(i > 0) { graph->temperature_history[i] = graph->temperature_history[i-1]; } } }
QPointF ZStTransform::transform(const QPoint &pt) const { return QPointF(transformX(pt.x()), transformY(pt.y())); }
QRectF ZStTransform::transform(const QRectF &rect) const { return QRectF(transformX(rect.left()), transformY(rect.top()), rect.width() * getSx(), rect.height() * getSy()); }
ZPoint ZStTransform::transform(const ZPoint &pt) const { return ZPoint(transformX(pt.x()), transformY(pt.y()), transformZ(pt.z())); }