Scaling 4D vector to specific bounds

2 ビュー (過去 30 日間)
Piotr Pawlowski
Piotr Pawlowski 2019 年 8 月 8 日
編集済み: Akhil Gopinath 2020 年 1 月 16 日
Hi everyone.
I have a rather uncommon problem. I'm trying to fit a vector (4D vector to be precise) to specific bounds, which I determined, but with preservation of direction. Let me explain:
e.g.
  1. generate 10 vectors, from range [0 5] for 1st coordinate, [0 9] 2nd, [0 4] third, [0 8] 4th. All coordinates are known
  2. scale vectors that have coordinates outside their bounds
  3. leave good vectors untouched
I was trying to figure it out on 2D plane. One conclusion is that I cannot just force outgoing coordinates to their maximum boundary values - it won't preserve direction. Such a method pinns those vecotrs all to the corner of a "boundary rectangle". I could figure out some conditional rules, but it is not what im trying to accomplish. My goal is to find a procedure, such that I can quickly apply to matrix of generated vectors. And since problem is 4D it is even harder to manage a solution. Any suggestions? Maybe dealing with norms?
Thanks in advance

回答 (1 件)

Akhil Gopinath
Akhil Gopinath 2020 年 1 月 16 日
編集済み: Akhil Gopinath 2020 年 1 月 16 日
Hi Piotr
you are thinking in the right direction by thinking of norm.
Maybe you can try to find the norm of the vector and transform them into unit vectors by diving with the calculated norm.
This will preserve the direction of the vectors.
You can then multiply with a scalar to resize the vector to the giving bound or add a scalar to shift the position but retaining the direction of the vectors.

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by