四连杆运动仿真

本文探讨了四连杆运动仿真的核心问题——如何确定两个圆的正确交点。通过分析向量BD与BC的叉乘结果的正负号,可以判断并选取合适的交点,在仿真过程中保持一致性。
摘要由CSDN通过智能技术生成

四连杆运动仿真的关键是求两个圆的交点,

两个圆有两个交点,哪个才是俺们想要的呢?

简单的说,向量BD叉乘BC,会出现正负号,一次仿真中要不取全正值,要不全取负值

/* 求两个圆的交点
 * 0  : error
 * 1  : one point
 * 2  : two points
 * 3  : the same circle
*/
template<typename _EvalType_=Number>
inline int circle_circle_intersection(
        _EvalType_ x0,_EvalType_ y0,_EvalType_ r0,
        _EvalType_ x1,_EvalType_ y1,_EvalType_ r1,
        _EvalType_ *xi,_EvalType_ *yi,
        _EvalType_ *xi_prime,_EvalType_ *yi_prime) {
    /*http://paulbourke.net/geometry/circlesphere/*/

    /* dx and dy are the vertical and horizontal distances between
   * the circle centers.
   */
    auto dx=x1-x0;
    auto dy=y1-y0;

    /* Determine the straight-line distance between the centers. */
    //d = sqrt((dy*dy) + (dx*dx));
    auto d=std::hypot(dx,dy); // Suggested by Kei
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值