Оба варианта работают.
CODE:extern "C" __declspec(dllexport) int get_direction(int x_start, int y_start, int x_end, int y_end)
{
// Convert from isometric coordinates to 2D coordinates
double x_start_2d = x_start - y_start;
double y_start_2d = (x_start + y_start) / 2;
double x_end_2d = x_end - y_end;
double y_end_2d = (x_end + y_end) / 2;
// Compute the direction vector in 2D space
double dx = x_end_2d - x_start_2d;
double dy = y_end_2d - y_start_2d;
// Compute the angle of the direction vector in degrees using C Standard Library's atan2
double angle = atan2(dy, dx) * 180.0 / M_PI;
// Convert the result to int before returning
return static_cast<int>(angle);
}
CODE:// вызов функции из кибор
int result = get_direction(111, 111, 333, 333);
CODE:extern "C" __declspec(dllexport) int get_direction2(double *x_start, double *y_start, double *x_end, double *y_end)
{
// Convert from isometric coordinates to 2D coordinates
double x_start_2d = *x_start - *y_start;
double y_start_2d = (*x_start + *y_start) / 2;
double x_end_2d = *x_end - *y_end;
double y_end_2d = (*x_end + *y_end) / 2;
// Compute the direction vector in 2D space
double dx = x_end_2d - x_start_2d;
double dy = y_end_2d - y_start_2d;
// Compute the angle of the direction vector in degrees using C Standard Library's atan2
double angle = atan2(dy, dx) * 180.0 / M_PI;
// Convert the result to int before returning
return static_cast<int>(angle);
}
CODE:// вызов функции из кибор
double x_start = 111;
double y_start = 111;
double x_end = 333;
double y_end = 333;
int result = get_direction2(address(#x_start), address(#y_start), address(#x_end), address(#y_end)); |