Answer the question
In order to leave comments, you need to log in
Draw an arrow at the tachometer, new coordinates
const double PI=3.14;
double rad = 0.0;
int X,Y;
const int R=10*size;
float k=(max-min)/6;
int n[7];
for (int i = 0; i < 7; i++) {
n[i]=min+k*i;
}
for (int i = -45, j=6; i <315;i+=45) {
if (i!=270) {
rad = (i * (PI/180));
Y = y-R * sin(rad);
X = x+R * cos(rad);
int Y1 = y-R*0.8 * sin(rad);
int X1 = x+R*0.8 * cos(rad);
int Y2 = y-R*0.7 * sin(rad);
int X2 = x+R*0.7 * cos(rad);
image ->Canvas->MoveTo(X1,Y1);
image ->Canvas->LineTo(X,Y);
image->Canvas->TextOutW(X2,Y2, n[j]);
j--;
}
//стрелка
if (max!=0 && min!=0) {
float i =225-value*(360/(float(max - min)) );
ShowMessage(i);
rad = (i * PI/180);
int Y3 = y-R * sin(rad);
int X3 = x+R * cos(rad);
image ->Canvas->MoveTo(x,y);
image ->Canvas->LineTo(X3,Y3);
image ->Canvas->TextOutW(X3,Y3,value);
}
Answer the question
In order to leave comments, you need to log in
We translate the value for the tachometer into the range from 0 to 1 (0 is the minimum, judging by the figure - 720, 1 - the maximum value, 960). Multiply by the maximum number of degrees (270). Thus, for 720 you will have 0 degrees, for 960 - 270. Add the desired constant angle (your 720 is clearly not at the zero of the circle)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question