K
K
Kimely2014-09-20 15:45:47
css
Kimely, 2014-09-20 15:45:47

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
9e41b69ca43c4582a506461245e689f2.png
. 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

6 answer(s)
A
Alex Glebov, 2016-09-18
@SkiperX

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

R
riot26, 2016-09-18
@riot26

https://habrahabr.ru/post/310186/
is it?

R
Rafael™, 2016-09-18
@maxminimus

it's too complicated and expensive it will be
easier to rewrite from scratch

A
aush, 2014-09-20
@aush

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;
}

UPD: it became interesting, I decided to draw a little. It turns out something like these pictures ppppp.png
. According to your comment, I still didn’t understand what exactly you want to do, but if you’re interested, you can look at the code: archive with the project (I sculpted the code as ideas appeared, so there is some mess; if something is not clear - ask) .

V
Vitaly, 2014-09-24
@vipuhoff

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

T
tsarevfs, 2014-09-20
@tsarevfs

Are you wondering how to draw it or how to get it geometrically? If the latter, describe in more detail what the task is: what is given and what should be the output.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question