当前位置: 首页>>代码示例>>C++>>正文


C++ Vector2d::setZero方法代码示例

本文整理汇总了C++中eigen::Vector2d::setZero方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector2d::setZero方法的具体用法?C++ Vector2d::setZero怎么用?C++ Vector2d::setZero使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eigen::Vector2d的用法示例。


在下文中一共展示了Vector2d::setZero方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: initialize

 /* This callback is called everytime this node's simulation starts or restarts.
  This is different from initialize() above. */
 virtual int64_t onInitialization() override {
     // Initial state and output
     x.setZero();
     velocity = 0.0;
     std::cout << "At " << currentSimulationTime() << " INIT" << std::endl;
     return 0;
 }
开发者ID:LA-EPFL,项目名称:openBuildNet,代码行数:9,代码来源:nodemotor.cpp

示例2: _basicCostGrad

double BlockConstraint::_basicCostGrad(Eigen::Vector2d& grad_c, const Vector2d &config)
{
    Eigen::Vector2d p = _tfinv*(config-_center);
//    std::cout << p.transpose() << "\t|\t" << scales[0] << ", " << scales[1] << std::endl;
    
    assert( buffer > 0 && "We only support positive-valued buffer sizes!");
    
    double c = INFINITY;
    for(size_t i=0; i<2; ++i)
    {
        if(fabs(p[i]) >= fabs(scales[i])+fabs(buffer))
        {
            grad_c.setZero();
            return 0;
        }
        else if(fabs(p[i]) >= fabs(scales[i]))
        {
            double dist = buffer-(fabs(p[i])-fabs(scales[i]));
            double ctemp = dist*dist/(2*buffer);
            if(ctemp < c)
            {
                c = ctemp;
                grad_c.setZero();
                grad_c[i] = -(fabs(p[i])-fabs(scales[i])-buffer)/buffer*sign(p[i]);
            }
        }
        else
        {
            double ctemp = scales[i]-p[i] + buffer/2;
            if(ctemp < c)
            {
                c = ctemp;
                grad_c.setZero();
                grad_c[i] = -sign(p[i]);
            }
        }
    }
    
    return c;
}
开发者ID:mxgrey,项目名称:ccrrt,代码行数:40,代码来源:BlockConstraint.cpp

示例3: if


//.........这里部分代码省略.........

      if (bymax < aymin)
        return false;
      if (bymin > aymax)
        return false;

      if (bymax <= aymax)
        intersection.y() = bymax;
      else if (bymin >= aymin)
        intersection.y() = bymin;
      else
        intersection.y() = aymin;

      if (acorn_debug_ear_state)
      {
        logInform("     INTERSECTS");
      }
      return true;
    }
    parallel = false;
    intersection.x() = a.pt_[0].x();
    intersection.y() = b.slope_ * intersection.x() + b.y_intercept_;

    double tb = (intersection.x() - b.pt_[0].x()) * b.inv_dx_;
    if (acorn_debug_ear_state)
    {
      logInform("     a vertical pt=(%8.4f, %8.4f) tb=%f",
        intersection.x(),
        intersection.y(),
        tb);
    }
    if (tb > 1.0 || tb < 0.0)
      return false;

    if (b.inv_dx_ == 0.0)
    {
      if (intersection.y() != a.pt_[0].y())
        return false;
    }
    else
    {
      double ta = (intersection.y() - a.pt_[0].y()) * a.inv_dx_;
      if (acorn_debug_ear_state)
      {
        logInform("       ta=%f", ta);
      }
      if (ta > 1.0 || ta < 0.0)
        return false;
    }

    if (acorn_debug_ear_state)
    {
      logInform("     INTERSECTS");
    }
    return true;
  }
  else if (b.vertical_)
  {
    return b.intersect(a, intersection, parallel);
  }
  else
  {
    double bottom = a.slope_ - b.slope_;
    if (std::abs(bottom) < std::numeric_limits<double>::epsilon())
    {
      parallel = true;
      intersection.setZero();
      return false;
    }

    parallel = false;
    intersection.x() = (b.y_intercept_ - a.y_intercept_) / bottom;
    intersection.y() = a.slope_ * intersection.x() + a.y_intercept_;

    double ta = (intersection.x() - a.pt_[0].x()) * a.inv_dx_;
    if (acorn_debug_ear_state)
    {
      logInform("     not vertical pt=(%8.4f, %8.4f) ta=%f",
        intersection.x(),
        intersection.y(),
        ta);
    }
    if (ta > 1.0 || ta < 0.0)
      return false;

    double tb = (intersection.x() - b.pt_[0].x()) * b.inv_dx_;
    if (acorn_debug_ear_state)
    {
      logInform("       tb=%f", tb);
    }
    if (tb > 1.0 || tb < 0.0)
      return false;

    if (acorn_debug_ear_state)
    {
      logInform("     INTERSECTS");
    }
    return true;
  }
}
开发者ID:team-vigir,项目名称:vigir_moveit_advanced,代码行数:101,代码来源:geom.cpp


注:本文中的eigen::Vector2d::setZero方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。