旋转中心的标定

一、标定旋转中心的操作步骤

如下图,在旋转轴工具上放置一个Mark点,旋转角度,获得三个点,三点拟合圆,获得圆心坐标和旋转半径(默认已经做完九点标定,这三个点转为世界坐标后再计算圆心坐标和旋转半径)

二、三点拟合圆心

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 求圆心
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            double[] xy = new double[3];
            xy = RotateCenter(double.Parse(txtX1.Text),double.Parse(txtY1.Text),double.Parse(txtX2.Text),double.Parse(txtY2.Text),double.Parse(txtX3.Text),double.Parse(txtY3.Text));
            txtxcen.Text = xy[0].ToString();//X
            txtycen.Text = xy[1].ToString();//Y
            txtrcen.Text = xy[2].ToString();//R

        }
        public double[] RotateCenter(double x1,double y1,double x2,double y2,double x3,double y3)
        {
            double a, b, c, d, e, f;
            a = 2 * (x2-x1);
            b = 2 * (y2-y1);
            c = x2 * x2 + y2 * y2 - x1 * x1 - y1 * y1;
            d = 2 * (x3 - x2);
            e = 2 * (y3 - y2);
            f = x3 * x3 + y3 * y3 - x2 * x2 - y2 * y2;
            double x = (b * f - e * c) / (b*d-e*a);
            double y = (d*c-a*f) / (b*d-e*a);
            double r = Math.Sqrt((x1 - x) * (x1 - x) + (y1 - x) * (y1 - x));
            double[] xyr = new double[3];
            xyr[0] = x;
            xyr[1] = y;
            xyr[2] = r;
            return xyr;
        }
    }
}

三、使用旋转中心计算偏移量原理

已知:旋转中心坐标和旋转半径R
〖R=l〗_OB 〖=l〗_OA

设:
在这里插入图片描述

因为
三角形BAC 和 三角形 OAD是相似三角形
所以
在这里插入图片描述

求解上面方程:
在这里插入图片描述

四、 计算一点绕另一点旋转一定角度后新点的坐标

  • 第4节主要是为了讲清楚这个推导过程,接下来我们直接给出代码:
  • 博客链接:C# 计算一点绕另一点旋转一定角度后新点的坐标_c# 计算一条直线旋转30度后的起点和终点坐标_MechMaster的博客-CSDN博客
    using System;
    
    namespace RotatePoint
    {
        class Program
        {
            static void Main(string[] args)
            {
                double X = 0;
                double Y = 0;
                //顺时针角度为负数
                RotateAngle(1, 1, -45, 2, 2, ref X, ref Y);
    
                Console.WriteLine(X+","+Y);
                Console.ReadKey();
            }
    
            public static string RotateAngle(double XRotation, double YRotation, double ARotate, double XBefore, double YBefore, ref double XAfter, ref double YAfter)
            {
                try
                {
                    double Rad = 0;
                    Rad = ARotate * Math.Acos(-1) / 180;
                    XAfter = (XBefore - XRotation) * Math.Cos(Rad) - (YBefore - YRotation) * Math.Sin(Rad) + XRotation;
                    YAfter = (YBefore - YRotation) * Math.Cos(Rad) + (XBefore - XRotation) * Math.Sin(Rad) + YRotation;
                    return "OK";
                }
                catch (Exception ex)
                {
                    return ex.Message;
                }
            }
        }
    }
    
    

五、X,Y和角度纠偏的步骤:

  • X,Y和角度的偏差,在机械动作上是同时进行纠偏的,但是在算法中却不是,我们往往是先转正角度,然后算出转正角度后新位置的坐标;
  • 此时新位置和模板角度是相同的,只需要平移就能重合,这个平移量就是9点标定时算出并保存的仿射变换矩阵来计算的了。
  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值