How to solve parametric system of vector equations?
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Dániel Széplaki
il 21 Mar 2020
Commentato: Christopher Creutzig
il 25 Mar 2020
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 Commento
Christopher Creutzig
il 25 Mar 2020
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.
Risposta accettata
David Goodmanson
il 22 Mar 2020
Modificato: David Goodmanson
il 22 Mar 2020
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 Commento
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Assumptions in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!