mihaispr
Administrator
Inregistrat: acum 17 ani
Postari: 2142
|
|
/*Programul calculeaza produsul mixt a 3vectori Obs.Produsul mixt se poate calcula numai daca avem 3 vectori v1=x1*i+y1*j+z1*k; v2=x2*i+y2*j+z2*k; v3=x3*i+y3*j+z3*k;(expresiile sub forma analitica pt.vectorii v1,v2 si v3 in spatiu;daca erau in plan k=0) Produsul mixt este este un determinant de ordin 3= x1*y2*z3+x3*y1*z2+x2*y3*z1-x3*y2*z1-x2*y1*z3-x1*y3*z2 i este versorul axei Ox si are lungimea 1 deci i=1 j este versorul axei Oy si are lungimea 1 deci j=1 */
#include<stdio.h> #include<conio.h> #include<math.h> //directiva care contine fctiile trig,exp si log #include<iostream.h>
typedef struct { int x1,x2,x3,y1,y2,y3,z1,z2,z3,v1,v2,v3,prmixt; char i,j,k; }scalar;
scalar v1,v2,v3;
void citire(scalar &v1,scalar &v2,scalar &v3) {printf("x1=" );scanf("%d",&v1.x1); printf("y1=" );scanf("%d",&v1.y1); printf("z1=" );scanf("%d",&v1.z1); printf("\n" ); //lasa un rand liber printf("x2=" );scanf("%d",&v2.x2); printf("y2=" );scanf("%d",&v2.y2); printf("z2=" );scanf("%d",&v2.z2); printf("x3=" );scanf("%d",&v3.x3); printf("y3=" );scanf("%d",&v3.y3); printf("z3=" );scanf("%d",&v3.z3); }
void afisare(scalar v1,scalar v2,scalar v3) {int x1,x2,x3,y1,y2,y3,z1,z2,z3,prmixt; //afisarea cu cout a celor 3 vectori printf("\n vectorul v1=" ); cout<<""<<v1.x1<<"*i+"<<v1.y1<<"*j+"<<v1.z1<<"*k"<< endl; printf("\n vectorul v2=" ); cout<<""<<v2.x2<<"*i+"<<v2.y2<<"*j+"<<v2.z2<<"*k"<< endl; printf("\n vectorul v3=" ); cout<<""<<v3.x3<<"*i+"<<v3.y3<<"*j+"<<v3.z3<<"*k"<< endl;
//afisarea cu cout a produsului mixt cout<<""<<(x1*y2*z3)+(x3*y1*z2)+(x2*y3*z1)-(x3*y2*z1)-(x2*y1*z3)-(x1*y3*z2)<< endl; }
void main() {clrscr(); citire(v1,v2,v3); afisare(v1,v2,v3); getch(); }
|
|