'Moving points of a line based on collision
I have a line colliding with a sphere:

The grey spheres are the endpoints of the line.
The white sphere is colliding with the line.
The blue sphere is the point of collision.
What I want to do is essentially move the blue sphere (the point of collision) to the edge of the white sphere by moving the grey spheres (the line endpoints).
But, I want the grey spheres moved based on how close the colliding white sphere is.
e.g. in the image above, the white sphere is colliding roughly 80% to the right on the line. So the grey sphere on the left should have to perform 80% of the movement, with the left sphere doing 20%, resulting in the diagonal movement (shown below)
While a more central collision would result in equal movement from both:

Any advice on the maths required here?
What I have available in my equation is: The collision position The endpoint positions of the line The position and radius of the white sphere
I'd like to use this information to move the two endpoint positions.
Solution 1:[1]
So.. not as hard as I thought it would be:
Vector3 d = (Vector3)lastCollisionPoint - sc;
float dlen = d.magnitude;
var movement = (sc + d * (r / dlen)) - (Vector3)lastCollisionPoint;
t2.transform.position += Vector3.Lerp(Vector3.zero, movement, lerp);
t1.transform.position += Vector3.Lerp(Vector3.zero, movement, 1f - lerp);
sc = sphere centre
lastCollisonPoint = the blue sphere collision point
t1 & t2 = the two points of the line
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

