diff --git a/.vs/3dMath/v15/.suo b/.vs/3dMath/v15/.suo index 8b14076..1327954 100644 Binary files a/.vs/3dMath/v15/.suo and b/.vs/3dMath/v15/.suo differ diff --git a/.vs/3dMath/v15/Browse.VC.opendb b/.vs/3dMath/v15/Browse.VC.opendb deleted file mode 100644 index f2a154f..0000000 Binary files a/.vs/3dMath/v15/Browse.VC.opendb and /dev/null differ diff --git a/main.cpp b/main.cpp index a163320..2718144 100644 --- a/main.cpp +++ b/main.cpp @@ -5,43 +5,49 @@ int main() { - GVector3 v1(SQRT(2)/2, SQRT(2) / 2, 0); - GVector3 v2(-1, 1, -1); - GVector3 v3(0, -2, -2); + /* + matrix P = (p1, p2, p3, ......, pn) + matrix A; + A * P = (A*p1, A*p2, A*p3, ......, A*pn) + */ + float a[] = { + 3, -1, 0, + 4, -1, 0, + -1, 0, 0 + }; + GMatrix A(3, 3, a); - //斯密特正交化 - GVector3 w1 = v1; - GVector3 w2 = v2 - proj(v2, w1); //cout << w2 << endl; - GVector3 w3 = v3 - proj(v3, w1) - proj(v3, w2); //cout << w3 << endl; + float p[] = { + 1, 2, 3, + 1, 2, 3, + 1, 2, 3 + }; + GMatrix P(3, 3, p); - //normalize - w1 = w1 / norm(w1); - w2 = w2 / norm(w2); - w3 = w3 / norm(w3); + //模拟P矩阵的第二列 + float x[] = { + 2, + 2, + 2 + }; + GMatrix X(3, 1, x); - GMatrix M1(3, 3); - M1.SetRowVec(0, w1); - M1.SetRowVec(1, w2); - M1.SetRowVec(2, w3); - cout << M1 << endl; + cout << A * P << endl; + cout << A * X << endl; - GMatrix M2 = Transpose(M1); - cout << M2 << endl; + /* + matrix P = (p1, p2, p3, ......, pn) + vector v = (v1, v2, v3, ......, vn) - cout << Det(M1) * Det(M2) << endl; + P * V = (p1 * v1) + (p2 * v2) + (p3 * v3) + ...... + (pn * vn) + */ + GVector c1 = A.GetColVec(0); + GVector c2 = A.GetColVec(1); + GVector c3 = A.GetColVec(2); - float a[] = { - 1, 2, 3, - 3, 1, 2, - 2, 3, 1 - }; - GMatrix M3(3, 3, a); + GVector ret = c1 * X[0][0] + c2 * X[1][0] + c3 * X[2][0]; + cout << ret << endl; - GMatrix M4 = Inverse(M3); - - cout << M3 << endl; - cout << M4 << endl; - cout << Det(M3) * Det(M4) << endl; return 0; } \ No newline at end of file