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

9 ビュー (過去 30 日間)
Shiv Karpoor
Shiv Karpoor 2022 年 1 月 25 日
コメント済み: Shiv Karpoor 2022 年 1 月 25 日
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

採用された回答

KSSV
KSSV 2022 年 1 月 25 日
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)
  1 件のコメント
Shiv Karpoor
Shiv Karpoor 2022 年 1 月 25 日
Thank you so much KSSV !! I really appreciate your help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by