I would use this instead:
let theta1 = if(v5 gt 0 and v6 gt 0) then Q1 ELSE 0
let theta2 = if(v5 lt 0 and v6 gt 0) then Q2 ELSE 0
let theta3 = if(v5 lt 0 and v6 lt 0) then Q3 ELSE 0
let theta4 = if(v5 gt 0 and v6 lt 0) then Q4 ELSE 0
let theta = theta1 + theta2 + theta3 + theta4