We have txt file with numbers:
60 0
120 4
180 20
60 -28
180 28
30 -28
30 28
30 -28
60 0
I need a plot with first column in horizontal coordinate line and the second column in vertical coordinate line like on this picture. But now I have smth like this
std::ifstream omega_file("test.txt");
MoveToEx(hdc, 0, 0, NULL); // start point
double T_new = 0;
while (!omega_file.eof())
{
omega_file >> T >> Omega;
T_new = T_new T;
LineTo(hdc, T_new / 60 * horizontal_step_grid, - Omega * vertical_step_grid);
MoveToEx(hdc, T_new / 60 * horizontal_step_grid, - Omega * vertical_step_grid, NULL);
}
CodePudding user response:
You will need to draw two lines (horizontal, then vertical) instead of one per one coordinate.
Also note that LineTo()
sets the current position, so MoveToEx()
to the same coordinate is redundant.
Try this:
std::ifstream omega_file("test.txt");
MoveToEx(hdc, 0, 0, NULL); // start point
int currentY = 0;
double T_new = 0;
while (omega_file >> T >> Omega)
{
T_new = T_new T;
int x = T_new / 60 * horizontal_step_grid;
int nextY = - Omega * vertical_step_grid;
LineTo(hdc, x, currentY);
LineTo(hdc, x, nextY);
currentY = nextY;
}