MATLAB Answers

Solving for 2 parametric equations

19 views (last 30 days)
luc
luc on 7 Apr 2015
Commented: Torsten on 9 Apr 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 Comments

Show 3 older comments
Torsten
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
luc on 9 Apr 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 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.

Sign in to comment.

Answers (0)


Translated by