4
$\begingroup$

For example if we define parametric line segment

curve1[t_, p1_, p2_] := t*p2 + (1 - t)*p1;

where p1 and p2 are 2D vectors, we can draw it easily

p1 = {0, 0}; p2 = {1, 2}; ParametricPlot[curve1[t, p1, p2], {t, 0, 1}]

enter image description here

But can't solve in general form

Clear[p1, p2]
Solve[curve1[t, p1, p2] == curve1[u, q1, q2], {t, u}]

because Mathematica treats p1, p2, q1 and q2 as scalars, and gives

$\left\{\left\{u\to -\frac{t (\text{p2}-\text{p1})}{\text{q1}-\text{q2}}-\frac{\text{p1}-\text{q1}}{\text{q1}-\text{q2}}\right\}\right\}$

Can I treat them as vectors and solve analytically?

$\endgroup$
3
  • $\begingroup$ @DanielHuber of course not, if p1, p2, q1 and q2 are all different, it doesn't true. $\endgroup$
    – Dims
    Commented Jan 13, 2022 at 10:38
  • $\begingroup$ Sorry I read it too fast. $\endgroup$ Commented Jan 13, 2022 at 10:51
  • 1
    $\begingroup$ This may be a starting point: Reduce[curve1[t, p1, p2] == curve1[u, q1, q2] && (p1 | p2 | q1 | q2) ∈ Vectors[2, Reals], {t, u}] $\endgroup$
    – qreus
    Commented Jan 13, 2022 at 10:54

2 Answers 2

5
$\begingroup$

You can use Vectors.

Solve[curve1[t, p1, p2] == curve1[u, q1, q2] && (p1 | p2 | q1 | q2) ∈ Vectors[2, Reals] && (t|u) ∈ Reals, {t, u}] //FullSimplify

output

$\endgroup$
3
$\begingroup$
Clear[p1, p2]
curve1[t_, p1_, p2_] := t*p2 + (1 - t)*p1;
{p1, p2, q1, q2} = {{p1x, p1y}, {p2x, p2y}, {q1x, q1y}, {q2x, q2y}};
Solve[curve1[t, p1, p2] == curve1[u, q1, q2], {t, u}]

enter image description here

$\endgroup$
2
  • $\begingroup$ It's cheating :) Can I just tell solver, that some variables are vectors? $\endgroup$
    – Dims
    Commented Jan 13, 2022 at 10:56
  • $\begingroup$ How do you know that it can be written without respect to the vector components? $\endgroup$ Commented Jan 13, 2022 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.