How to generate random points in a 3d line, if two end points are known??

4 Ansichten (letzte 30 Tage)
Hello MATLAB Community,
I am working on a project and I am having a small problem, where I have to generate random points between two known points in 3D space.
for example : point A = [ 0, 0, 405] and point B = [ 4.5, -5.5, 480], I need to generate say 50 - 100 random points in-between point A & B.
Can anyone please help me with any suggestions.
Thank you in advance!!
I really appreciate your help.
Kind regards,
Shiv

Akzeptierte Antwort

KSSV
KSSV am 25 Jan. 2022
A = [ 0, 0, 405] ;
B = [ 4.5, -5.5, 480] ;
AB = B-A ; % vector
t = sort(rand(1,100)) ; % random points
% Parametric equation of line in 3D
P = A'+t.*AB' ;
% plot
figure
hold on
plot3(A(1),A(2),A(3),'*r')
plot3(B(1),B(2),B(3),'*r')
plot3(P(1,:),P(2,:),P(3,:),'.-b')
view(3)

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by