Created
March 15, 2018 18:39
-
-
Save sienki-jenki/df24b148a2ec185ff2dc83056b56dedd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdlib> | |
#include <math.h> | |
#include <ctime> | |
#include <fstream> | |
#include <iomanip> | |
using namespace std; | |
class wektor{ | |
public: | |
float x,y,cx,cy; | |
void wypiszxy(); | |
void przypiszxy(float xx,float yy); | |
}; | |
class kulka{ | |
public: | |
wektor poloz; | |
void skrec(float rot); | |
void skrec1(float rot); | |
}; | |
void wektor::wypiszxy(){ | |
cout<<"{"<<x<<","<<y<<"},"<<endl; | |
//cout<<"Kat pomiedzy x a r wynosi: "<<fi<<endl; | |
}; | |
void wektor::przypiszxy(float xx,float yy){ | |
cx=xx; | |
cy=yy; | |
}; | |
void kulka::skrec(float rot){ | |
poloz.x = poloz.cx + cos(rot) * 2; | |
poloz.y = poloz.cy + sin(rot) * 2; | |
}; | |
void kulka::skrec1(float rot){ | |
poloz.x = poloz.cx + cos(rot) * 5; | |
poloz.y = poloz.cy + sin(rot) * 5; | |
}; | |
int main(){ | |
kulka k1; | |
k1.poloz.przypiszxy(2.1,0.9); | |
int ilosc_rogow; | |
cout<<"Podaj ilosc rogow: "; | |
cin>>ilosc_rogow; | |
float step = M_PI/ilosc_rogow; | |
float rot = M_PI /2*3; | |
//cout<<k1.poloz.cx<<" "<<k1.poloz.cy<<endl; | |
for(int c=0;c<ilosc_rogow;c++){ | |
k1.skrec(rot); | |
rot = rot + step; | |
k1.poloz.wypiszxy(); | |
k1.skrec1(rot); | |
rot = rot + step; | |
k1.poloz.wypiszxy(); | |
}; | |
cout<<"{2.1,-1.1}"<<endl; | |
return 0; | |
} | |
/*int main(){ | |
int ilosc_rogow,c; | |
float step=0; | |
float rot = M_PI /2*3; | |
c=0; | |
wektor2d w1; | |
w1.x=2.1; | |
w1.y=0.9; | |
kulka k1; | |
cout<<"Podaj ilosc rogow: "; | |
cin>>ilosc_rogow; | |
for(int i=0;i<ilosc_rogow;i++){ | |
c++; | |
k1.lec(c); | |
k1.skrec(rot); | |
k1.poloz.wypiszxyf(); | |
rot = rot + step; | |
} | |
/*float ilosc_rogow; | |
float step = M_PI / ilosc_rogow; | |
float cx=2.1; | |
float cy=0.9; | |
float rot = M_PI /2*3; | |
ofstream myfile; | |
myfile.open ("wspolrzedne.txt"); | |
for (int i = 0; i < ilosc_rogow; i++) { | |
x = cx + cos(rot) * 2; | |
y = cy + sin(rot) * 2; | |
rot = rot + step; | |
myfile<<"{"<<x<<","<<y<<"},"<<endl; | |
x = cx + cos(rot) * 5; | |
cout<<"x2= "<<x<<endl; | |
y = cy + sin(rot) * 5; | |
cout<<"y2= "<<y<<endl; | |
rot = rot + step; | |
myfile<<"{"<<x<<","<<y<<"},"<<endl; | |
} | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment