Alan B
Alan B

Reputation: 4288

Calculating reflex and obtuse angles

Given two lines of common origin point, whose rotational angles I have in degrees, what's the best way in Lua to calculate the reflex and obtuse angles involved?

Upvotes: 0

Views: 266

Answers (1)

LHMathies
LHMathies

Reputation: 2454

Assuming that you want the reflex angle that complements the obtuse angle, and don't worry about getting values of 90 or 180 degrees for the obtuse value:

function obtuse_reflex(a, b)
  local diff = (a - b) % 180
  if diff < 90 then diff = 180 - diff end
  return diff, 360 - diff
end

Upvotes: 2

Related Questions