0

Problem:

Given a triangle described by coordinates of its tops/tips/vertices, fill it with triangles.

Rules:

triangles inside it should have space between each other (I think that I will calculate function y=k*x+b for one side of triangle and increase\decrease b to 10-20 or make space between tops (one top for triangle)) something like this:

wanted result

But I want to create many variants of "filling".

Can you tell me if there is any kind of function to determine the position of inside triangles (center and angle of rotation or vertices) (relative to their centers))?

Or what theorems\functions can be looked for finding this solution?

P.S. I plan to use JS\Canvas for calculating this dynamically.

Spektre
  • 45,598
  • 10
  • 100
  • 347
MAxxiS
  • 19
  • 2
  • 1
    *"I want to create many varios"*: You'll have to be specific. What do you mean with "tops"? The corners? *"is there any kind of function to determinate position... their tops... and their angle of rotation?"*: Please ask only one question, and this is more a question about mathematics, not programming. – trincot Dec 08 '19 at 08:31
  • 1
    Share what have tried so far – Mahbub Moon Dec 08 '19 at 08:31
  • have a look at `atan2(y1-y0,x1-x0)` its standard math function it returns angle of line in all 4 quadrants ... Also I would use perpendicular vectors to sides for the displacement instead of using line equation that does not work for all cases... anyway there are also field based solutions for problems like this see [How to implement a constraint solver for 2-D geometry?](https://stackoverflow.com/a/40827518/2521214) – Spektre Dec 08 '19 at 09:53
  • @MahbubMoon, here is example - https://ibb.co/y8SsXRj . In the example you also can see two triangles near each other at the left and this is correct situation for me too – MAxxiS Dec 08 '19 at 11:04
  • @trincot, I am agree that it is more about math than coding. Generally I want to have at the end you can see here - https://ibb.co/y8SsXRj . – MAxxiS Dec 08 '19 at 11:06
  • Seeing that output, I think you need to add much more specification to your question. The drawing seems quite random. What *exactly* is the input that determines this output? – trincot Dec 08 '19 at 11:51
  • @trincot, this is main idea - to generate such images by input params (for example it can be about 6 params from 0 to 100). – MAxxiS Dec 08 '19 at 13:13
  • 2
    That is too vague. Focus on one particular problem you have, with concrete parameters and concrete expected output, and the logic for getting the output from the input. – trincot Dec 08 '19 at 13:16
  • See [Delaunay triangulation](https://en.m.wikipedia.org/wiki/Delaunay_triangulation) ("tends to avoid *sliver triangles*") and imagine each triangle shrunk by half the spacing wanted. – greybeard Dec 08 '19 at 23:20
  • Now the picture is included in the post, I see a non-triangle inside (or two alternate pairs of triangles lacking spacing). – greybeard Dec 09 '19 at 08:51

0 Answers0