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


C++ Matrix4d::cwiseAbs方法代码示例

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


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

示例1: if

/** Add a new sample to the path. If the sample time is less than the first time,
  * it is added at the end. If it is greater than the last time, it is appended
  * to the path. The sample is ignored if it has a time in between the first and
  * last times of the path.
  */
void
CurvePlot::addSample(const CurvePlotSample& sample)
{
    bool addToBack = false;

    if (m_samples.empty() || sample.t > m_samples.back().t)
    {
        addToBack = true;
    }
    else if (sample.t < m_samples.front().t)
    {
        addToBack = false;
    }
    else
    {
        // Sample falls within range of current samples; discard it
        return;
    }

    if (addToBack)
        m_samples.push_back(sample);
    else
        m_samples.push_front(sample);

    if (m_samples.size() > 1)
    {
        // Calculate a bounding radius for this segment. No point on the curve will
        // be further from the start point than the bounding radius.
        if (addToBack)
        {
            const CurvePlotSample& lastSample = m_samples[m_samples.size() - 2];
            double dt = sample.t - lastSample.t;
            Matrix4d coeff = cubicHermiteCoefficients(zeroExtend(lastSample.position),
                                                      zeroExtend(sample.position),
                                                      zeroExtend(lastSample.velocity * dt),
                                                      zeroExtend(sample.velocity * dt));
            Vector4d extents = coeff.cwiseAbs() * Vector4d(0.0, 1.0, 1.0, 1.0);
            m_samples[m_samples.size() - 1].boundingRadius = extents.norm();
        }
        else
        {
            const CurvePlotSample& nextSample = m_samples[1];
            double dt = nextSample.t - sample.t;
            Matrix4d coeff = cubicHermiteCoefficients(zeroExtend(sample.position),
                                                      zeroExtend(nextSample.position),
                                                      zeroExtend(sample.velocity * dt),
                                                      zeroExtend(nextSample.velocity * dt));
            Vector4d extents = coeff.cwiseAbs() * Vector4d(0.0, 1.0, 1.0, 1.0);
            m_samples[1].boundingRadius = extents.norm();
        }
    }
}
开发者ID:nisselarsson,项目名称:Celestia,代码行数:57,代码来源:curveplot.cpp


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