Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class vector{
- public:
- int x,y,z;
- vector(int x1,int y1,int z1):x(x1),y(y1),z(z1){}
- vector add(vector other){
- return vector(x + other.x, y + other.y, z + other.z);
- }
- float dot(vector oth){
- return x*oth.x + y*oth.y + z*oth.z;
- }
- vector cross(vector ot){
- return vector (z * ot.y - y * ot.z, x*ot.z - z-ot.x, y*ot.x - x*ot.y);
- }
- void print(){
- cout<< x << '\t' << y << '\t'<< z << endl;
- }
- };
- int main()
- {
- vector a(1,0,0);
- a.print();
- vector b(0,1,0);
- b.print();
- vector c = a.add(b);
- c.print();
- float d=a.dot(b);
- cout<<d<<endl;
- vector s= a.cross(b);
- s.print();
- }
Add Comment
Please, Sign In to add comment