diff --git a/.vs/3dMath/v16/.suo b/.vs/3dMath/v16/.suo new file mode 100644 index 0000000..d78846f Binary files /dev/null and b/.vs/3dMath/v16/.suo differ diff --git a/GMath.cpp b/GMath.cpp index 136704b..e2a51fe 100644 --- a/GMath.cpp +++ b/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) { diff --git a/GMath.h b/GMath.h index ec8d62e..8e5c110 100644 --- a/GMath.h +++ b/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 diff --git a/main.cpp b/main.cpp index 1757d9f..0a09388 100644 --- a/main.cpp +++ b/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; } \ No newline at end of file