NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io


#include <iostream>
#include <conio.h>
#include <math.h>
using namespace std;


const float pi=M_PI;

//Deklaracja klasy
class Wektor
{
float x;
float y;
float z;
public:
Wektor(){}; //konstruktor bezparametrowy
Wektor(float New_x, float New_y, float New_z) //konstruktor z argumentami
{x=New_x; y=New_y, z=New_z;}
void wyprow(); //funkcja wypisujaca wynik

friend ostream & operator<<(ostream &wy, Wektor & v);// przeciazony operator
// do wypisywania wektora
friend istream& operator>>(istream & we, Wektor &v); // przeciazony operator
// do wczytywania wektora
friend float fun(Wektor &v1, Wektor &v2,float &alfa_); //zaprzyjazniona
//funkcja do wyliczania iloczynu skalarnego
friend float prossfer(Wektor &vv, float &beta, float &eps); //funkcja
//przekształcająca wektor z układu prostokatnego do sferycznego
friend Wektor sferpros(float mod_v,float beta, float eps); //funkcja
//przeksztalcajaca wektor z ukladu sferycznego na prostokatny
};

//-------- przeciazenie operatora << dla wektora-----------------
ostream & operator<<(ostream &wy, Wektor & v)
{
wy<<"("<<v.x<<","<<v.y<<","<<v.z<<")";
return wy;

}
//--------przeciazenie operatora >> dla wektora --------------------
istream& operator>>(istream & we, Wektor &v)
{
we>>v.x>>v.y>>v.z;
return we;
}

/*----funkcja przekształcająca wektor do układu sferycznego ---
przyjmujemy układ wspolrzednych kartezjanski lewoskrętny x i y w poziomie
z -składowa pionowa*/

float prossfer(Wektor &vv,float &beta, float &eps)
{

float modulv_p,modulv,x_, y_, z_;
x_=vv.x; y_=vv.y; z_=vv.z;
modulv_p=sqrt(x_*x_+y_*y_); //rzut wektora na płaszczyzne pozioma
modulv= sqrt(x_*x_+y_*y_+z_*z_); //moduł wektora - dlugosc
eps=asin(z_/modulv);
if(x_>0 && y_>0) beta=atan(y_/x_);
if(x_<0 && y_>0) beta=pi/2+atan(fabs(x_)/y_);
if(x_<0 && y_<0) beta=pi+atan(y_/x_);
if(x_>0 && y_<0) beta= 3*pi/4+ atan(x_/fabs(y_));
return modulv;

}
//--funkcja przekształcajaca wektor z ukladu sferycznego do prostokatnego
Wektor sferpros(float mod_v,float beta, float eps)
{
float dpv; //rzut dlugosci wektora na plaszczyzne
float x_, y_, z_;
Wektor w;
dpv=mod_v*cos(eps);
z_=mod_v*sin(eps);
x_=dpv*cos(beta);
y_= dpv*sin(beta);
w.x=x_; w.y=y_ ; w.z=z_;
return w;
}
//============== Program główny=======================================
int main(void)
{
cout<<"Aby zamienic wspolrzedne prostokatne na sferyczne wprowadz 1n"<<endl;
cout<<"Aby zamienic wspolrzedne sferyczne na prostokatne wprowadz 2n"<<endl;
float vvk1,vvk2,vvk3,vvk4, beta,ilocz_skal;
int wybor;
Wektor vk1,vk2,vk3,vk4,ww;
float dlug_wek,beta_wek, eps_wek ;

cin>>wybor;

if (wybor==1)
{

cout<<"n podaj 3 wspolrzedne wektora w jednej linii ze spacja(x y z)"<<endl;
cin>>vk1;
cout<<"nv1k="<<vk1;
dlug_wek=prossfer(vk1,beta_wek,eps_wek);
cout<<"n wspolrzedne wektora w ukadzie sferycznym dlug_wek="<<dlug_wek
<<" beta_wek= "<<beta_wek<<" eps_wek="<<eps_wek;
}
else if (wybor==2)
{

cout<<"Wprowadz dlugosc wektora (modul)"<<endl;
cin>>dlug_wek;
cout<<"Wprowadz kat beta wektora"<<endl;
cin>>beta_wek;
cout<<"Wprowadz kat epsilon wektora"<<endl;
cin>>eps_wek;
ww=sferpros(dlug_wek,beta_wek, eps_wek);
cout<<"nwspolrzedne prostokatne wektora w ukladzie prostokatnym sa nastepujace (x, y, z) = "<<ww<<endl;

}
else cout<<"Nieprawidlowy wybor. Nastapi zamkniecie programu";

getch();
return 0;
}



     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.