I've been trying to write a program that correctly projects 4D lines (4-space) and points upon a 2D screen, so I've first utilized parametric equations to try to clip any lines that might pass through (where p is the distance from (some axis) 0 to the clipping plane) z=p and w=p, then apply perspective transformations to the points and line points to be rendered if they are z>=p and w>=p. Am I going about this right, and if not then how should I go about doing this?
Please use fairly laymen's terms, I am familiar with parametric equations, rotation and transformation matrices, etc., but I'm not so great on the terminology or all of the specific mechanics and properties of matrix multiplication.
I have my attempt at an application of this running at https://editor.p5js.org/hpestock/sketches/Yfagz4Bz3, if it helps.
Here's an attempt. Let $a,b,b_1,b_2,p\in\mathbb{R}^4$ and $s,u,v\in\mathbb{R}$ be such that: $$L(s) := as+b$$ and $$P(u,v) := p+b_1u+b_2v$$ describe a line and a 2D plane respectively ($b_1$ and $b_2$ L.I. of course). Since we want to project the line onto the plane, assume for simplicity that $p:=0$.
Then what we want to do is find the vector projections onto the directions , $b_i$, that describe the plane: $$a_1(s) := proj_{b_1}(as+b) = \langle as+b,b_1\rangle \frac{b_1}{|b_1|^2}\text{ }\text{ and }\text{ }a_2(s):= proj_{b_2}(as+b) = \langle as+b,b_2 \rangle\frac{b_2}{|b_2|^2}$$ and add them for the total projection: $$\tilde{L}(s):= proj_{P(u,v)}\big(L(s)\big) = (a_1+a_2)(s).$$
I tried an example for clarity in $\mathbb{R}^3$ using $b:= (0,0,1)$, $a := (1,1,1)$, $b_1 := (1,0,0)$ and $b_2 := (0,1,0)$. The result I got was $\tilde{L(s)} = (1,1,0)s$. Which when graphed at least looks feasible.
As for perspective, that is another battle entirely IMO. I've tried graphing with Java in a JFrame and altering objects with buttons as to move them around etc. I wanted to say make them disappear when they are far enough away, and make them look like they were getting smaller as they moved towards a horizon point. Wasn't sure exactly how to do this, but I assumed linear scaling w.r.t. distance from the screen into the computer. Note that for lines which are infinite, scaling my not be apparent graphically. So I would pick an interval for $'s'$ at first...