   Make vector inverse proportional
  Hello I nead some help whit linear algebra. I want to make a vector inverse proportional. A long vector will become smal and vice versa but the direction has to be the same. Is this the best way to go:NewVector = Oldvector * 1/length(OldVector)or is there som smart matrix I can use?Thank you for your time:)   
  There's not really anything faster that you can do here unless you are willing to settle for a gross approximation.  However, its very unlikely that the speed of this calculation will have any noticeable effect on the performance of your application, unless you are doing it many, many, many times per frame.   ;Quote:Original post by XmonHello I nead some help whit linear algebra. I want to make a vector inverse proportional. A long vector will become smal and vice versa but the direction has to be the same. Is this the best way to go:NewVector = Oldvector * 1/length(OldVector)this will infact make all vectors of unit length. if you want a vector of length 2 to become 1/2 and 1/2 to become 2, youd need this:NewVector = Oldvector * 1/length(OldVector)^2saves a squareroot aswell.   ;Quote:Original post by EelcoQuote:Original post by XmonHello I nead some help whit linear algebra. I want to make a vector inverse proportional. A long vector will become smal and vice versa but the direction has to be the same. Is this the best way to go:NewVector = Oldvector * 1/length(OldVector)this will infact make all vectors of unit length. if you want a vector of length 2 to become 1/2 and 1/2 to become 2, youd need this:NewVector = Oldvector * 1/length(OldVector)^2saves a squareroot aswell.Yeah your're right, did'nt saw that first.;Quote:Original post by XmonHello I nead some help whit linear algebra. I want to make a vector inverse proportional. A long vector will become smal and vice versa but the direction has to be the same. Is this the best way to go:NewVector = Oldvector * 1/length(OldVector)or is there som smart matrix I can use?Thank you for your time:)I have a geometrical solution.  Doubt it will result in a matrix solution, but it is worth a try.we want y = 1/xwell,x:1 as 1:yTake (x+1,0).  Find the line "L" through (x+1,0) and (1,1).Find the intercept of "L" and the y-axis, (0, y_0).Define y = y_0-1.Then y = 1/x.I doubt that this can be used by matrix math to find y effectively.  And probably simply calculating:result = (x,y,z) / (x^2 + y^2 + z^2)is faster in any case.Another question: do you actually require |result| = 1/|input|?If you just want to switch the order of the length of the vectors, and you know the max length, then|result| = max - |input|will switch the length of the vectors.