Scaling 4D vector to specific bounds

3 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by