How to find 3 points in a sphere?
5 views (last 30 days)
Show older comments
I want to find 3 points on a sphere whose radius and centre is known. The points should form a circle on the sphere's surface. I am using peter corke robotics toolbox
4 Comments
Answers (1)
Adam Danz
on 4 May 2021
The question is: how to get any 3 points along a great circle on a sphere with known radius and center
Here's how I think of the problem.
Assume unit sphere with radius 1 centered at (0,0,0) and a great circle laying on the xy plane. The point to the far left, upward, and far right sections of the sphere are
xyzn = [-1 0 0; % left
0 1 0; % upper
1 0 0]; % right
Now all you have to do is scale it and shift it to the sphere's center.
r = 12; %radius
cnt = [-10,8,20]; % center points (x,y,z)
xyz = xyzn.*r + cnt
xyz are 3 coordinates (row-wise) that lay on a great circle that lies on the xy plane passing through the center of the sphere.
Now let's plot it,
[sx,sy,sz] = sphere(20);
sx = sx*r+cnt(1);
sy = sy*r+cnt(2);
sz = sz*r+cnt(3);
mesh(sx,sy,sz,'LineWidth',2,'FaceAlpha',.6)
axis equal
hold on
plot3(xyz(:,1),xyz(:,2),xyz(:,3), 'k*', 'MarkerSize', 12, 'LineWidth',2)
xlabel('x'); ylabel('y'); zlabel('z')
view([-187, 23])
See Also
Categories
Find more on Robotics 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!