Division of Line Segment

/**  */
void Line::EqualDivision(int nCount, QLineF fline, QList<QPointF> *ltPts)
{
    Q_ASSERT(0 != ltPts);
    QPointF p1,p2;
    float x,y,xStep,yStep,nStepLen;

    ltPts->clear();
    if(nCount<=1){
        return;
    }

    p1 = fline.p1();
    p2 = fline.p2();
    if(p1.x() == p2.x() && p1.y() == p2.y()){
        return;
    }

    nStepLen = fline.length()/nCount;
    for(int i=1; i<nCount; i++){
        x = (i*nStepLen*p2.x() + (nCount-i)*nStepLen*p1.x())/fline.length();
        y = (i*nStepLen*p2.y() + (nCount-i)*nStepLen*p1.y())/fline.length();
        ltPts->append(QPointF(x,y));
    }
}

Reference

math-only-math.com


相关文章:

  • 2022-02-09
  • 2022-12-23
  • 2021-04-01
  • 2021-07-24
  • 2022-02-08
  • 2022-12-23
  • 2021-11-10
猜你喜欢
  • 2022-01-05
  • 2021-08-15
  • 2021-10-24
  • 2021-06-10
  • 2021-05-24
相关资源
相似解决方案