GeometryAlgorithm.h 711 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * GeometryAlgorithm.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. class GeometryAlgorithm
  12. {
  13. public:
  14. struct Node
  15. {
  16. double x;
  17. double y;
  18. double dx = 0;
  19. double dy = 0;
  20. int id;
  21. };
  22. struct Edge
  23. {
  24. int from;
  25. int to;
  26. };
  27. static double distance(double x1, double y1, double x2, double y2);
  28. static bool edgesIntersect(const Node& a, const Node& b, const Node& c, const Node& d);
  29. static void forceDirectedLayout(std::vector<Node>& nodes, const std::vector<Edge>& edges, int iterations, double width, double height);
  30. };