Finding a line segment from two edges of a cube that intersects an arbitrary point within the cube volume

To give some context for where this problem is originating, I am an artist whose work is primarily focused on illustrating concepts in math and physics through sculptural media. I am working on creating a series of sculptures that depict different constellations with their stars as they are actually arranged in space in 3D (well, almost, my z coordinates are the distances from earth in light years scaled down to fit within the confines of the cube, so not 100% true to life, but close enough for art reasons). From most angles, the sculptures just look like beads strung at random from wires anchored to a cube frame, but when viewed head-on from the front, they form the shape of the constellation as it appears here on earth. Here's an early version of the Big Dipper I finished last summer to give you an idea of what these will look like. big dipper

So far, I've been brute forcing the x and y coordinates for the stars from pictures of constellations stuck in Adobe Illustrator, I grab my z coordinates from Wikipedia, and once I've scaled and centered my (x,y,z)'s for all of a constellation's stars in a spreadsheet, I plot them as points in Geogebra with a cube frame drawn around them, each dimension of the cube ranging over -100 to 100 with the origin in the center. I'll then resave that file under each individual star's name, turn off all the other stars, and then draw a line segment connecting different cube edges and then slide its end points along the edge until the line intersects the center of the star. These lines are what will ultimately become the wires connecting the star to the frame edges in the final sculpture, and I generally find 2-5 possible solutions for each star. Here's an example of my found brute-force'd solutions for a star in Aquarius to illustrate (the red point is my marker to keep myself oriented): sadachiba

What I want to know is, how can I SOLVE for these lines, either algebraically or numerically? While the process can be pretty meditative and relaxing sometimes, I am getting pretty tired of brute forcing all these solutions by hand in Geogebra, especially since it is difficult to get the line segment precisely through the plotted point by scooting around its end points (not to mention this just propogates my errors in the final, physical form, so no bueno), and because I know that I'm probably missing some of the possible solutions sometimes (and I want all the solutions for each star so I can have some wire position options for aesthetic reasons and to make sure no wires pass in front of other stars when viewed head-on). I had talked out the problem with some of my most trusted physics classmates and one of my physics professors last summer, but if memory serves, none of us ever came up with a solution, or in the very least I never found anything that worked. (Which is weird, because this seemed like it should be pretty easy to me, and honestly it still does.) I think I had tried some failed way involving determinants as one of my attempts, but I don't remember what it was and Lord knows what sketchbook that was in. At no point was there an attempt by any party to try and solve the problem numerically, but I've taken numerical analysis since then, so that option is now comfortably on the table for me if need be.

So, what I'm working with here, essentially:

Seven knowns, and two unknowns.

1. The known (x,y,z) coordinates for the star

2. Two known coordinates (with values of either -100 or 100, depending on which cube edge) and one unknown coordinate (the position along the length of that cube edge) for the first wire anchor

3. Two known coordinates and one unknown coordinate for the second wire anchor on another cube edge

What I want: a straightforward formula (or algorithm) for computing those two unknowns. A comp sci friend of mine has volunteered to write a script to automate this whole line-finding process for me, and I imagine that it will probably check all possible combinations of cube edges for solutions for what it's worth.

Anyway, thank you in advance! I'm really looking forward to having this mystery solved.

• With an edge and a point you can identify a plane. You can then find the intersection of this plane, if any, with the other edge. You will need a different equation for each edge of the cube I fear.
– N74
Apr 12 '17 at 20:12

Instead of giving a formula, I would suggest you to use GeoGebra to find what you want without approximations.

1) Start with your cube and point $P$ inside it; choose one of the edges ($GH$ in the diagram below).

2) Draw plane $PGH$ (tool "Plane through three points"): that plane will intersect other two edges at points $I$ and $J$, which you can draw (tool "Point" or "Intersection").

3) Draw lines $IP$ and $JP$, and check if they intersect edge $GH$: in that case you can draw the intersection point and find a solution. In the diagram, only line $JP$ intersects $GH$ at $K$.

4) Repeat for the other edges.

Aretino's Geogebra solution may be your most practical option, but for completeness, let me also give you the algebraic solution.

For concreteness, suppose that one of your edges is the edge with $x = y = -100$ (and variable $z$), and the other edge is the edge with $y = z = +100$ (and variable $x$). We will say that the star has coordinates $(x^*, y^*, z^*)$, if you'll excuse the notational pun.

If $(x^*, y^*, z^*)$ lies on the line segment from $(-100,-100,z)$ to $(x, 100, 100)$, then it is the weighted average $$(x^*, y^*, z^*) = \lambda \cdot (-100,-100,z) + (1-\lambda) \cdot (x, 100, 100).$$ We first pick out the coordinate (in this case, the $y$-coordinate) where both edges are have a fixed value. We must have $$y^* = \lambda \cdot -100 + (1-\lambda) \cdot 100,$$, giving us $\lambda = \frac{100 - y^*}{200}$ and $1-\lambda = \frac{100 + y^*}{200}$

Now we can figure out what $x$ and $z$ must be. In the first coordinate, we have $$x^* = \frac{100 - y^*}{200} \cdot (-100) + \frac{100 + y^*}{200} \cdot x$$ which has only one unknown, $x$, that we can solve for. In the third coordinate, we have $$z^* = \frac{100 - y^*}{200} \cdot z + \frac{100 + y^*}{200} \cdot 100$$ which has only one unknown, $z$, that we can solve for.

Here, the solutions are $x = 200 \cdot \frac{x^* + 100}{y^* + 100} - 100$ and $z = 100 - 200 \cdot \frac{z^*-100}{y^*-100}$, but this will vary depending on which edges of the cube we consider. (Each pair of edges only lets us cover about $\frac16$ of the cube's volume.)