1

Given 3 polygons which all are defined as flat (when seen from the side they have no points out of line with the rest, so essentially they are 2D shapes in 3D space), made of exactly 4 points, convex and with the additional information that each poly attaches to the other two at exactly two points each...

Starting from having these polygons "laying flat", that is: their values all lie on the x,y plane and all have a Z value of 0...

...how can I work out how to position these polygons in 3D space such that they are connected at their connecting points?

Matt W
  • 11,753
  • 25
  • 118
  • 215

2 Answers2

1

Label the polygons A, B, C. Select A such that B and C already each share an edge with it before folding, and consider it as remaining in the X-Y plane throughout the transformation.

Before folding, either there is exactly one point to which all three polygons attach, or there is not (in which case the resulting shape after folding contains a hole through it).

In the former case, consider that point (d). One of the edges attached to it will become shared by B and C after folding. Let e be the point on B that shares an edge with d but does not touch A. Similarly f for C. After folding, e and f are the same point. Consider the circle described by rotating e around the edge shared by A and B, and similarly for f about the edge shared by A and C. The circles intersect at exactly two points (one above and one below the X-Y plane). Write out the circle equations, solve, and arbitrarily select one of the two solutions. You now now the angles through which B and C have been rotated about the edges they share with A and the rest of the mesh is fully constrained.

In the latter case, find an edge of A such that one end attaches to B and the other to C. As before, consider the points on B and C that share edges with those points but not with A, rotate about the edges of A and solve for intersection.

Draw a diagram; it helps.

moonshadow
  • 86,889
  • 7
  • 82
  • 122
  • Thank you. Would you have code for solving those angles? Doing it in 3 dimensions is beating me. – Matt W Aug 15 '16 at 14:50
1

I'm going to assume that you want all your polygons to meet at one point. Here's how you would do the problem for triangles (it can be easily adapted to quadrilaterals).

Let's suppose in the 2D world your triangles are already arranged so that two of the corresponding pairs of sides are next to each other, and the common point of the triangles is the origin. In other words, let O be the origin, and we have points A, B, C, D so that our three triangles are AOB, BOC, and COD. (You can always apply some transformations to get to this situation.) The task is now to align OA with OD (these are assumed to have the same length) by "folding up" the triangle.* Here's what you would do in pseudocode:

assert(length(OA) == length(OD))
let L_A = line through A perpendicular to OB
let L_D = line through D perpendicular to OC
let E = intersection of L_A and L_D
let z = sqrt(length(OA) * length(OA) - length(OE) * length(OE))

let O' = (0, 0, 0), B' = (B.x, B.y, 0), C' = (C.x, C.y, 0)
let A' = (E.x, E.y, z)

Then, A'O'B' corresponds to AOB, B'O'C' corresponds to BmOC, and C'O'A' corresponds to COD.

*Note: this is only possible if the angles AOB, BOC, and COD sum to less than 360.

arghbleargh
  • 3,090
  • 21
  • 13