Point * calcCenter (Triangle * T){
	float m21,m32, m13;
	Point * center;

	m21 = (P1->y - P0->y) / (P1->x - P0->x);
	m32 = (P2->y - P1->y) / (P2->x - P1->x);
	m13 = (P0->y - P2->y) / (P0->x - P2->x);

	if(CCW(P0, P1, P2) == 0){
		return NULL;
	}
	center = (Point*) malloc(sizeof(Point));
	if(!center) return NULL;

	if(!VERTICAL(P0, P1) && !VERTICAL(P1, P2) && m21!=m32){//p2 common point
		center->x = (m21 * m32 * (P2->y - P0->y) + m21 * (P1->x + P2->x) - m32 * (P0->x + P1->x)) / (2 * (m21- m32));
		center->y = (-(1/(m21?m21:m32))) * (center->x - ((m21?P0->x:P2->x) + P1->x)/2) + ((m21?P0->y:P2->y) + P1->y) / 2;
	}
	else if(!VERTICAL(P0, P2) && !VERTICAL(P1, P2) && m32!=m13){//p3 common point
		center->x = (m32 * m13 * (P0->y - P1->y) + m32 * (P2->x + P0->x) - m13 * (P1->x + P2->x)) / (2 * (m32- m13));
		center->y = (-(1/(m32?m32:m13))) * (center->x - ((m32?P1->x:P0->x) + P2->x)/2) + ((m32?P1->y:P0->y) + P2->y) / 2;
	}
	else{
		center->x = (m13 * m21 * (P1->y - P2->y) + m13 * (P0->x + P1->x) - m21 * (P2->x + P0->x)) / (2 * (m13- m21));
		center->y = (-(1/(m13?m13:m21))) * (center->x - ((m13?P2->x:P1->x) + P0->x)/2) + ((m13?P2->y:P1->y) + P0->y) / 2;
	}
	return center;
}
示例#2
0
//控制台程序显示二维图
void c_show_map(int **map,int length, int x, int y)
{
	int row, col;	
	printf("show_map\n");
	for(row=0;row<length;row++)
	{
		//上划线
	//	self_def_undo_length(length);
		/*
		//中空
		for(col = 0; col < length; col++)
		{
			VERTICAL();
			color_space(*(*(map+raw)+col));
		}
		VERTICAL();
		putchar('\n');
		*/
		//输出数字
		for(col = 0; col < length; col++)
		{
			VERTICAL();
			if(row == x && col == y)
			{
				print_flick(*(*(map+row)+col));
			}
			else
			{
				print_number(*(*(map+row)+col));
			}
		}
		VERTICAL();
		putchar('\n');
		/*
		//中空
		for(col = 0; col < length; col++)
		{
			VERTICAL();
			color_space(*(*(map+row)+col));
		}
		VERTICAL();
		putchar('\n');
		//上划线
		*/
	}
//	self_def_undo_length(length);
}
示例#3
0
//	AI Action
void	cMobKnight::AI_StatusAction	( void )
 {
	//	스테이터스가 DIE 상태일 경우
	if( m_Status.m_Status == STATUS_DIE )
	{
		m_cMobKnightController.SetRangeNoLoop(m_Status.StartFrame,
			m_Status.EndFrame,
			m_Status.StartFrame,
			m_Status.EndFrame,
			m_Status.PlayTime );
		return;
	}

	if( SCENEMGR->GetNowScene() != MENU &&  m_Status.ActionCansle == true 
		&& SetLength( CHARMGR->GetPos() ) < 45.0f 
		&& m_fDot > 0.85f						//	몬스터의 거리가 25안이고 때릴수 있는 상태이고
		)										//	몬스터와 플레이어의 각도의 길이가 0에 가까우면
	{
		int Monsterchoise = rand()%2;

		switch( Monsterchoise )
		{
		case 0:
			{
				m_ActionCheck	=	0;
				VERTICAL();
				break;
			}
		case 1:
			{
				if( m_CheckHP != m_Status.m_HP )
				{
					m_CheckHP	=	m_Status.m_HP;
					m_ActionCheck	=	0;
					VERTICAL_RIGHT();
				}
				break;
			}
		}//	switch end
	}//	if end
}