示例#1
0
void Circulo::Dibujar(QPainter *AreaPintado)
{
    QPen pen(this->getColor(), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    AreaPintado->setPen( pen);
    AreaPintado->setBrush(this->getFondo());
    QPointF punto(this->getX(),this->getY());
    AreaPintado->drawEllipse(punto,(qreal)this->radio,
                             (qreal)this->radio);

 }
void Cabeza::Dibujar(QPainter *AreaPintado){
    QPen pen(this->getColor(), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    AreaPintado->setPen( pen);
    AreaPintado->setBrush(this->getFondo());
    QPointF punto(this->getX(),this->getY());

    if(this->tipo==0){
        AreaPintado->drawEllipse(punto,this->radio1,this->radio1);
    }else if(this->tipo==1){
        AreaPintado->drawRect(this->getX()-(this->getAncho()/2),this->getY()-(this->getAlto()/2),this->getAncho(),this->getAlto());
    }else{
        AreaPintado->drawEllipse(punto,this->radio1,this->radio2);
    }
}
示例#3
0
文件: mapa_t.cpp 项目: Rafaherrero/ia
unsigned mapa_t::contar_entidades(id_t entidad)
{
	QPoint punto(0,0);
	unsigned cantidad = 0;
	for(unsigned i = 0; i < entidades_.tam_x(); i++){
		for(unsigned j = 0; j < entidades_.tam_y(); j++){
			punto.setX(i);
			punto.setY(j);
			if(entidades_.at(punto) == entidad)
				cantidad++;
		}
	}
	return cantidad;
}
示例#4
0
文件: mapa_t.cpp 项目: Rafaherrero/ia
unsigned mapa_t::contar_entidades(void)
{
	QPoint punto(0,0);
	unsigned cantidad = 0;
	for(unsigned i = 0; i < entidades_.tam_x(); i++){
		for(unsigned j = 0; j < entidades_.tam_y(); j++){
			punto.setX(i);
			punto.setY(j);
			if(entidades_.at(punto) != ID_GLOBAL_ENTIDAD_NULA)
				cantidad++;
		}
	}
	return cantidad;
}
示例#5
0
文件: mapa_t.cpp 项目: Rafaherrero/ia
unsigned mapa_t::contar_setos(void)
{
	QPoint punto(0,0);
	unsigned cantidad = 0;
	for(unsigned i = 0; i < setos_.tam_x(); i++){
		for(unsigned j = 0; j < setos_.tam_y(); j++){
			punto.setX(i);
			punto.setY(j);
			if(setos_.at(punto) == ID_GLOBAL_SETO_HAY)
				cantidad++;
		}
	}
	return cantidad;
}
示例#6
0
文件: mapa_t.cpp 项目: Rafaherrero/ia
void mapa_t::colocar_monstruos(unsigned cantidad)
{
	if(cantidad > (tam_x_*tam_y_)-contar_setos())
		throw exception::out_of_range("Excedido el numero de monstruos posibles");

	unsigned contador = 0;
	QPoint punto(0,0);
	while(contador < cantidad)
	{
		punto.setX(common::random()%entidades_.tam_x());
		punto.setY(common::random()%entidades_.tam_y());
		if(setos_.at(punto) == ID_GLOBAL_SETO_NO_HAY && entidades_.at(punto) == ID_GLOBAL_ENTIDAD_NULA){
			entidades_.at(punto) = ID_GLOBAL_ENTIDAD_MONSTRUO;
			contador++;
		}
	}
}
示例#7
0
int main() {
	
	std::cout << "******************************************************************" << std::endl;
	std::cout << "* Ejemplos de Acceso Privado 1                                   *" << std::endl;
	std::cout << "******************************************************************" << std::endl;
	
	std::cout << "El modificador private nos ayuda a evitar que metodos o atributos" << std::endl;
	std::cout << "de una clase sean unica y exclusivamente usados y vistos por las " << std::endl;
	std::cout << "instancias de la clase. En nuestro ejemplo de punto mX y mY son  " << std::endl;
	std::cout << "privados por lo tanto ni con herencias podemos acceder directamente." << std::endl;
	std::cout << "Esto es acceder de la forma punto.mX o bien punto.mY" << std::endl;
	
	Punto punto(1.0, 2.0);
	std::cout << "Punto(" << punto.getX() << ", " << punto.getY() << ")" << std::endl << std::endl;
	
	return 0;
}
//Rotacion y traslacion de Coordenadas
geometry_msgs::Twist transformacion_homogenea(geometry_msgs::Twist pos, double theta, geometry_msgs::Twist trasl)
{

    geometry_msgs::Twist referenced_pos;
    Eigen::Matrix3f T;
    Eigen::Matrix3f T_inv;
    //theta = (2* M_PI)-theta;
    theta = theta *-1; //NO ESTAMOS SEGUROS PORQUE FUNCIONA, VER FOTO DE GARY
    T(0,0) = cos(theta);
    T(0,1) = sin(theta);
    T(0,2) = trasl.linear.x;

    T(1,0) = -sin(theta);
    T(1,1) = cos(theta);
    T(1,2) = trasl.linear.y;

    T(2,0) = 0;
    T(2,1) = 0;
    T(2,2) = 1;

    T_inv = T.inverse();
   
    Eigen::Vector3f punto(pos.linear.x,pos.linear.y,1);

    Eigen::Vector3f punto_transf(3);
    punto_transf = T_inv * punto;

    referenced_pos.linear.x = punto_transf(0);
    referenced_pos.linear.y = punto_transf(1);
    referenced_pos.angular.z = punto_transf(2);
   
/*ROS_INFO_STREAM("Matriz transf homogenea inv:"
            <<T_inv(0,0)<<" "<<T_inv(0,1)<<" "<<T_inv(0,2)<<"\n"<<
            T_inv(1,0)<<" "<<T_inv(1,1)<<" "<<T_inv(1,2)<<"\n"<<
            T_inv(2,0)<<" "<<T_inv(2,1)<<" "<<T_inv(2,2)<<"\n");
    ROS_INFO_STREAM("Matriz transf homogenea:"
            <<T(0,0)<<" "<<T(0,1)<<" "<<T(0,2)<<"\n"<<
            T(1,0)<<" "<<T(1,1)<<" "<<T(1,2)<<"\n"<<
            T(2,0)<<" "<<T(2,1)<<" "<<T(2,2)<<"\n""\n");
    ROS_INFO_STREAM("Punto:"
            <<punto(0)<<" "<<punto(1)<<" "<<punto(2)<<"\n");
    ROS_INFO_STREAM("Punto transf:"
            <<punto_transf(0)<<" "<<punto_transf(1)<<" "<<punto_transf(2)<<"\n");*/
    return referenced_pos;
}
geometry_msgs::Twist destransformacion_homogenea(geometry_msgs::Twist pos_A, double theta, geometry_msgs::Twist trasl)
{
    geometry_msgs::Twist original_pos;
    Eigen::Matrix3f T;
    Eigen::Matrix3f T_inv;
    //theta = (2* M_PI)-theta;
    T(0,0) = cos(theta);
    T(0,1) = sin(theta);
    T(0,2) = trasl.linear.x;

    T(1,0) = -sin(theta);
    T(1,1) = cos(theta);
    T(1,2) = trasl.linear.y;

    T(2,0) = 0;
    T(2,1) = 0;
    T(2,2) = 1;
   
    Eigen::Vector3f punto(pos_A.linear.x,pos_A.linear.y,1);

    Eigen::Vector3f punto_transf(3);
    punto_transf = T* punto;

    original_pos.linear.x = punto_transf(0);
    original_pos.linear.y = punto_transf(1);
    original_pos.angular.z = 0;//punto_transf(2);
    /*ROS_INFO_STREAM("Matriz transf homogenea detransf:"
            <<T(0,0)<<" "<<T(0,1)<<" "<<T(0,2)<<"\n"<<
            T(1,0)<<" "<<T(1,1)<<" "<<T(1,2)<<"\n"<<
            T(2,0)<<" "<<T(2,1)<<" "<<T(2,2)<<"\n""\n");
    ROS_INFO_STREAM("Punto A:"
            <<punto(0)<<" "<<punto(1)<<" "<<punto(2)<<"\n");
    ROS_INFO_STREAM("Punto transf:"
            <<punto_transf(0)<<" "<<punto_transf(1)<<" "<<punto_transf(2)<<"\n");*/
   
    return original_pos;
}