Creating a rectangular patch using random numbers
Show older comments
Hi I am currently producing four random points in a 3D space. With these points I would like to create a rectangular patch which i can then use to find the vectors between them, then the normal and finally the plane equation. However my problem with this is that I need the patch to be a quadrilateral with parallel lines. When using three points it is fine as all three points are within the same plane however when using four points. One of my points is always off. How can I fix this.
An example of what I mean is provided below.
Accepted Answer
More Answers (1)
chicken vector
on 27 Apr 2023
Edited: chicken vector
on 27 Apr 2023
You can't really fix this.
A plane is univoquely defined by 3 points in space, so, most-probably, a fourth point won't lie on that plane and no bi-dimensional figure can match your requirements.
If you really want to pull-off some graphics you can plot every possible triangular patch as follows:
nPoints = 4;
dims = 3;
patchColor = [.8 .8 .8];
points = rand(dims,nPoints);
polyData = struct;
figure;
hold on;
for p = 1 : nPoints
scatter3(points(1,1),points(2,1),points(3,1),50,'k','filled');
polyData(p).patch = patch(points(1,1:3),points(2,1:3),points(3,1:3),patchColor,'FaceAlpha',0.3);
points = circshift(points,1,2);
end
hold off;
view([1,1,1])
polyData(1).patch
This way you can access patch properties.
Notice that if you are looking ofr the vector connecting two points, you can just do the difference.
point1 = [3 4]';
point2 = [10 0]';
vector = point2 - point1
versor = vector/norm(vector)
Categories
Find more on Surfaces, Volumes, and Polygons 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!
