calculate theta