GeometryAlgorithm.h 762 B

1234567891011121314151617181920212223242526272829303132
  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. #include "../StdInc.h"
  12. class GeometryAlgorithm
  13. {
  14. public:
  15. struct Node
  16. {
  17. double x, y;
  18. double dx = 0, dy = 0;
  19. int id;
  20. };
  21. struct Edge
  22. {
  23. int from, to;
  24. };
  25. static double distance(double x1, double y1, double x2, double y2);
  26. static bool edgesIntersect(const Node& a, const Node& b, const Node& c, const Node& d);
  27. static void forceDirectedLayout(std::vector<Node>& nodes, const std::vector<Edge>& edges, int iterations, double width, double height);
  28. };