コード例 #1
0
ファイル: tcomplex.cpp プロジェクト: shnellpavel/STP_labs
TComplex TComplex::sqrt(long n, long i) {
   /* n(q) = n(r)* (cos ((fi + 2*k*pi)/n)+ i* sin ((fi + 2*k*pi)/n))*/
    double sqrt_r = pow(module(), 1.0 / n);
    double _real = sqrt_r * cos((angle_rad() + 2 * 3.1415926535897932384 * i) / n); //3.1415926535897932384
    double _imagine = sqrt_r * sin((angle_rad() + 2 * 3.1415926535897932384 * i) / n); //3.1415926535897932384
    return TComplex(_real, _imagine);
}
コード例 #2
0
ファイル: WristWidget.cpp プロジェクト: mBusaleh/corobot
void WristWidget::timerEvent(QTimerEvent *event)
// get the new wrist angle if the user interacted with the widget
 {
     Q_UNUSED(event);

     // get the lines from the scene and get the new angle if it has moved
     QList<Line  *> lines;
     foreach (QGraphicsItem  *item, scene()->items()) {
         if (Line  *l = qgraphicsitem_cast<Line  *>(item))
             lines << l;
     }
     if(wristAngle != -lines.at(0)->rotation){
            wristAngle = -lines.at(0)->rotation;

        if(angle_type)
            emit angle(wristAngle);
        else
            emit angle(wristAngle/180*M_PI);

        emit angle_rad(wristAngle/180*M_PI);

        QList<QGraphicsLineItem  *> lines2;
            foreach (QGraphicsItem  *item, scene()->items()) {
                if (QGraphicsLineItem  *l = qgraphicsitem_cast<QGraphicsLineItem  *>(item))
                    lines2 << l;
            }

          int x = WRIST_HEIGHT * cos(wristAngle*M_PI/180 + M_PI / 2);
          int y = WRIST_HEIGHT * sin(wristAngle*M_PI/180 + M_PI / 2);

          lines2.at(1)->setLine(WRIST_CENTER_X, WRIST_CENTER_Y,WRIST_CENTER_X + x, WRIST_CENTER_Y - y);
      }
コード例 #3
0
ファイル: tcomplex.cpp プロジェクト: shnellpavel/STP_labs
double TComplex::angle_deg() {
    return angle_rad() * 57.295779513;
}
コード例 #4
0
ファイル: tcomplex.cpp プロジェクト: shnellpavel/STP_labs
TComplex TComplex::to_power (long power) {
/*qn = rn(cos (n*fi)+ i* sin (n*fi))*/
    double fi = angle_rad();
    double mod = module();
    return TComplex(pow(mod,power) * cos(power * fi), pow(mod,power) * sin(power * fi));
}