2025-05-22 23:26:34 +02:00
|
|
|
/*
|
2025-06-18 23:38:48 +02:00
|
|
|
* GeometryAlgorithm.h, part of VCMI engine
|
2025-05-22 23:26:34 +02:00
|
|
|
*
|
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
|
*
|
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2025-06-18 23:38:48 +02:00
|
|
|
class GeometryAlgorithm
|
2025-05-22 23:26:34 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2025-07-02 18:23:02 +03:00
|
|
|
struct Node
|
|
|
|
|
{
|
|
|
|
|
double x;
|
|
|
|
|
double y;
|
|
|
|
|
double dx = 0;
|
|
|
|
|
double dy = 0;
|
|
|
|
|
int id;
|
|
|
|
|
};
|
2025-05-22 23:26:34 +02:00
|
|
|
|
2025-07-02 18:23:02 +03:00
|
|
|
struct Edge
|
|
|
|
|
{
|
|
|
|
|
int from;
|
|
|
|
|
int to;
|
|
|
|
|
};
|
2025-05-22 23:26:34 +02:00
|
|
|
|
2025-07-02 18:23:02 +03:00
|
|
|
static double distance(double x1, double y1, double x2, double y2);
|
|
|
|
|
static bool edgesIntersect(const Node& a, const Node& b, const Node& c, const Node& d);
|
|
|
|
|
static void forceDirectedLayout(std::vector<Node>& nodes, const std::vector<Edge>& edges, int iterations, double width, double height);
|
2025-05-22 23:26:34 +02:00
|
|
|
};
|