0

I have an array of Triangle objects that are equilateral triangles and have for x and y coordinates the center of the triangle :

enter image description here

The distance between this point and a, b or c is t_r. The distance between this point and A, B or C is t_R. The side of a triangle is t_size

I want to create a function that place each triangle on a grid following this order :

enter image description here

So this function gets the index of the triangle in the array and updates its x and y position. Do you have any idea how I could proceed ? You should note that when the triangles are upside down, their center point is still as if they were straight but I just draw them inverted. For example, the translation from the first triangle to the second isn't up and right but only right.

I really don't know how I could do this. I tried to find a pattern in each "level" (color) of triangles but I didn't find any, neither in the side where the next triangle will be that change for every triangle...

2
  • What problem are you facing, what have you tried so far? Commented Oct 11, 2018 at 11:11
  • But center of triangle 2 is higher by t_R/2 (one third of the height) Commented Oct 11, 2018 at 11:36

1 Answer 1

1

This seems relatively straightforward. There is a limited number of jumps needed to go from one step to the next, and they are quite predictable too.

Let us enumerate the different jumps:

  • 1 to 2 (also found in 8 to 9, or reversed in 4 to 5): (t_size * cos(30º), t_size * sin(30º))
  • 2 to 3 (or any other vertical-up): (0, t_size)
  • 3 to 4 (a reflection of 1 to 2): ( - t_size * cos(30º), t_size * sin(30º) )
  • 4 to 5 (left as an exercise)
  • 5 to 6 (another exercise)
  • 6 to 7 (as in moving from 4 to 2; therefore = - (d12 + d23 + d34), where dXY is the vector used to move from X to Y)
  • 6 to 1 = -d34

Now, let us continue the sequence using these displacements:

  • first ring: d12, d23, d34, d45, d56,
  • jump to next ring: d67
  • second ring: d61, d12, d23, d12, d23, d34, d23, d34, d45, d34, d45, d56, d45, d56, d61, d56, d61
  • jump to next: d67

In the next ring, you would extend the bolded segments (the "do a zigzag in this direction) to repeat them thrice, and in the n-th ring, you would extend them n times.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.