/* Fonction principale */
int main()
{
    /* Declaration et initialisation des variables */
    struct point_s a;
    struct point_s b = {4.2, -0.4, 4};
    double d;

    a.x = 0.0;
    a.y = 3.5;
    a.rang = 1;

    afficher_point(a);
    printf("\n");

    d = distance(a, b);
    printf("La distance entre ");
    afficher_point(a);
    printf(" et ");
    afficher_point(b);
    printf(" est de %g.\n", d);

    afficher_point(milieu(a,b));
    printf("\n");
    /* Valeur fonction */
    return EXIT_SUCCESS;
}
void MultiplesTangentes::draw()
{
    if(Dessinable())
    {
        ofPushStyle();
        ofEnableAlphaBlending();
        ofSetColor(255, 255, 255, Alpha() * 255);
        ofSetLineWidth(lineWidth());
        float distance(Tools::getDistance(*Origine(), *Destination()));
        float angle(Tools::getAngle(*Origine(), *Destination()));
        ofVec2f milieu(Origine()->getMiddle(*Destination()));
        tangente()->Origine(&milieu);
        tangente()->rayon(distance / 2.);
        tangente()->Dessinable(Dessinable());
        tangente()->Alpha(Alpha());
        tangente()->lineWidth(lineWidth());

        for(int i = 0; i < nombreDeTangentesMax(); i += _step)
        {
            tangente()->angle(angle * (1 + i / (float)nombreDeTangentesMax() * M_PI));
            tangente()->draw();
        }

        ofDisableAlphaBlending();
        ofPopStyle();
    }
}
예제 #3
0
void moitie (retour * monRetour, int * T, int paramk, int paraml, bool verb) {
	bool subverb = verb;
	if (paramk == paraml) {
		monRetour->k = paramk;
		monRetour->l = paraml;
		monRetour->somme = T[paramk];
	} else {
		int mid = (int) ((paramk + paraml)/2);
		retour retourGauche;
		moitie(&retourGauche, T, paramk, mid, subverb);
		retour retourDroit;
		moitie(&retourDroit, T, mid + 1, paraml, subverb);
		retour retourMid;
		milieu(&retourMid, T, paramk, mid, paraml, subverb);
		
		if (retourGauche.somme >= retourDroit.somme && retourGauche.somme >= retourMid.somme) {
			monRetour->k = retourGauche.k;
			monRetour->l = retourGauche.l;
			monRetour->somme = retourGauche.somme;
			if (DEBUG == true) {printf("moitie gauche, somme : %d\n", monRetour->somme);}
		}
		else if (retourDroit.somme >= retourGauche.somme && retourDroit.somme >= retourMid.somme) {
			monRetour->k = retourDroit.k;
			monRetour->l = retourDroit.l;
			monRetour->somme = retourDroit.somme;
			if (DEBUG == true) {printf("moitie droite, somme : %d\n", monRetour->somme);}
		}
		else {
			monRetour->k = retourMid.k;
			monRetour->l = retourMid.l;
			monRetour->somme = retourMid.somme;
			if (DEBUG == true) {printf("moitie milieu, somme : %d\n", monRetour->somme);}
		}
	}
	if (verb == true) {
		printf("Moitié ");
		printRetour(monRetour);
	}
}