Python - 两圆相交求交点坐标
来源:互联网 发布:花千骨御剑进阶数据 编辑:程序博客网 时间:2024/05/21 06:18
Python - 两圆相交求交点坐标
Max.Bai
2016-05-16
Python - 两圆相交求交点坐标
三轴机械臂求坐标问题,其实转化为平面问题就是两圆相交求交点问题,交点算出来就可以用反三角函数算出各个机械臂的夹角。
已知圆1, 半径R, 坐标(x, y)
圆2, 半径S, 坐标(a, b)
求两圆交点x3, y3 x4, y4。
算法一脚本:
# -*- coding: utf-8 -*-import mathdef sq(x): return float(x * x)# target point on tabletx = float(10)ty = float(10)# hight of tableh0 = float(5)# length of armR = float(10)S = float(8)# arm pointx = float(0)y = float(5)# target point for arma = float(math.sqrt(sq(tx)+ sq(ty)))b = h0print "arm target:", a, bd = math.sqrt(sq(math.fabs(a-x)) + sq(math.fabs(b-y)))print "desitens:", dif d > (R+S) or d < (math.fabs(R-S)): print "This point can't be rached!" #return -1 exit if d == 0 and R==S : print "Can't rach arm point!" #return -2 exitA = (sq(R) - sq(S) + sq(d)) / (2 * d)h = math.sqrt(sq(R) - sq(A))x2 = x + A * (a-x)/dy2 = y + A * (b-y)/d#print x2, y2x3 = x2 - h * ( b - y ) / dy3 = y2 + h * ( a - x ) / dx4 = x2 + h * (b - y) / dy4 = y2 - h * (a - x) / dprint "arm middle point:"print x3, y3print x4, y4
已知圆1, 半径L1, 坐标(0, L3)
圆2, 半径L2, 坐标(x, y)
求圆1交点与圆心连线和Y轴的夹角a1,
圆2交点与圆心连线和X轴的夹角a2。
算法二:
# -*- coding: utf-8 -*-import mathL1 = float(10)L2 = float(10)L3 = float(5)x = float(14.1421356237)y = float(5)def sq(x): return x * xA = float(-2 * x * L1)B = float(2*(y-L3)*L1)C = float(sq(L2) - sq(L1) - sq(x) -sq(y-L3))a1 = float(2*math.atan((B-math.sqrt(sq(B)+sq(A)-sq(C)))/(A+C)))A = float(2 * (y - L3) * L2)B = float(2 * x * L2)C = float(sq(L2) + sq(x) + sq(L3-y) -sq(L1))a2 = float(2* math.atan((B-math.sqrt(sq(B)+sq(A)-sq(C)))/(A+C)))print a1, a2print a1*180/math.pi, a2*180/math.pi
0 0
- Python - 两圆相交求交点坐标
- 求解两圆相交的交点坐标
- 两直线四坐标点判断相交并求交点
- 求线段相交交点坐标
- python 求直线交点坐标
- 判断两线段是否相交求交点
- 判断两线段相交,并求交点
- 计算几何--两圆的位置关系(求交点个数及交点坐标)
- 判断两线段是否相交并计算交点坐标
- C++ 实现两线段是否相交、相交情况、若相交求出交点坐标
- C++ 实现两线段是否相交、相交情况、若相交求出交点坐标
- 判断两条线段/直线相交,并求交点
- 判断两条线段/直线相交,并求交点
- 判断两线段是否相交,并求交点
- 两圆相交求相交面积
- 两圆相交求面积
- 两圆相交求面积
- 求两个相交圆的交点的公式
- c++ decltype
- H.265读书笔记(二)
- 利用mybatis-generator自动生成代码
- HTML5的视频格式之争
- 【bzoj1612】【Usaco2008 Jan】Cow Contest奶牛的比赛 题解&代码
- Python - 两圆相交求交点坐标
- 寻找矩阵的鞍点问题
- Google Guava官方教程(中文版)
- 飞虫 Android软件安全与逆向分析之Dalvik
- 并查集的解题集合
- Java 可变参数
- 接口测试的两种方法
- (2)尽可能使用const
- 媒体播放器三大底层架构