Answer the question
In order to leave comments, you need to log in
How to learn to triangulate an arbitrary path (JavaScript + SVG)?
The question rather sounds like "Who has free time to teach a person geometry (triangulation)".
I want to write a script for triangulating an arbitrary polygon, but I don't know what algorithm.
I will use an SVG file with an arbitrary path and JavsScript.
I wanted from simple to complex. Found a JavaScript example and parsed it.
The construction process itself is understood, but it is used to fill the background, i.e. when the boundary coordinates are known.
Those. we know the size of the polygon, from the width and height we calculate how many polygons will fit and how many vertices we need to create.
The extreme vertices are determined by the size of the screen.
Then we arrange the dots in a cycle and connect them in turn to make right-angled triangles. (in fact, we break it into squares and draw diagonals). Then we randomly shift the vertices in different directions.
The output is a polygonal background.
But what if you need to triangulate, for example, a Rhombus? Or a pentagon? Or if there is an inner outline that shows which area does not need to be filled?
In general, I wanted to read the theory
There was an article in pfd .
Only I don’t remember anything from my studies, and even there I didn’t shine with mathematical sciences.
Plugging immediately on the introduction, for example, I don’t know what "IR ^ 2" is (the phrase: "The set of points in IR2").
So I'm not sure that I can easily master this article.
Therefore, questions arose:
1. Is this article suitable for my tasks in general?
2. Where to start? (what material to read) Tutorial / more detailed articles?
3. Maybe someone will find time to suggest incomprehensible questions?
I would like to say ahead of time:
I understand that I want to take up the invention of the bicycle, and without much preparation.
I know that there are d3js and other libraries, but I don’t have deadlines, there are no specific tasks. At the moment, I would just be interested in writing such a tool myself.
I was impressed with the tool:
somestuff.ru/filter/HTML5/I There you can even specify control points for generating polygons.
Until then, it's too early for me.
At least just understand the basics, principles, triangulation algorithms, develop a script based on this data.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question