Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <cmath>
- using namespace std;
- class Punkt {
- public:
- float x;
- float y;
- void display()
- {
- cout<<"("<<x<<", "<<y<<")";
- }
- Punkt(float positionX, float positionY) {
- x=positionX;
- y=positionY;}
- Punkt(){
- x=0;
- y=0;
- }
- };
- class Trojkat{
- public:
- Punkt A, B, C;
- float liczPole()
- {
- float AB = sqrt((A.x - B.x)*(A.x - B.x)+(A.y - B.y)*(A.y - B.y));
- float d, e, f;
- d=(B.y-A.y)/(B.x-A.x);
- e=A.y-d*A.x;
- //C.y=(-1/d)*C.x+f
- f=C.y-(-1/d)*C.x;
- Punkt P;
- //y=d*x+e
- //y=(-1/d)*x+f
- //d*x+e=(-1/d)*x+f
- //d*x+(1/d)*x=f-e
- P.x=(f-e)/(d+(1/d));
- P.y=(-1/d)*P.x+f;
- float PC = sqrt((P.x - C.x)*(P.x - C.x)+(P.y - C.y)*(P.y - C.y));
- return (AB*PC)/2;
- }
- float liczObwod()
- {
- float AB = sqrt((A.x - B.x)*(A.x - B.x)+(A.y - B.y)*(A.y - B.y));
- float BC = sqrt((C.x - B.x)*(C.x - B.x)+(C.y - B.y)*(C.y - B.y));
- float CA = sqrt((C.x - A.x)*(C.x - A.x)+(C.y - A.y)*(C.y - A.y));
- return AB+BC+CA;
- }
- };
- int main()
- {
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement