I have two points p1 and p2, and I want to get the parametric equation of a linear function that passes through those, but ranging from one point to another.
For example, if I have 2 points {0,0} and {1,1/2}, the equation would be {t,t/2}.
The goal of having a parametric equation is to have the function defined even when the slope is $\infty$.
I tried this (here the angle[] function is Atan2, is basically ArcTan but ranging from 0-2π):
Piecewise[
{
{{t, Last@p1 + Tan@angle[p1, p2] (t - First@p1)},
Min[First@p1, First@p2] <= t && t <= Max[First@p1, First@p2]},
{{First@p1, t}, First@p1 == First@p2}
},
Indeterminate
]
But when a point is on top of the other the function is a vertical line, ranging from $-\infty$ to $\infty$; I would only want the function to be defined from Last@p1 to Last@p2.
In other words, I want a Graphics' Line, but using parametric equations.
Something like this:

p1 + t (p2 - p1)? – Kuba Apr 22 '14 at 10:07Piecewisefor this.) – C. E. Apr 22 '14 at 10:14line[t_] := p1 + t (p2 - p1) /; 0 <= t <= 1but your question is still unclear. Please refer to my previous question. And focus on what you are writing. – Kuba Apr 22 '14 at 10:21Linein your plot? You can insertGraphicsinto a plot withPrologor 'Epilog`. – m_goldberg Apr 22 '14 at 10:22Solve/NMinimizefort1, t2with restrictions. Also, take a look at Line intersection algorithm – Kuba Apr 22 '14 at 10:35