A section of Laboratory Project: Putting 3D in Perspective: the full video with all its notes is on that page.
Notes: Putting 3D in Perspective Question 4: Projecting a 3D Rectangle to 2D
Written notes — from Laboratory Project: Putting 3D in Perspective.
Question 4
A rectangle with vertices (621, -147, 206), (563, 31, 242), (657, -111, 86), and (599, 67, 122) is added to the scene.
The line L intersects this rectangle.
To make the rectangle appear opaque [not transparent], a programmer can use hidden line rendering, which removes portions of objects that are behind other objects.
Identify the portion of L that should be removed.
Solution:
Let's graph out the rectangle inside GeoGebra as well as its projection onto the screen.
(621, -147, 206) projects to:
(0, -147/(1-621/1000) = -387.8628, 206/(1-621/1000) = 543.5356) = (0, -387.86, 543.54)
(563, 31, 242) projects to:
(0, 31/(1-563/1000) = 70.9382, 242/(1-563/1000) = 553.7757) = (0, 70.94, 553.78)
(657, -111, 86) projects to:
(0, -111/(1-657/1000) = -323.6152, 86/(1-657/1000) = 250.7289) = (0, -323.62, 250.73)
(599, 67, 122) projects to:
(0, 67/(1-599/1000) = 167.0823, 122/(1-599/1000) = 304.2394) = (0, 167.08, 304.24)


We are asked to remove the portion of the line behind the rectangle that is projected onto the screen.
To do this, we need to determine two points:
- The point at which the line intersects the rectangle.
- The point at which the projected line intersects the bottom boundary of the projected rectangle.
Point of Intersection of the Line and Rectangle
To determine the point of intersection of the line and rectangle, we first determine the equation of the plane that contains the rectangle.




Calculation check:
944 / 118 = 8
236 / 118 = 2 354 / 118 = 3621 * 8 - 147 * 2 + 206 * 3 = 5,292
Now we can plug in our parametric equations of the line into the equation of the plane for the rectangle to get the point where they intersect.

Calculation check:
8 * 630 + 2 * 390 + 3 * 162 = 6,306
5292 - (8230 - 2285 + 3*102) = 3716
3716/6306 = 0.5893
3716/2 = 1858 6306/2 = 3153
1858/3153 = 0.5893
Plugging in the value of t inside the parametric equations of the line we get:
x = 230 + 630 * 1858/3153 = 601.2464 y = -285 + 390 * 1858/3153 = -55.1808 z = 102 + 162 * 1858/3153 = 197.4634
And this point projects onto the screen at:
x' = 0 y' = -55.1808 / (1 - 601.2464/1000) = -138.3832 z' = 197.4634 / (1 - 601.2464/1000) = 495.2015
Graphing this out in GeoGebra, we have:


Point of Intersection of the Projected Line and Projected Rectangle
From the above image, the projected line intersects the bottom right portion of the projected rectangle.
Recall the vector equation of the projected line we calculated earlier:
r = <0, -71.43, 600> + t<0, -328.57, -514.29>
And recall the coordinates of the projected rectangle.
R1 = (0, -387.86, 543.54) R2 = (0, 70.94, 553.78) R3 = (0, -323.62, 250.73) R4 = (0, 167.08, 304.24)
Let's calculate the vector equation of the bottom right portion of the projected rectangle.

Actually, let's type this out to save time:
r = <0, -323.62, 250.73> + s<0-0, 167.08-(-323.62), 304.24-250.73>
= <0, -323.62, 250.73> + s<0, 490.7, 53.51>
If the lines intersect then we should be able to obtain values of the parameters t and s such that the coordinates equal for each line:
x = 0
y = -71.43 - 328.57t = -323.62 + 490.7s
--> (-71.43 + 323.62) - 328.57t = 490.7s
--> (252.19/490.7) - (328.57/490.7)t = s
--> 0.5139 - 0.6696t = s --> Equation 1
z = 600 - 514.29t = 250.73 + 53.51s
--> (600 - 250.73) - 514.29t = 53.51s
--> (349.27/53.51) - (514.29/53.51)t = s
--> 6.5272 - 9.6111t = s --> Equation 2
Subtracting the Equation 2 from Equation 1, we can thus solve for t:
(0.5139 - 6.5272) + (-0.6696 + 9.6111)t = 0
--> -6.0133 + 8.9415t = 0
--> t = 6.0133/8.9415 = 0.6725
Plugging this value of t into either Equation 1 or 2 and solving for s we get: s = 0.5139 - 0.6696*0.6725 = 0.0636 Plugging these values into the two equations of the projected lines we get:
Projected line:
x = 0 y = -71.43 - 328.570.6725 = -292.3933 z = 600 - 514.290.6725 = 254.14
Projected bottom right line of rectangle:
x' = 0 y' = -323.62 + 490.70.0636 = -292.4115 z' = 250.73 + 53.510.0636 = 254.1332
Calculation check:

Graphing it All Out in GeoGebra 3D Graphing Calculator
Graphing this out in GeoGebra, and hiding the line segment projected behind the screen, we have our final projected image:


Absolutely amazing stuff!!
- Watch on: YouTube · Telegram
- Full video and written notes: Laboratory Project: Putting 3D in Perspective
- Sections playlist: Laboratory Project: Putting 3D in Perspective (YouTube)
- More: Vectors and the Geometry of Space · mes.fm/math
Notes originally posted on the Hive blockchain →
