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


C++ GetSquared函数代码示例

本文整理汇总了C++中GetSquared函数的典型用法代码示例。如果您正苦于以下问题:C++ GetSquared函数的具体用法?C++ GetSquared怎么用?C++ GetSquared使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: GetSquared

Real Distance<Real,TVector>::GetSquared (Real tmin, Real tmax,
    const TVector& velocity0, const TVector& velocity1)
{
    // The assumption is that distance f(t) is a convex function.  If
    // f'(tmin) >= 0, then the minimum occurs at tmin.  If f'(tmax) <= 0,
    // then the minimum occurs at tmax.  Otherwise, f'(0) < 0 and
    // f'(tmax) > 0 and the minimum occurs at some t in (tmin,tmax).

    Real t0 = tmin;
    Real f0 = GetSquared(t0, velocity0, velocity1);
    if (f0 <= ZeroThreshold)
    {
        // The distance is effectively zero.  The objects are initially in
        // contact.
        mContactTime = t0;
        return (Real)0;
    }
    Real df0 = GetDerivativeSquared(t0, velocity0, velocity1);
    if (df0 >= (Real)0)
    {
        // The distance is increasing on [0,tmax].
        mContactTime = t0;
        return f0;
    }

    Real t1 = tmax;
    Real f1 = GetSquared(t1, velocity0, velocity1);
    if (f1 <= ZeroThreshold)
    {
        // The distance is effectively zero.
        mContactTime = t1;
        return (Real)0;
    }
    Real df1 = GetDerivativeSquared(t1, velocity0, velocity1);
    if (df1 <= (Real)0)
    {
        // The distance is decreasing on [0,tmax].
        mContactTime = t1;
        return f1;
    }

    // Start the process with Newton's method for computing a time when the
    // distance is zero.  During this process we will switch to a numerical
    // minimizer if we decide that the distance cannot be zero.
    int i;
    for (i = 0; i < MaximumIterations; ++i)
    {
        // Compute the next Newton's iterate.
        Real t = t0 - f0/df0;
        if (t >= tmax)
        {
            // The convexity of the graph guarantees that when this condition
            // happens, the distance is always positive.  Switch to a
            // numerical minimizer.
            break;
        }

        Real f = GetSquared(t, velocity0, velocity1);
        if (f <= ZeroThreshold)
        {
            // The distance is effectively zero.
            mContactTime = t;
            return (Real)0;
        }

        Real df = GetDerivativeSquared(t, velocity0, velocity1);
        if (df >= (Real)0)
        {
            // The convexity of the graph guarantees that when this condition
            // happens, the distance is always positive.  Switch to a
            // numerical minimizer.
            break;
        }

        t0 = t;
        f0 = f;
        df0 = df;
    }

    if (i == MaximumIterations)
    {
        // Failed to converge within desired number of iterations.  To
        // reach here, the derivative values were always negative, so report
        // the distance at the last time.
        mContactTime = t0;
        return f0;
    }

    // The distance is always positive.  Use bisection to find the root of
    // the derivative function.
    Real tm = t0;
    for (i = 0; i < MaximumIterations; ++i)
    {
        tm = ((Real)0.5)*(t0 + t1);
        Real dfm = GetDerivativeSquared(tm, velocity0, velocity1);
        Real product = dfm*df0;
        if (product < -ZeroThreshold)
        {
            t1 = tm;
            df1 = dfm;
//.........这里部分代码省略.........
开发者ID:shurcooL,项目名称:Slide,代码行数:101,代码来源:Wm5Distance.cpp

示例2: GetSquared

Real DistVector3Segment3<Real>::Get ()
{
    Real fSqrDist = GetSquared();
    return Math<Real>::Sqrt(fSqrDist);
}
开发者ID:PrLayton,项目名称:SeriousFractal,代码行数:5,代码来源:Wm4DistVector3Segment3.cpp

示例3:

Real DistLine2Segment2<Real>::Get ()
{
    return Math<Real>::Sqrt(GetSquared());
}
开发者ID:Kiichi77,项目名称:WildMagic,代码行数:4,代码来源:Wm5DistLine2Segment2.cpp

示例4: GetSquared

Real DistSegment3Rectangle3<Real>::Get ()
{
    Real fSqrDist = GetSquared();
    return Math<Real>::Sqrt(fSqrDist);
}
开发者ID:rms80,项目名称:libgeometry,代码行数:5,代码来源:Wm4DistSegment3Rectangle3.cpp

示例5:

Real DistPoint3Segment3<Real>::Get ()
{
    return Math<Real>::Sqrt(GetSquared());
}
开发者ID:2asoft,项目名称:GeometricTools,代码行数:4,代码来源:Wm5DistPoint3Segment3.cpp

示例6:

Real DistLine2Ray2<Real>::Get ()
{
    return Math<Real>::Sqrt(GetSquared());
}
开发者ID:fishxz,项目名称:omni-bot,代码行数:4,代码来源:Wm5DistLine2Ray2.cpp

示例7:

Real DistVector3Box3<Real>::Get ()
{
    return Math<Real>::Sqrt(GetSquared());
}
开发者ID:rms80,项目名称:libgeometry,代码行数:4,代码来源:Wm4DistVector3Box3.cpp

示例8:

Real DistRay3Triangle3<Real>::Get ()
{
    return Math<Real>::Sqrt(GetSquared());
}
开发者ID:JackTing,项目名称:SkpColl,代码行数:4,代码来源:Wm5DistRay3Triangle3.cpp

示例9: GetSquared

Real DistLine2Line2<Real>::Get ()
{
	Real sqrDist = GetSquared();
	return Math<Real>::Sqrt(sqrDist);
}
开发者ID:bhlzlx,项目名称:WildMagic,代码行数:5,代码来源:Wm5DistLine2Line2.cpp

示例10:

Real DistLine3Circle3<Real>::Get ()
{
    return Math<Real>::Sqrt(GetSquared());
}
开发者ID:rasslingcats,项目名称:calico,代码行数:4,代码来源:Wm5DistLine3Circle3.cpp

示例11: GetSquared

Real DistVector3Tetrahedron3<Real>::Get ()
{
    Real fSqrDist = GetSquared();
    return Math<Real>::Sqrt(fSqrDist);
}
开发者ID:rms80,项目名称:libgeometry,代码行数:5,代码来源:Wm4DistVector3Tetrahedron3.cpp

示例12:

Real DistVector3Frustum3<Real>::Get ()
{
    return Math<Real>::Sqrt(GetSquared());
}
开发者ID:daleaddink,项目名称:flagship3d,代码行数:4,代码来源:Wm4DistVector3Frustum3.cpp

示例13:

Real DistPoint3Ellipsoid3<Real>::Get ()
{
    return Math<Real>::Sqrt(GetSquared());
}
开发者ID:JackTing,项目名称:SkpColl,代码行数:4,代码来源:Wm5DistPoint3Ellipsoid3.cpp

示例14: GetSquared

Real DistPoint3Tetrahedron3<Real>::Get ()
{
    return Math<Real>::Sqrt( GetSquared() );
}
开发者ID:kanbang,项目名称:myexercise,代码行数:4,代码来源:Wm5DistPoint3Tetrahedron3.cpp

示例15: GetSquared

Real DistLine3Triangle3<Real>::Get ()
{
    Real fSqrDist = GetSquared();
    return Math<Real>::Sqrt(fSqrDist);
}
开发者ID:rms80,项目名称:libgeometry,代码行数:5,代码来源:Wm4DistLine3Triangle3.cpp


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