Solving for 2 parametric equations
Show older comments
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 Comments
Torsten
on 9 Apr 2015
You will have to tell which variable to solve for.
I guess that
solve(x^2+(z+1)^2==x^2+(z)^2,z)
will work.
Best wishes
Torsten.
luc
on 9 Apr 2015
Torsten
on 9 Apr 2015
At least one problem is that a pair (theta,s) - applied to both surfaces - do not yield the same point in 3d-space.
I think this is the minimum requirement to make solve work for your problem.
Further: What do you expect as output from solve ? A parametrized 1d-curve ?
Some curves are that complicated that they can only be represented as the intersection of two surfaces - they don't have a representation on their own.
Best wishes
Torsten.
luc
on 9 Apr 2015
Torsten
on 9 Apr 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.
Answers (0)
Categories
Find more on Mathematics in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!