private void updatePoiMatrix(Position pcbPoi,Position poi1, Position poi2,Position takePhotoPoi)
{
//更新對應的陣列
imagePoiList.Add(new Position() { X = (poi1.X + poi2.X) / 2, Y = (poi1.Y + poi2.Y) / 2 });
//dstPoi- takePhotoPoi,獲取takePhoto的J1與J2,
System.Windows.Point p1=new System.Windows.Point();
p1.X = pcbPoi.X - takePhotoPoi.X;
p1.Y = pcbPoi.Y - takePhotoPoi.Y;
var jAngles=this.currentRobot.GetJAngle();
double angleJ = -jAngles[0] - jAngles[1];
System.Windows.Point p2= MatrixHelper.GetRotatePoint(p1, angleJ, new System.Windows.Point() { X = 0, Y = 0 });
Position newDstPoi = new Position();
newDstPoi.X = p2.X;
newDstPoi.Y = p2.Y;
robotPoiList.Add(newDstPoi);
}
/// <summary>
/// 逆時針旋轉,獲取旋轉後的點位
/// </summary>
/// <param name="p1">待旋轉的點</param>
/// <param name="angle">旋轉角度</param>
/// <param name="center">旋轉中心</param>
/// <returns></returns>
public static Point GetRotatePoint(Point p1, double angle, Point center)
{
//使用旋轉矩陣求值
RotateTransform rotateTransform = new RotateTransform(angle, center.X, center.Y);
Point p = new Point(p1.X, p1.Y);
System.Windows.Point p2 = rotateTransform.Transform(p);
return p2;
}
作者:Bonker 出處:http://www.cnblogs.com/Bonker QQ:519841366 |