Answer the question
In order to leave comments, you need to log in
How to connect the vertices of a polygon in pairs so that the lines do not intersect?
I need it for the visualizer of peculiar formulas.
For example, the formula 3p, 5p, 4p should look like this
. I drew it crookedly, but the meaning is clear. Interested in the implementation in C # or just give me the algorithm, I'll write it myself.
Answer the question
In order to leave comments, you need to log in
a regular container with a fixed width of 1140px, it will stay centered on large monitors.
Everything around the edges is background pictures - they will stretch.
joxi.ru/gmvbGY3tRBB8ma
it's too complicated and expensive it will be
easier to rewrite from scratch
You can get a list of vertices using formulas and connect them one by one. In this case, the lines will not intersect.
IEnumerable<Point> GetPoints(int points) // points - количество вершин
{
return Enumerable.Range(0, points)
.Select(i => 2 * i * Math.PI / points)
.Select(arg => new Point
{
X = Math.Cos(arg),
Y = Math.Sin(arg)
});
}
struct Point
{
public double X;
public double Y;
}
It’s easiest for you to look in the direction of graphs, any formula you describe (for example, from chemistry) can be described by a graph, the construction of which the problem has already been solved 100500 times, you can look at an example here habrahabr.ru/post/116758
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question