MATLAB Answers

Show intersection of two spheres

25 views (last 30 days)
ercan duzgun
ercan duzgun on 6 Jan 2021
Edited: Adam Danz on 6 Jan 2021
How can I show the intersections of two spheres on MATLAB plot?
My code is this:
close all;clear all;clc;
pA1=[-2.9,-0.9,0]';
pA2=[-1.2,3.0,0]';
pB1=[1.3,-2.3,0]';
pB2=[-1.2,-3.7,0]';
pC1=[2.5,4.1,0]';
pC2=[3.2,1.0,0]';
patch([pA1(1),pA2(1),pC1(1),pC2(1),pB1(1),pB2(1)],[pA1(2),pA2(2),pC1(2),pC2(2),pB1(2),pB2(2)],0)
grid on; axis equal;hold on;
text(pA1(1),pA1(2),'A1');text(pA2(1),pA2(2),'A2')
text(pB1(1),pB1(2),'B1');text(pB2(1),pB2(2),'B2')
text(pC1(1),pC1(2),'C1');text(pC2(1),pC2(2),'C2')
L1=5.0;L2=4.5;L3=5.0;L4=5.5;L5=5.5;L6=5.7;
%kure ciziyor
[x y z] = sphere(128);x=L1*x;y=L1*y;z=L1*z;
h = surfl(x+pA1(1), y+pA1(2), z+pA1(3));
set(h, 'FaceAlpha', 0.1)
shading interp
[x y z] = sphere(128);x=L2*x;y=L2*y;z=L2*z;
h = surfl(x+pA2(1), y+pA2(2), z+pA2(3));
set(h, 'FaceAlpha', 0.5)
shading interp
patch([pA1(1),pA2(1),pC1(1),pC2(1),pB1(1),pB2(1)],[pA1(2),pA2(2),pC1(2),pC2(2),pB1(2),pB2(2)],0)
  1 Comment
Adam Danz
Adam Danz on 6 Jan 2021
> How can I show the intersections of two spheres on MATLAB plot?
This has been addressed in the forum several times:

Sign in to comment.

Answers (0)

Tags

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!