Solving for 2 parametric equations

8 visualizaciones (últimos 30 días)
luc
luc el 7 de Abr. de 2015
Comentada: Torsten el 9 de Abr. de 2015
Hey everyone! I got a question: I'm trying to calculate where a sphere and a cone intersect. I've got 2 parametric functions describing a sphere and a cone, K and S. These are both functions of "s and t" which are the two vars describing each point.
(so S(s,t) and K(s,t) note that S is not equal to s)
What I want to do is solve for K==S. Any idea why matlab does not give me an answer?
The code is added below: it currently plots the 2 functions, if you remove the commented section u'll see the problem.
Thanks in advance!
syms t s theta r x0 y0 z0 c vx vy vz K(theta,s) S(theta,s) real
%%defining the constants
x0=1;
y0=1;
z0=1;
c=0.5;
vx=1;
vy=-2;
vz=3;
r=5;
P=[x0 y0 z0]';
A=[vx vy vz]';
x=A(:).'/norm(A); %normalise the input vector
yz=null(x).'; %find the null spaces of normalised A
xyz=[x;yz] %The rows of this matrix are the axes of a normalised
u=xyz(2,:)'
v=xyz(3,:)' %u and v are a ortogonal normal basis for normalised A
%t=(tan(theta+pi/2));
%K(t,s)=P+A*t+t*tan(C/2)*(u*cos(s)+v*sin(s))
K(theta,s)=P+x'*(tan(theta+pi/2))+(tan(theta+pi/2))*tan(c/2)*(u*cos(s)+v*sin(s))
%K described a cone with directional vector A, vertex(centre)=P and opening
%parameter=C
S(theta,s)=r*[sin(theta) 0 0;0 sin(theta) 0;0 0 cos(theta)]*[cos(s);sin(s);1]
%S described a sphere with centre @0,0,0 and radius r.
%I want to know the function that described the intersection of these 2
%objects. So for K=S.
%%solve(K==S) % does not work. Why?
%%plotting
KK=formula(K) %rewrite for indexing.
SS=formula(S)
%GG=formula(G)
figure
ezsurf(KK(1), KK(2), KK(3), [0,2*pi,0,pi])
hold on
spheresurf=ezsurf(SS(1), SS(2), SS(3), [0,2*pi,0,pi])
set(spheresurf,'facealpha',0)
set(spheresurf,'edgecolor',[.2 .4 .9])
%inters=ezsurf(GG(1),GG(2),GG(3),[0,2*pi,0,pi])
%set(inters,'edgecolor',[.6 .9 .2])
%%there are clearly 2 circle like figure where the cone and the sphere
%%intersect. Why doesn't the solve function work?
  6 comentarios
luc
luc el 9 de Abr. de 2015
Okay,
Thanks for the advice.
I think the output would be a semi-sphere in 3D. So a line in 3D.
If you look at this picture u can see that the outcome would indeed be something of that ilk.
I was thinking of rewriting my equations to match a cone with z vector, 0 origin and a sphere with a different centre to make it easier.
Any thoughts?
Torsten
Torsten el 9 de Abr. de 2015
Did you try to use "solve" if the result is 1d, 2d ... instead of 0d ?
I'd test it: Try to find the intersection of the sphere x^2+y^2+z^2=1 with the plane x+z=1.
And as I already said: Don't use a parametrization of your sphere/cone. Or a parametrization such that one pair (theta,s) - applied to both equations - yields the same point in 3d-space.
Best wishes
Torsten.

Iniciar sesión para comentar.

Respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by