I had this function in my old codes:
Code:
function Angle3D(x1,y1,z1,x2,y2,z2: double): double;
var a: double;
begin
  a:=(x1*x2+y1*y2+z1*z2) /
     ( sqrt(x1*x1+y1*y1+z1*z1) * sqrt(x2*x2+y2*y2+z2*z2) );
  //if a>1 then a:=1 else if a<-1 then a:=-1;
  result:=abs(arccos(a));
end;
It looks slightly unfinished, and i was surprised i didn't clean that up for nxPascal yet. Atleast what i understand, result should always be >= 0. Sqrt insides seem fine, they are always on positive side or 0 so don't need any temp variables either. Not sure what i was thinking with the if-clause.