You do not need to calculate previous transaction hash, because it is already known. To spend the previous output you just have to know
- tx hash
- output index in this tx
- output value
- output script
plus you should choose
- fee
- new address
then create some byte data and sign it with appropriate private key
Good manual you can find here: How to redeem a basic Tx?How to redeem a basic Tx?