Subject: | Addition of scalar doesn't work |
The multiply sub understands how to multiply by a scalar. The plus and minus subs do not. When given a scalar they die with something like: "Can't use string ("7") as an ARRAY ref ...".
A simple fix is, in the plus and minus functions, to add:
if (!ref $a) { $a = Math::Quaternion->new($a); }
if (!ref $b) { $b = Math::Quaternion->new($b); }
Or make the args ($a,0,0,0) and ($b,0,0,0) if that is more appealing.