How can I create random Co-ordinate shifts (x,y,z) that add to a displacement of 1?

1 回表示 (過去 30 日間)
I have a set of co-ordiantes with x, y and z values. I'm trying to shift the co-ordiantes randomly to produce an overall shift of 1 (mm).
I know that if i'm shifting x y and z by random amounts of a b and c respectively, then:
sqrt(a^2 + b^2 + c^2) = 1
How can I randomly produce a vector (a, b, c) that satisfies the above equation?
Thanks!!

採用された回答

Matt J
Matt J 2020 年 3 月 30 日
[a,b,c]=sph2cart(2*pi*rand,pi*rand,1);

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by