x^2+y^2+z^2=r^2
where the r s the radius of the sphere.
How to plot this object in matlab? Here's my solution:
close all;
clc;
clear;
[x, y,z]=meshgrid(-3:0.1:3, -3:0.1:3,-3:0.1:3);
v1=x.^2+y.^2+z.^2; % create the 1st object
r1=2;% set radius
p1=patch(isosurface(x,y,z,v1,r1));
set(p1, 'FaceColor','r')
hold on
v2=(x-1).^2+(y-1).^2+(z-1).^2;% create the 2nd object
r2=3;
p2=patch(isosurface(x,y,z,v2,r2));
set(p2,'FaceColor','b')
view(3)% set to 3D view
x^2+y^2+z^2=r^2
(x+2-y^2)^2+y^2+z^2=6
(x+2-y^2+z^3)^2+y^2+z^2=6
You can get some latest computer tips, blogging tips and internet tips in the blog TechnTechie.
ReplyDelete