added scale matrix derivation