if we take the (x1,y1),(x2,y2) as coordinates the formula was (x-x1)/(x2-x1)=(y-y1)/(y2-y1)
Let P(x1, y1), Q(x2, y2), and M(x3, y3).If M is the midpoint of PQ, then,(x3, y3) = [(x1 + x2)/2, (y1 + y2)/2]We need to verify that,√[[(x1 + x2)/2 - x1]^2 + [(y1 + y2)/2 - y1]^2] = √[[x2 - (x1 + x2)/2]^2 + [y2 - (y1 + y2)/2]^2]]Let's work separately in both sides. Left side:√[[(x1 + x2)/2 - x1]^2 + [(y1 + y2)/2 - y1]^2]= √[[(x1/2 + x2/2)]^2 - (2)(x1)[(x1/2 + x2/2)) + x1^2] + [(y1/2 + y2/2)]^2 - (2)(y1)[(y1/2 + y2/2)] + y1^2]]= √[[(x1)^2]/4 + [(x1)(x2)]/2 + [(x2)^2]/4 - (x1)^2 - (x1)(x2) + (x1)^2 +[(y1)^2]/4 + [(y1)(y2)]/2 + [(y2)^2]/4 - (y1)^2 - (y1)(y2) + (y1)^2]]= √[[(x1)^2]/4 - [(x1)(x2)]/2 + [(x2)^2]/4 + [(y1)^2]/4 - [(y1)(y2)]/2 + [(y2)^2]/4]]Right side:√[[x2 - (x1 + x2)/2]^2 + [y2 - (y1 + y2)/2]^2]]= √[[(x2)^2 - (2)(x2)[(x1/2 + x2/2)] + [(x1/2 + x2/2)]^2 + [(y2)^2 - (2)(y2)[(y1/2 + y2/2)] + [(y1/2 + y2/2)]^2]]= √[[(x2)^2 - (x1)(x2) - (x2)^2 + [(x1)^2]/4 + [(x1)(x2)]/2 + [(x2)^2]/4 + (y2)^2 - (y1)[(y2) - (y2)^2 + [(y1)^2]/4) + [(y1)(y2)]/2 + [(y2)^2]/4]]= √[[(x1)^2]/4 - [(x1)(x2)]/2 + [(x2)^2]/4 + [(y1)^2]/4 - [(y1)(y2)]/2 + [(y2)^2]/4]]Since the left and right sides are equals, the identity is true. Thus, the length of PM equals the length of MQ. As the result, M is the midpoint of PQ
slope is the steepness of a line, it is defined by the change in the y values divided by the change in the x values of any two points on a line (x1, y1) and (x2, y2) slope = (y1 - y2)/(x1 - x2)
(y-y1)=(y2-y1/x2-x1)(x-x1)
Points: (x1, y1) and (x2, y2) Slope: y1-y2/x1-x2
#include<stdio.h> #include<graphics.h> #include<math.h> #include<conio.h> #include<dos.h> #include<alloc.h> #include<stdlib.h> #define RAD 3.141592/180 class fig { private: int x1,x2,y1,y2,xinc,yinc; public: void car() { xinc=10;yinc=10; x1=y1=10; x2=x1+90;y2=y1+35; int poly[]={x1+5,y1+10,x1+15,y1+10,x1+20,y1,x1+50,y1,x1+60,y1+10,x1+90,y1+17,x1+90,y1+20,x1+5,y1+20,x1+5,y1+10}; setfillstyle(SOLID_FILL,LIGHTGRAY); setlinestyle(SOLID_LINE,1,2); setcolor(4); drawpoly(9,poly); line(x1+15,y1+10,x1+60,y1+10); line(x1+20,y1+10,x1+20,y1); line(x1+35,y1+10,x1+35,y1); line(x1+50,y1+10,x1+50,y1); floodfill(x1+18,y1+8,4); floodfill(x1+28,y1+8,4); floodfill(x1+36,y1+8,4); floodfill(x1+52,y1+8,4); setfillstyle(SOLID_FILL,4); floodfill(x1+18,y1+12,4); setfillstyle(SOLID_FILL,BLUE); bar(x1+5,y1+20,x1+90,y1+25); setcolor(DARKGRAY); circle(x1+20,y1+25,8); circle(x1+20,y1+25,6); setfillstyle(1,8); floodfill(x1+21,y1+25,8); circle(x1+70,y1+25,8); circle(x1+70,y1+25,6); floodfill(x1+71,y1+25,8); int size=imagesize(x1,y1,x2,y2); void far *buf=farmalloc(size); getimage(x1,y1,x2,y2,buf); while(!kbhit()) { putimage(x1,y1,buf,XOR_PUT); x1+=xinc;x2+=xinc; if(x2<(getmaxx()-10)) putimage(x1,y1,buf,COPY_PUT); else { cleardevice(); x1=10;x2=x1+90; y1+=yinc;y2+=yinc; if(y2<(getmaxy()-10)) { putimage(x1,y1,buf,COPY_PUT); } else {y1=10;y2=y1+35;} } delay(200); } farfree(buf); getch(); } } } } void main() { int gd=DETECT,gm; initgraph(&gd,&gm,"d:\\cplus"); fig f; f.car(); cleardevice(); closegraph(); }
Line (x1, y1, x2, y1); Line (x2, y1, x2, y2); Line (x2, y2, x1, y2); Line (x1, y2, x1, y1);
Oh, don't you worry, friend! When using the slope formula, whether you do (y2-y1)/(x2-x1) or (y1-y2)/(x1-x2), the answer will be the same! It's all about the difference in vertical and horizontal values, and as long as you stay consistent in your calculations, you'll find the slope just fine. Just trust your instincts and enjoy the process of solving the equation.
if we take the (x1,y1),(x2,y2) as coordinates the formula was (x-x1)/(x2-x1)=(y-y1)/(y2-y1)
GIven 2 distance points (x1,y1) and (x2,y2) we can draw a line between those point and the midpoint formula finds the midpoint of that line. Call the midpoint (m1,m2) then it is [ (x1+x1 )/2 , (y1+y2/2)]
(y -y1)=(x -x1)(y2 -y1)/(x2 -x1) defines the line containing coordinates (x1,y1) and (x2.y2).
y - y1 = m(x - x1), where m is the slope of the line, and (x1, y1) is a point on the line.
Let P(x1, y1), Q(x2, y2), and M(x3, y3).If M is the midpoint of PQ, then,(x3, y3) = [(x1 + x2)/2, (y1 + y2)/2]We need to verify that,√[[(x1 + x2)/2 - x1]^2 + [(y1 + y2)/2 - y1]^2] = √[[x2 - (x1 + x2)/2]^2 + [y2 - (y1 + y2)/2]^2]]Let's work separately in both sides. Left side:√[[(x1 + x2)/2 - x1]^2 + [(y1 + y2)/2 - y1]^2]= √[[(x1/2 + x2/2)]^2 - (2)(x1)[(x1/2 + x2/2)) + x1^2] + [(y1/2 + y2/2)]^2 - (2)(y1)[(y1/2 + y2/2)] + y1^2]]= √[[(x1)^2]/4 + [(x1)(x2)]/2 + [(x2)^2]/4 - (x1)^2 - (x1)(x2) + (x1)^2 +[(y1)^2]/4 + [(y1)(y2)]/2 + [(y2)^2]/4 - (y1)^2 - (y1)(y2) + (y1)^2]]= √[[(x1)^2]/4 - [(x1)(x2)]/2 + [(x2)^2]/4 + [(y1)^2]/4 - [(y1)(y2)]/2 + [(y2)^2]/4]]Right side:√[[x2 - (x1 + x2)/2]^2 + [y2 - (y1 + y2)/2]^2]]= √[[(x2)^2 - (2)(x2)[(x1/2 + x2/2)] + [(x1/2 + x2/2)]^2 + [(y2)^2 - (2)(y2)[(y1/2 + y2/2)] + [(y1/2 + y2/2)]^2]]= √[[(x2)^2 - (x1)(x2) - (x2)^2 + [(x1)^2]/4 + [(x1)(x2)]/2 + [(x2)^2]/4 + (y2)^2 - (y1)[(y2) - (y2)^2 + [(y1)^2]/4) + [(y1)(y2)]/2 + [(y2)^2]/4]]= √[[(x1)^2]/4 - [(x1)(x2)]/2 + [(x2)^2]/4 + [(y1)^2]/4 - [(y1)(y2)]/2 + [(y2)^2]/4]]Since the left and right sides are equals, the identity is true. Thus, the length of PM equals the length of MQ. As the result, M is the midpoint of PQ
slope is the steepness of a line, it is defined by the change in the y values divided by the change in the x values of any two points on a line (x1, y1) and (x2, y2) slope = (y1 - y2)/(x1 - x2)
It's m = y2 - y1/ x2- x1 It's m equals y2 minus y1 over x2 minus x1
(y-y1)=(y2-y1/x2-x1)(x-x1)
(y-y1)=m(x-x1) OR we can write it y=m(x-x1)+y1