先来理解一下 切线长定理:https://www.bilibili.com/video/BV1z24y1W7Ag/?vd_source=9ecca5fd041baffbae0341c50a8ce070
开始进入正题:
得出OP平分角∠BOA 角∠BOP=夹角除以2 得出弧度=π夹角/2/180 得出tan(BOP弧度)
得出BP=半径tan(BOP弧度)
勾股定理得出OP=根号下半径²+BP²的
计算OP点的X值 = cos OB与X轴的旋转值-角BOP 乘以OP的长度
计算OP点的Y值 = sin OB与X轴的旋转值-角BOP 乘以OP的长度
private static Vector2 getQieDian(float radius, Vector2 point1, Vector2 point2)
{
Vector2 qiedian = new Vector2();
float qieXianLength = Mathf.Tan(Mathf.PI * Vector2.Angle(point1, point2) / 2 / 180) * radius;
float duiJiaoXianLength = Mathf.Sqrt(qieXianLength * qieXianLength + radius * radius);
float duiJiaoXianAngle = 90 - Vector2.Angle(point1, point2) / 2;//这里应该计算出OB与X轴的夹角 我使用90替代了
qiedian.x = Mathf.Cos(Mathf.PI * duiJiaoXianAngle / 180) * duiJiaoXianLength;
qiedian.y = Mathf.Sin(Mathf.PI * duiJiaoXianAngle / 180) * duiJiaoXianLength;
//Debug.LogError(Vector2.Angle(point1, point2) + " " + qieXianLength + " " + qiedian);
return qiedian;
}