#include<iostream>
using namespace std;
int main()
{
double x[2] = { 0,0 }, y[2] = { 0,-4 }, z[2] = { -3,0 };
double CXx, CYx, CZx, CXy, CYy, CZy, CXz, CYz, CZz, D,L;
L = sqrt(pow(x[1] - x[0], 2) + pow(y[1] - y[0], 2) + pow(z[1] - z[0], 2));
if (x[0] == x[1] && y[0] == y[1]) {
if (z[1] > z[0]) {
double Lambda[3][3] = { { 0,0,1 },{ 0,1,0 },{ -1,0,0 } };
}
else {
double Lambda[3][3] = { { 0,0,-1 },{ 0,1,0 },{ 1,0,0 } };
}
}
else
{
CXx = (x[1] - x[0]) / L;
CYx = (y[1] - y[0]) / L;
CZx = (z[1] - z[0]) / L;
D = sqrt(pow(CXx, 2) + pow(CYx, 2));
CXy = -CYx / D;
CYy = CXx / D;
CZy = 0;
CXz = -(CXx*CZx) / D;
CYz = -(CYx*CZx) / D;
CZz = D;
double Lambda[3][3] = { { CXx,CYx,CZx },{ CXy,CYy,CZy },{ CXz,CYz,CZz } };
}
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
cout << Lambda[i][j] << " ";
}cout << endl;
}
return 0;
}
I am unable to print the 2D array Lambda. It is stated as Undefined. I know that there is some problem with my If-Else statement but I am unable to find what. When I define Lambda before the conditional statements I am getting an output. What do I not understand about the conditional statements.