Exemplo n.º 1
0
void GrAtlasTextBlob::Run::SubRunInfo::computeTranslation(const SkMatrix& viewMatrix,
                                                          SkScalar x, SkScalar y, SkScalar* transX,
                                                          SkScalar* transY) {
    calculate_translation(!this->drawAsDistanceFields(), viewMatrix, x, y,
                          fCurrentViewMatrix, fX, fY, transX, transY);
    fCurrentViewMatrix = viewMatrix;
    fX = x;
    fY = y;
}
Exemplo n.º 2
0
void GrAtlasTextBlob::flushBigGlyphs(GrContext* context, GrDrawContext* dc,
                                     const GrClip& clip, const SkPaint& skPaint,
                                     const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
                                     const SkIRect& clipBounds) {
    SkScalar transX, transY;
    for (int i = 0; i < fBigGlyphs.count(); i++) {
        GrAtlasTextBlob::BigGlyph& bigGlyph = fBigGlyphs[i];
        calculate_translation(bigGlyph.fApplyVM, viewMatrix, x, y,
                              fInitialViewMatrix, fInitialX, fInitialY, &transX, &transY);
        SkMatrix ctm;
        ctm.setScale(bigGlyph.fScale, bigGlyph.fScale);
        ctm.postTranslate(bigGlyph.fX + transX, bigGlyph.fY + transY);
        if (bigGlyph.fApplyVM) {
            ctm.postConcat(viewMatrix);
        }

        GrBlurUtils::drawPathWithMaskFilter(context, dc, clip, bigGlyph.fPath,
                                            skPaint, ctm, nullptr, clipBounds, false);
    }
}
Exemplo n.º 3
0
/** Calculate here your desired settings. What you desire is checked afterwards to the current
 *    settings of the physical boundaries, but take care also.
 *
 *  How you do this is up to you, but be careful, our hardware is expensive!!!!
 *
 *  Available are:
 *
 *     target_     --> current target coordinates to drive to
 *     robot_      --> current robot coordinates
 *     robot_vel_  --> current Motor velocities
 *
 *     local_target_      --> our local target found by the search component we want to reach
 *     local_trajec_      --> The point we would collide with, if we would drive WITHOUT Rotation
 *
 *     orient_at_target_  --> Do we have to orient ourself at the target?
 *     stop_at_target_    --> Do we have to stop really ON the target?
 *
 *  Afterwards filled should be:
 *
 *     proposed_          --> Desired translation and rotation speed
 *
 *  Those values are questioned after an update() was called.
 */
void
ForwardOmniDriveModule::update()
{
  proposed_.x   = 0.f;
  proposed_.rot = 0.f;

  float dist_to_target    = sqrt( sqr(local_target_.x) + sqr(local_target_.y) );
  float alpha_target      = normalize_mirror_rad( atan2( local_target_.y, local_target_.x ) );
  float alpha_next_target = angle_distance_signed(robot_.ori, target_.ori);

  // last time border check............. IMPORTANT!!!
  // because the motorinstructor just tests robots physical borders.
  if ( dist_to_target < 0.04 ) {
    proposed_.x = proposed_.y = proposed_.rot = 0.f;

  } else {
    float angle_tollerance = M_PI_4;
    calculate_rotation(alpha_target, alpha_next_target, dist_to_target, angle_tollerance / 2.);

    float dec_factor = 1;
    if ( fabs(alpha_target) >= angle_tollerance ) {                             // if we need to turn a lot => drive slower
      dec_factor = 0.5;
    }

    calculate_translation(dist_to_target, alpha_target, dec_factor);

    if ( stop_at_target_ ) {
      float target_rel     = std::sqrt( sqr(target_.x - robot_.x) + sqr(target_.y - robot_.y) );
      float robo_trans     = std::sqrt( sqr(robot_vel_.x) + sqr(robot_vel_.y) );
      float proposed_trans = std::sqrt( sqr(proposed_.x) + sqr(proposed_.y) );
      float target_trans   = guarantee_trans_stop(target_rel, robo_trans, proposed_trans);

      float des = fabs(target_trans / proposed_trans);
      if      ( proposed_trans == 0 ) { des = 0; }

      proposed_.x *= des;
      proposed_.y *= des;
    }
  }
}