I'm trying to solve a system of vector equations, but I have no idea how to do it. The following is a basic example of what I'm trying to solve:
$p = a*x + b*y$
$x = (p - y).normalize() + z$
where p, x, y, and z are 3D vectors.
I want to be able to solve this without making it a system of six equations by writing out how to evaluate the normalize function. I'm fine with solving three pairs of a system of two equations (one for each component of the vector) as long as I can solve the system of two equations once for one component and then input the corresponding values for the other two components.
My Original Problem
I want to take the formula for the force of a spring ($F_k = -kx$) and combine it wither Newton's second law ($F = ma$) and the kinematic formula ($p_{new} = p_{old} + v_{old} * t + \frac{1}{2} at^2$) to get a formula for the positions for two masses connected by a spring after a certain amount of time given their start positions and velocities.
$p = p_o + v_o * t + \frac{at^2}{2}$ (kinematic formula for the first end of the spring)
$q = q_o + w_o * t + \frac{a_2t^2}{2}$ (kinematic formula for the second end of the spring)
The force on both ends of the springs are equal opposites, so
$a = F_k / m$ where m is the mass of the first end
$a_2 = - F_k / n$ where n is the mass of the second end
Then you can replace $a$ and $a_2$ with their values in the first two equations:
$p = p_o + v_o * t + \frac{F_kt^2}{2m}$
$q = q_o + w_o * t - \frac{F_kt^2}{2n}$
Using Hooke's law, we can calculate the force
$F_k = -kx$
$p = p_o + v_o * t - \frac{kxt^2}{2m}$
$q = q_o + w_o * t + \frac{kx_2t^2}{2n}$
$x$ is the distance vector between the mass and the equilibrium of the spring. For example, if the spring at rest has a length of 10, then $x$ would be the distance vector between the end of the spring and 10 length units from the other end. In other words, $x$ is the distance between the ends of the spring minus the normal length of the spring (10)
$x = (p - q) - l$
However, $(p - q)$ is a vector, and $l$ is a scalar. The direction of $l$ should be the same as $(p - q)$. Therefore, the equation should be
$x = (p - q) - (p - q).normalize() * l$
Actually, this is the $x$ for the first end of the spring (since $p - q$ points toward the second end). However, the $x$ for the other end will just be $-x_1$
So we get
Final System of Equations
$p = p_o + v_o * t - \frac{kxt^2}{2m}$
$q = q_o + w_o * t - \frac{kxt^2}{2n}$ I replaced $x_2$ with $-x$
$x = (p - 1) - (p - q).normalize() * l$
(PS. Please tell me if I made any errors forming this. I seem to come up with something slightly different each time. So I may have made a mistake)