1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
TPoint Point1,Point2;
//première courbe
Point1 = Point(100,100);
Point2 = Point(220,40);
Canvas->MoveTo(Point1.x,Point1.y);
Canvas->LineTo(Point2.x,Point2.y);
//calcul de l'angle du premier segment par rapport à l'horizontal
double oppose = Point1.y-Point2.y;
double hypothenuse = sqrt( (Point2.x-Point1.x)*(Point2.x-Point1.x) + (Point2.y-Point1.y)*(Point2.y-Point1.y) );
double angle = ArcSin(oppose/hypothenuse);
Label1->Caption = FloatToStrF(angle*180.0/M_PI,ffFixed,6,2) + "°";
//point de référence
Point1 = Point(100,100);
//calcul du deuxième point de la courbe perpendiculaire
//on considère que le segment à la même longueur que le premier
double angle2 = M_PI_2-angle;
double Yb = fabs( Point1.y - hypothenuse*sin(-angle2)) ;
double Xb = sqrt( hypothenuse*hypothenuse - (Point1.y - Yb)*(Point1.y - Yb) ) + Point1.x;
Point2 = Point(Xb,Yb);
Canvas->MoveTo(Point1.x,Point1.y);
Canvas->LineTo(Point2.x,Point2.y);
//calcul de l'angle du deuxième segment par rapport à l'horizontal
oppose = Point1.y-Point2.y;
hypothenuse = sqrt( (Point2.x-Point1.x)*(Point2.x-Point1.x) + (Point2.y-Point1.y)*(Point2.y-Point1.y) );
angle = ArcSin(oppose/hypothenuse);
Label2->Caption = FloatToStrF(angle*180.0/M_PI,ffFixed,6,2) + "°"; |
Partager