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


C++ SHAPE_CIRCLE类代码示例

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


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

示例1: pushoutForce

static VECTOR2I pushoutForce( const SHAPE_CIRCLE& aA, const SEG& aB, int aClearance )
{
    VECTOR2I f( 0, 0 );

    const VECTOR2I c = aA.GetCenter();
    const VECTOR2I nearest = aB.NearestPoint( c );

    const int r = aA.GetRadius();

    int dist = ( nearest - c ).EuclideanNorm();
    int min_dist = aClearance + r;

    if( dist < min_dist )
    {
        for( int corr = 0; corr < 5; corr++ )
        {
            f = ( aA.GetCenter() - nearest ).Resize( min_dist - dist + corr );

            if( aB.Distance( c + f ) >= min_dist )
                break;
        }
    }

    return f;
}
开发者ID:zhihuitech,项目名称:kicad-source-mirror,代码行数:25,代码来源:shape_collisions.cpp

示例2: switch

const SHAPE_LINE_CHAIN PNS_SOLID::Hull( int aClearance, int aWalkaroundThickness ) const
{
    int cl = aClearance + aWalkaroundThickness / 2;

    switch( m_shape->Type() )
    {
    case SH_RECT:
    {
        SHAPE_RECT* rect = static_cast<SHAPE_RECT*>( m_shape );
        return OctagonalHull( rect->GetPosition(), rect->GetSize(), cl + 1, 0.2 * cl );
    }

    case SH_CIRCLE:
    {
        SHAPE_CIRCLE* circle = static_cast<SHAPE_CIRCLE*>( m_shape );
        int r = circle->GetRadius();
        return OctagonalHull( circle->GetCenter() - VECTOR2I( r, r ), VECTOR2I( 2 * r, 2 * r ),
                              cl + 1, 0.52 * ( r + cl ) );
    }

    case SH_SEGMENT:
    {
        SHAPE_SEGMENT* seg = static_cast<SHAPE_SEGMENT*> ( m_shape );
        return SegmentHull( *seg, aClearance, aWalkaroundThickness );
    }

    default:
        break;
    }

    return SHAPE_LINE_CHAIN();
}
开发者ID:BTR1,项目名称:kicad-source-mirror,代码行数:32,代码来源:pns_solid.cpp

示例3: pushoutForce

static VECTOR2I pushoutForce( const SHAPE_CIRCLE& aA, const SEG& aB, int aClearance )
{
    VECTOR2I nearest = aB.NearestPoint( aA.GetCenter() );
    VECTOR2I f (0, 0);

    int dist = ( nearest - aA.GetCenter() ).EuclideanNorm();
    int min_dist = aClearance + aA.GetRadius();

    if( dist < min_dist )
        f = ( aA.GetCenter() - nearest ).Resize ( min_dist - dist + 10 );

    return f;
}
开发者ID:rubdos,项目名称:kicad-source-mirror,代码行数:13,代码来源:shape_collisions.cpp

示例4: Collide

static inline bool Collide( const SHAPE_CIRCLE& aA, const SHAPE_LINE_CHAIN& aB, int aClearance,
                            bool aNeedMTV, VECTOR2I& aMTV )
{
    bool found = false;

    for( int s = 0; s < aB.SegmentCount(); s++ )
    {
        if( aA.Collide( aB.CSegment( s ), aClearance ) )
        {
            found = true;
            break;
        }
    }

    if( !aNeedMTV || !found )
        return found;

    SHAPE_CIRCLE cmoved( aA );
    VECTOR2I f_total( 0, 0 );

    for( int s = 0; s < aB.SegmentCount(); s++ )
    {
        VECTOR2I f = pushoutForce( cmoved, aB.CSegment( s ), aClearance );
        cmoved.SetCenter( cmoved.GetCenter() + f );
        f_total += f;
    }

    aMTV = f_total;
    return found;
}
开发者ID:zhihuitech,项目名称:kicad-source-mirror,代码行数:30,代码来源:shape_collisions.cpp

示例5: Collide

static inline bool Collide( const SHAPE_CIRCLE& aA, const SHAPE_LINE_CHAIN& aB, int aClearance,
                            bool aNeedMTV, VECTOR2I& aMTV )
{
    for( int s = 0; s < aB.SegmentCount(); s++ )
    {
        if( aA.Collide( aB.CSegment( s ), aClearance ) )
            return true;
    }

    return false;
}
开发者ID:Th0rN13,项目名称:kicad-source-mirror,代码行数:11,代码来源:shape_collisions.cpp


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