How to solve parametric system of vector equations?

4 次查看(过去 30 天)
I have two parameters: P1 and P2, they are vectors. I am looking for a C vector and r scalar.
I have constraints: (P1-C)^2 == (P2-C)^2 == r^2 ; (C-(P1+P2)/2)*(P1-P2) == 0 ; 1+r^2 == C^2
Now I have tried creating symbolic variables, such as a, b and then P1 = (a,b). But somehow the dot product of two vectors becomes some complex vector.
So the question is, can I solve a system of equations such as this, using vectors?
  1 个评论
Christopher Creutzig
If you do not say differently, symbolic variables are complex (and scalar). The dot product therefore follows the rules in the complex plane. Please try syms a b real, and if you still run into problems, please post a minimal, but complete code snippet, i.e., something others can copy and run.

请先登录,再进行评论。

采纳的回答

David Goodmanson
David Goodmanson 2020-3-22
编辑:David Goodmanson 2020-3-22
Hi Daniel,
interesting problem. does this correspond to a particular physical situation?
% P1 --> a, P2 --> b
% solution is for c^2 = r^2 + z^2
a = 2*rand(3,1)-1;
b = 2*rand(3,1)-1;
z = 1; % specific case
p = (a+b)/2;
q = (b-a)/2;
u = cross(p,q); % perpendicular to plane defined by a and b
w = cross(u,q);
w = w/norm(w); % unit vector in ab plane, perpendicular to (b-a)
lambda = (dot(q,q)+z^2-dot(p,p))/(2*dot(p,w));
c = p+lambda*w;
r = sqrt(dot(q,q)+lambda^2);
% checks, should be small
dot(c-a,c-a) - r^2
dot(c-b,c-b) - r^2
dot(c -((a+b)/2),b-a)
dot(c,c) - (r^2+z^2)
  1 个评论
Dániel Széplaki
Dániel Széplaki 2020-3-22
编辑:Dániel Széplaki 2020-3-22
It corresponds to a geometric problem. You are given two points inside a unit circle, and you have to find a another circle, that fits on those points, and is perpendicular to the first circle.
I see how your answer works now. Very elegant, thank you!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Assumptions 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by