in reply to about the application of arrow operator

Assuming that you have an extraneous '}' in that line, spacing and parentheses will do wonders for readability:
 return ($a->X * $b->X) + ($a->Y * $b->Y) + ($a->Z * $b->Z);