Solving 3D Vector equations

I need to solve 3D vector equations having known and unknown position vectors. Equations have dot products, cross products, modulus and a combination of them.
Here's a one set of equations.
(l-o) x (q-o) . (c-o) = 0
o-q * [ (l-q).(q-c) ] = l-q * [ (o-q).(q-c) ]
Here, l,o,q,c are position vectors and l,o are known.
Thank you.

 Respuesta aceptada

Andrew Newell
Andrew Newell el 30 de Mayo de 2011

1 voto

Interesting equations. The first says that the points l,o,q,c are coplanar, but I'm not sure what the second means.
You can solve a system like this using fsolve. Since fsolve requires a function f(x) with vector x, you first need to combine your unknowns in a vector, e.g., x = [q; c]. Note: I am assuming your vectors are all column vectors.
Create a function
function y = myfun(x,l,o)
q = x(1:3); c = x(4:6);
y = [dot(cross(l-o,q-o),c-o)
abs(o-q)*dot(l-q,q-c) - abs(l-q)*dot(o-q,q-c)];
To solve your system of equations, you need to find an x that makes y equal to zero. Save this function in a file.
In a separate file, provide the values for l and o and create an anonymous function:
f = @(x) myfun(x,l,o);
Then make an initial guess for your solution, e.g., q0 and c0. Finally, solve:
x0 = [q0; c0];
xsol = fsolve(f,x0);

Más respuestas (1)

Jan
Jan el 28 de Mayo de 2011

2 votos

Yes. If the equation can be solved, it can be solved in Matlab also.
If you want a more detailed answer, post the equation.

1 comentario

Chirath Dharshana
Chirath Dharshana el 29 de Mayo de 2011
Here's a one set of equations.
(l-o) x (q-o) . (c-o) = 0
|o-q| * [ (l-q).(q-c) ] = |l-q| * [ (o-q).(q-c) ]
Here, l,o,q,c are position vectors and l,o are known.
Thanks in advance.

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by