Hello all,
I am trying to make a unit vector subroutine for two near points. Given the two points a1, a2 (two triplets of number) I have to define the e=(a2-a1)/distance(a1,a2) {note that a2-a1 is in vector notation}. My problem arises when I have to evaluate the above as a1 tends to a2 and more particular when lets say one has a1=(1,2,1000.00001) and a2=(1,2,1000). Then I get a NaN vector as a result. I am using single precision and I would prefer to keep it that way. Could you please propose a solution so that the computer difference result 1000.00001-1000 is actualy a 0.00001 and not a zero.
Thanks
I am trying to make a unit vector subroutine for two near points. Given the two points a1, a2 (two triplets of number) I have to define the e=(a2-a1)/distance(a1,a2) {note that a2-a1 is in vector notation}. My problem arises when I have to evaluate the above as a1 tends to a2 and more particular when lets say one has a1=(1,2,1000.00001) and a2=(1,2,1000). Then I get a NaN vector as a result. I am using single precision and I would prefer to keep it that way. Could you please propose a solution so that the computer difference result 1000.00001-1000 is actualy a 0.00001 and not a zero.
Thanks