typedef struct _XFORM { FLOAT eM11; 水平缩放因子,旋转角度的余弦 FLOAT eM12; 水平比例因子,旋转角度的正弦 FLOAT eM21; 垂直比例因子,旋转角度的正弦负值 FLOAT eM22; 垂直缩放因子,旋转角度的余弦 FLOAT eDx; 水平转换偏差 FLOAT eDy; 垂直转换偏差 } XFORM; |
X’ = x * eM11 + y * eM21 + eDx Y’ = x * eM12 + y * eM22 + eDy |
void __fast call TForm1::rotatedraw(int x, int y,/* 中心点是指围绕旋转的点*/float ff, /*指针值是指针指向的数值*/float hr,float lr, /*量程范围是指针表的显示数值区间*/ float scale0,float scale1, /*角度范围是指针表的显示角度区间*/float rscale, /*零点角度是指针表的最小显示数值角度*/ Graphics::TBitmap *p/*指针位图是指针的标准横向由左向右的位图指针*/){ XFORM xform; Float tf, f; /*防止除零导致浮点溢出*/ If (x==0) x=0.0001; /*旋转角度换算*/ To=(ff-lr)*(scale0-scale1)/(hr-lr)-rscale; F=3.14159265*tf/180; /*转换坐标系定义*/ Xform.eM11 = cos (f); Xform.eM12 = sin (f); Xform.eM21 = -sin (f); Xform.eM22 = cos (f); Xform.eDx =x- (sqrt (x*x+y*y))*(cos (f+atan (y/x)));//-sin (f)*p->Height/2; Xform.eDy =y- (sqrt (x*x+y*y))*(sin (f+atan (y/x)));//-cos (f)*p->Height/2; /*转换坐标系设置*/ SetGraphicsMode (Form1->Canvas->Handle, GM_ADVANCED); SetWorldTransform (Form1->Canvas->Handle, &xform); /*透明方式*/ P->Transparent = true; /*透明颜色定义*/ P->Transparent Color = p->Canvas->Pixels [0][0]; /*指针绘制*/ Form1->Canvas->Draw (x, y, p); |