To determine Miller Indices of crystal lattice planes I would need a stable algorithm which determines the smallest set of integer coordinates of a vector which has same direction as a given vector (e.g. through the unit vector). Let's try out an example: When I have a simple integer vector given as $v=\{1.,2.,3.\}$ and I calculate the unit vector through
v={1.,2.,3.}
e=Normalize[v]
I get
{0.267261, 0.534522, 0.801784}
for e. Using this vector now to reconstruct the original vector by trying to find the smallest integer coordinates e.g. through
Function[x,If[And@@(IntegerQ[#]&)/@x,x,(#/GCD@@#&)@Rationalize[x, 1/10^10]]]]
@Normalize[{1.,2.,3.}]
is just working for vector coordinates which are greater than one (e.g. $\{1.5,2.,3\}$ is yielding the correct result $\{3,4,6\}$) but not for normalized vector coordinates. The above example yields a vector with very high integer coordinates.
I'm sure there is a simple solution to this but it seems that I'm a blockhead on this...
Rationalize
. $\endgroup$