How to solve parametric system of vector equations?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Dániel Széplaki
el 21 de Mzo. de 2020
Comentada: Christopher Creutzig
el 25 de Mzo. de 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 comentario
Christopher Creutzig
el 25 de Mzo. de 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.
Respuesta aceptada
David Goodmanson
el 22 de Mzo. de 2020
Editada: David Goodmanson
el 22 de Mzo. de 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 comentario
Más respuestas (0)
Ver también
Categorías
Más información sobre Assumptions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!