关于halcon 版本
read_image(Image, 'fabrik')
get_image_size(Image, Width, Height)
dev_display(Image)
dev_set_draw('margin')
draw_rectangle2(3600, Row, Column, Phi, Length1, Length2)
gen_rectangle2(Rectangle, Row, Column, Phi, Length1, Length2)
tuple_cos (Phi, Cos)
tuple_sin (Phi, Sin)
dev_set_color('green')
RT_X := -Length1*Cos - Length2*Sin
RT_Y := -Length1*Sin + Length2*Cos
gen_circle (Circle, Row-RT_Y, Column+RT_X, 10)
RB_X := Length1*Cos - Length2*Sin
RB_Y := Length1*Sin + Length2*Cos
gen_circle (Circle, Row-RB_Y, Column+RB_X, 10)
LB_X := Length1*Cos + Length2*Sin
LB_Y := Length1*Sin - Length2*Cos
gen_circle (Circle, Row-LB_Y, Column+LB_X, 10)
LT_X := -Length1*Cos + Length2*Sin
LT_Y := -Length1*Sin - Length2*Cos
gen_circle (Circle, Row-LT_Y, Column+LT_X, 10)
C++版本
Point2f arry[4] = {};
float a = (float)(-Rect_points[0][1].x*cos(Rect_points[0][2].x) - Rect_points[0][1].y*sin(Rect_points[0][2].x));
float b = (float)(-Rect_points[0][1].x*sin(Rect_points[0][2].x) + Rect_points[0][1].y*cos(Rect_points[0][2].x));
Point2f A(Rect_points[0][0].x - b, Rect_points[0][0].y + a);
float c = (float)(Rect_points[0][1].x*cos(Rect_points[0][2].x) - Rect_points[0][1].y*sin(Rect_points[0][2].x));
float d = (float)(Rect_points[0][1].x*sin(Rect_points[0][2].x) + Rect_points[0][1].y*cos(Rect_points[0][2].x));
Point2f B(Rect_points[0][0].x - d, Rect_points[0][0].y + c);
float e = (float)(Rect_points[0][1].x*cos(Rect_points[0][2].x) + Rect_points[0][1].y*sin(Rect_points[0][2].x));
float f = (float)(Rect_points[0][1].x*sin(Rect_points[0][2].x) - Rect_points[0][1].y*cos(Rect_points[0][2].x));
Point2f C(Rect_points[0][0].x - f, Rect_points[0][0].y + e);
float g = (float)(-Rect_points[0][1].x*cos(Rect_points[0][2].x) + Rect_points[0][1].y*sin(Rect_points[0][2].x));
float h = (float)(-Rect_points[0][1].x*sin(Rect_points[0][2].x) - Rect_points[0][1].y*cos(Rect_points[0][2].x));
Point2f D(Rect_points[0][0].x - h, Rect_points[0][0].y + g);
arry[0] = A; arry[1] = B; arry[2] = C; arry[3] = D;