There are many ways to calculate the length of a vector, some are based on the idea that the length function can use powers other than 2 to do it's calculations

for 2:

sqrt( x^2 + y^2 + z^2 ... ) == ( x^2 + y^2 + z^2 ... ) ^ 1/2

this is the standard length.

for 1:

( x+y+z ... )

this is called the Manhatten distance.

for infinity:

( x^inf + y^inf + z^inf ... ) ^ 1/inf

this is the maximum value in the vector.

there is also the technique of quick length which is the sorted abs vector (where the largest value is first) calculated as the dot of { 1,1/2,1/4, ... } e.g.

{ 2,4,1 } -> 4,2,1 -> 5.25

This isn't a bad approximation in most uses, i think i remember someone saying that its about 6% out at worst but that sounds quite conservative to me.

## No comments:

Post a comment