示例#1
0
文件: Polygon.cpp 项目: mraggi/Graph
bool Polygon::Intersects(const Circle& other) const
{
    const Polygon& B = *this;

    if (Intersects(other.Position()))
        return true; // If the center of the circle is inside the polygon

    for (int i = 0; i < B.NumPoints(); ++i)
    {
        if (other.Intersects(Segment(B[i], B[i + 1])))
            return true;
    }

    return false;
}
示例#2
0
文件: Polygon.cpp 项目: mraggi/Graph
Polygon::Polygon(const Circle& circle, int num)
    : FConvex(circle.Position()), m_vPoints(num)
{
    real angle = -2*pi/num;

    real sint = sin(angle);
    real cost = cos(angle);

    Point current(-circle.Radius(), 0);

    for (int i = 0; i < num; ++i)
    {
        m_vPoints[i] = current;
        current.Rotate(sint, cost);
    }
}
示例#3
0
文件: main.c 项目: lirui79/CProject
void test_three()
{
	Circle   *circle ;
	Point    *point ;
	Shape    *shape ;
	IMethod  *ptr ;
	double area = 0.0 ;
	circle = New(Circle) ;

	circle->Set(circle , 10.0 , 20.0) ;
	circle->Move(circle , 100.0 , 300.0) ;

	circle->Position(circle) ;

	circle->SetRadius(circle , 30.0) ;
	area = circle->Area(circle) ;

	circle->SetCircle(circle , 1.0 , 2.0 , 3.0) ;

	shape = (Shape*)circle ;
	shape->Position(shape) ;
	area = shape->Area(shape) ;

	point = (Point*)circle ;
	point->Move(point , 1000.0 , 2000.0) ;
	point->Position(point) ;

	circle->AddRadius(circle , 50.0) ;
	area = point->Area(point) ;

	ptr = (IMethod*)circle ;
//	area = ptr->Area() ;
    ptr->GetClassName() ;
	Delete(ptr) ;

}