예제 #1
0
bool ON_Polyline::CreateStarPolygon(
    const ON_Circle& circle,
    double other_radius,
    int side_count
)
{
    bool rc = ( circle.IsValid() && side_count >= 3 && other_radius >= 0.0 )
              ? true
              : false;
    if ( rc )
    {
        SetCapacity(2*side_count+1);
        SetCount(2*side_count+1);
        double half_a = ON_PI/side_count;
        int i;
        ON_Circle other_circle = circle;
        other_circle.radius = other_radius;
        for ( i = 0; i < side_count; i++ )
        {
            m_a[i*2]   = circle.PointAt(half_a*2*i);
            m_a[i*2+1] = other_circle.PointAt(half_a*(1+2*i));
        }
        m_a[side_count*2] = m_a[0];
    }
    else
        Destroy();
    return rc;
}
예제 #2
0
bool ON_Polyline::CreateInscribedPolygon(
    const ON_Circle& circle,
    int side_count
)
{
    bool rc = ( circle.IsValid() && side_count >= 3 ) ? true : false;
    if ( rc )
    {
        SetCapacity(side_count+1);
        SetCount(side_count+1);
        double a = 2.0*ON_PI/side_count;
        int i;
        for ( i = 0; i < side_count; i++ )
        {
            m_a[i] = circle.PointAt(a*i);
        }
        m_a[side_count] = m_a[0];
    }
    else
        Destroy();
    return rc;
}
예제 #3
0
bool ON_Polyline::CreateCircumscribedPolygon(
    const ON_Circle& circle,
    int side_count
)
{
    bool rc = ( circle.IsValid() && side_count >= 3 ) ? true : false;
    if ( rc )
    {
        SetCapacity(side_count+1);
        SetCount(side_count+1);
        double half_a = ON_PI/side_count;
        int i;
        ON_Circle c = circle;
        c.radius = circle.radius/cos(half_a);
        for ( i = 0; i < side_count; i++ )
        {
            m_a[i] = c.PointAt(half_a*(1+2*i));
        }
        m_a[side_count] = m_a[0];
    }
    else
        Destroy();
    return rc;
}