Message Boards Message Boards

GROUPS:

Find the Coordinates of a triangular mesh?

Posted 11 days ago
143 Views
|
4 Replies
|
1 Total Likes
|

Hello , I have an equilateral triangle with vertices at {0,0},{4,0} and {2,2 Sqrt[3]}. Three points on each side are taken dividing the side into four equal parts .These points are joined so as to draw lines parallel to the sides. How do we get the coordinates of the intersecting points of the triangular mesh obtained? For example {{1/2,sqrt[3]/2},{1,0},{0,0}} is a triangle. Thanks for any help.

4 Replies

A geometric way is to use InfiniteLine and RegionIntersection:

a = {0, 0}; b = {4, 0}; c = {2, 2 Sqrt[3]};
ab3 = Table[t*a + (1 - t) b, {t, {1/4, 1/2, 3/4}}];
ac3 = Table[t*a + (1 - t) c, {t, {1/4, 1/2, 3/4}}];
bc3 = Table[t*b + (1 - t) c, {t, {1/4, 1/2, 3/4}}];
ab3LinesParallelToAC = Table[InfiniteLine[pt, c - a], {pt, ab3}];
ab3LinesParallelToBC = Table[InfiniteLine[pt, b - c], {pt, ab3}];
ac3LinesParallelToAB = Table[InfiniteLine[pt, a - b], {pt, ac3}];
Graphics[{{Gray, Polygon[{a, b, c}]}, ab3LinesParallelToAC, Green, 
  ab3LinesParallelToBC, Red, ac3LinesParallelToAB, Blue, 
  PointSize[Large], 
  Outer[RegionIntersection, ab3LinesParallelToAC, 
   ab3LinesParallelToBC], 
  Outer[RegionIntersection, ab3LinesParallelToAC, 
   ac3LinesParallelToAB],
  Outer[RegionIntersection, ab3LinesParallelToBC, 
   ac3LinesParallelToAB]}]

Thanks Gorni, Nicely done.Gives co-ordinates of desired points on the sides of the triangle but this shows the way to get points inside the triangle. I hope I can get them.Thanks again.

IGraph/M has a function to generate triangular graphs, with coordinates attached.

<<IGraphM`
g = IGTriangularLattice[4, VertexLabels -> "Name"]

Mathematica graphics

Get the coordinates like so:

In[54]:= GraphEmbedding[g]
Out[54]= {{1/2, (3 Sqrt[3])/2}, {0, Sqrt[3]}, {1, Sqrt[3]}, {-(1/2), 
  Sqrt[3]/2}, {1/2, Sqrt[3]/2}, {3/2, Sqrt[3]/2}, {-1, 0}, {0, 0}, {1,
   0}, {2, 0}}

They can be scaled, translated, etc. with ScalingTransform, TranslationTransform, etc. to deal with triangles of different dimensions.

You can look up the implementation in https://github.com/szhorvat/IGraphM/blob/master/IGraphM/DeterministicGenerators.m which you might find helpful to build on.

Thanks Horvat, In fact I have found a way to get the coordinates of a triangular mesh of any size as described earlier without the graphical representation. My interest is to count the number of all equilateral triangles so formed by these coordinates. But i know for a triangle of size 4,the number of triangles obtained from the 15 vertices is 27. Any help.

(* n=Number of parallel lines = size of triangle;h= height of unit triangle;x=vertex \
points *)
n = 4;
h = Sqrt[3] /2;
Array[x, n];
x[0] = {{n/2, n h}}
For[i = 1, i <= n, i++, 
  x[i] = Table[{x[0][[1, 1]] - i/2 + j, n h - i h}, {j, 0, i}]];
set = Apply[Union, Table[x[i], {i, 0, n}]]
Length[set]
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract