blobt 3 years ago
parent
commit
c4c321f45e
  1. BIN
      .vs/3dMath/v16/.suo
  2. 15
      GMath.cpp
  3. 1
      GMath.h
  4. 53
      main.cpp

BIN
.vs/3dMath/v16/.suo

15
GMath.cpp

@ -268,6 +268,21 @@ GVector::GVector(const GVector & copy)
memcpy(v, copy.v, n * sizeof(float));
}
GVector::GVector(int dim, const GVector3& copy)
{
n = dim;
v = new float[n];
for (int i = 0; i < n; i++) {
if (i < 3) {
v[i] = copy[i];
}
else {
v[i] = 0;
}
}
}
GVector::~GVector()
{
if (v) {

1
GMath.h

@ -89,6 +89,7 @@ public:
GVector(int dim, double x, ...);
GVector(const GVector3& copy);
GVector(const GVector& copy);
GVector(int dim, const GVector3& copy);
~GVector();
//GVector 3

53
main.cpp

@ -1,48 +1,43 @@
#include "GMath.h"
#include "CArrayBuffer.h"
#include "CDataView.h"
#include "CFloat32Array.h"
int main() {
/*int linda = 4;
float a[] = {
2, -2, 0,
-2, 1, -2,
0, -2, 0
};
GMatrix A(3, 3, a);
GMatrix E(3, 3);
E.SetIdentity();
E = E * linda;
float x1 = 0.0;
float y1 = 0.0;
float z1 = 1.0;
float x2 = 0.0;
float y2 = 1.0;
float z2 = 0.0;
float x3 = 12.0;
float y3 = 10.0;
float z3 = 12.0;
GVector3 v1(x1, y1, z1);
GVector3 v2(x2, y2, z2);
GVector3 v3(x3, y3, z3);
GVector t = v1 ^ v2;
float m = t * v3;
cout << ReduceRowEchelonForm(A -E) << endl;*/
cout << m << endl;
float a[] = {
2, -2, 0,
-2, 1, -2,
0, -2, 0
x1, x2, x3,
y1, y2, y3,
z1, z2, z3
};
GMatrix A(3, 3, a);
GVector3 x1(0.5, 1, 1);
GVector3 x2(-1, -0.5, 1);
GVector3 x3(2, -2, 1);
x1.normalize();
x2.normalize();
x3.normalize();
GMatrix Q(3, 3);
GMatrix M1(3, 3, a);
cout << Det(M1) << endl;
Q.SetColVec(0, x1);
Q.SetColVec(1, x2);
Q.SetColVec(2, x3);
cout << Inverse(Q)*A*Q << endl;
return 0;
}
Loading…
Cancel
Save