Angle difference between two bearings: Difference between revisions

Content added Content deleted
(→‎{{header|Julia}}: added Lua section afterward)
(→‎{{header|Lua}}: added brief explanation above sample code.)
Line 899: Line 899:


=={{header|Lua}}==
=={{header|Lua}}==

Each bearing will be stored in an object that inherits methods to accomplish all parts of the task: accept a new number of degrees, automatically adjusting to the range [-180, 180]; construct new bearing objects; subtract another bearing from itself and return the difference; construct a list of new bearing objects given a list of arbitrary degree sizes; and format the number of degrees into a modest human-readable format. Bearings will be zero-initialized by default if no degree size is provided.

<lang lua>bearing = {degrees = 0} -- prototype object
<lang lua>bearing = {degrees = 0} -- prototype object