1

Lets say I have a triangle like this:

enter image description here

and an array of the points [A,B,C,D,E,F]

Is there a way to calculate the array for an 120˚ rotated version of the triangle where the array would look like this [C,E,F,B,D,A] or [F,D,A,E,B,C]. I'm looking for a way that would also work for triangles that are be split into smaller pieces.

6
  • Um - rotating a triangle by 120 degrees around its center, doesn't that yield the same triangle (assuming all sides have the same lengths)? Sep 23, 2014 at 20:08
  • yes but if you maintain labeling of vertices and the order of building the array, then the array will be different after a rotation of 120 degrees around the middle point. @Andreas What are the other conditions of rotation? Will it be always a multiple of 120 degrees? And if not what is the protocol for building the array if the base edge is not parallel to the horizontal of the screen?
    – Pankrates
    Sep 23, 2014 at 20:13
  • @Pankrates, yes always 120˚. The idea is store lines like from A to B, which would be from index0 to index1, with the rotated arrays I would get the coordinates C and E or F and E. The triangle is as simple as in the image. Sep 23, 2014 at 20:20
  • How do you propose splitting this triangle into 8 pieces (as mentioned in the comments below)? 16 I can see, but not 8.
    – beaker
    Sep 23, 2014 at 21:10
  • Just add another row of rectangles to the bottom, or split every edge into 3 pieces instead of 2 Sep 23, 2014 at 21:17

4 Answers 4

1

Under the assumption that the rotation can be only exactly 120 degrees in clockwise direction and the given start array is [A,B,C,D,E,F] it is quite easy to see that A,C,F will only ever occupy index 0,2,5 and B,D,E will only ever occupy index 1,3,4

Simple permutation rules arise for a single 120 degree rotation

index 0 -> 5
index 2 -> 0
index 5 -> 2
index 1 -> 3
index 3 -> 4
index 4 -> 1

This can be further abstracted to simple code

2
  • Ok, but would this also work for a triangle that is split into 8 instead of 4 pieces. Sep 23, 2014 at 20:37
  • no clearly this wouldn't as it only considers 6 vertices. It might however very well be possible to derive a general algorithm that works for any division of the triangle however this is not trivial. I would suggest considering a different approach of building the array, in which case @Reinhard suggested a very easy solution
    – Pankrates
    Sep 23, 2014 at 20:42
1

Imagine you would fill your array not like you did, but in the following way:
Take a straight line from the center of the triangle to point A.
Rotate it to the right. It will touch point B, C, E, F and D. Fill the array this way: ABCEFD.
Then it is clear how it looks like after a rotation of 120 degrees: CEFDAB, and after another 120 degrees: FDABCE. You just had to rotate the array contents 2 positions left.

EDIT (due to the comment below):
You can consider the array as closed circular structure. You fill the "circular array" point by point as you encounter them by rotating the half line. Of course, you can start at any angle. This will simply change the start point in the circular array. So it works for deeper splitting also. One thing one had to consider is that you will encounter at certain angles 2 or more points on the half line. In this case you had to use a rule in which sequence you fill them into the circular array. You could e.g. fill them from inside out.

So, is it really required to express your array in the not well adapted order ABCDEF initially?

2
  • Ok, but would this also work for a triangle that is split into 8 instead of 4 pieces. Sep 23, 2014 at 20:37
  • No the initial order is not that important. Sep 24, 2014 at 6:02
0

Since this is always a multiple of 120˚, probably the simplest is to compute two permutations for rotating by 120˚ and 240˚. These permutations would simply map points to new locations in the array.

0

Generally speaking, no algorithm can "guess" how you denoted the vertexes.

Either there must be a systematic way that you need to tell us, or you can work as follows: for every vertex apply the 120° rotation to the coordinates and find another vertex that matches them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.