How can I draw a plane between 2 points ?
Show older comments
Hi, I am trying to draw a plane between 2 points. I am not sure what is a good way to do it. My idea is that I have 3 points out of which 2 points represent a robot (as a point) and there is a common point between these 2 points. I am considering a stationary case and the robots cannot move more than a certain distnace from the common point, hence the maximum distance the robot can move is a circle around the common point. Let's assume all 3 points are stationary.
Let's say I have P0(common point), P1 (1st robot point), P2 (2nd robot point). I always want to compute the angle between P1 (Robot 1) and P2 (Robot 2). Hence, I started drawing a plane for each robot with respect to the common point and I am trying to find the angle between these planes. I tried using affine fit to make the planes (I am not sure whether this is the right choice) and I am not sure what is a good way to visualise this plane.
I have attached my code below, this is just for plane visualisation. This is not working as surf function is unable to find a conection, from previous issues raised by others here example this one - how to use surf function? - MATLAB Answers - MATLAB Central (mathworks.com) . I understand that Surf function is not a good choice for doing this. I would like to know other ways of doing this in Matlab
p_0 = [1.25, 1.0, 1.0];
p_1 = [1.0, 1.0, 1.0];
plane_1_points = [p_1; p_0];
figure;
XYZ_1 = plane_1_points;
plot3(XYZ_1(:,1),XYZ_1(:,2),XYZ_1(:,3),'r.');
hold on
%compute the normal to the plane and a point that belongs to the plane
[n_1,~,p_1] = affine_fit(XYZ_1);
%plot the two points p_1 and p_2
plot3(p_1(1),p_1(2),p_1(3),'ro','markersize',15,'markerfacecolor','red');
%plot the normal vector
quiver3(p_1(1),p_1(2),p_1(3),n_1(1)/3,n_1(2)/3,n_1(3)/3,'r','linewidth',2)
%plot the two adjusted planes
%[X,Y] = meshgrid(linspace(0,1,N));
X = reshape(XYZ_1(:,1), [2,1]);
Y = reshape(XYZ_1(:,2), [2,1]);
%first plane
surf(X,Y, - (n_1(1)/n_1(3)*X+n_1(2)/n_1(3)*Y-dot(n_1,p_1)/n_1(3)),'facecolor','red','facealpha',0.5);
Accepted Answer
More Answers (0)
Categories
Find more on Robotics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!