Skip to content

Commit

Permalink
Elimination of unnecessary implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
makotok committed Oct 16, 2012
1 parent 3070d6d commit 2198afd
Showing 1 changed file with 0 additions and 99 deletions.
99 changes: 0 additions & 99 deletions projects/hanappe/src/hp/lang/class.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,103 +56,4 @@ function M:new(...)
return obj
end



--------------------------------------------------------------------------------
-- modules that extend functionality of the math.
-- @class table
-- @name math
--------------------------------------------------------------------------------
local math = setmetatable({}, {__index = _G.math})

--------------------------------------------------------------------------------
-- Calculate the average of the values of the argument.
-- @param ... The number of variable-length argument
-- @return average
--------------------------------------------------------------------------------
function math.average(...)
local total = 0
local array = {...}
for i, v in ipairs(array) do
total = total + v
end
return total / #array
end

--------------------------------------------------------------------------------
-- Calculate the total values of the argument
-- @param ... The number of variable-length argument
-- @return total
--------------------------------------------------------------------------------
function math.sum(...)
local total = 0
local array = {...}
for i, v in ipairs(array) do
total = total + v
end
return total
end

--------------------------------------------------------------------------------
-- TODO
--------------------------------------------------------------------------------
function math.distance( x0, y0, x1, y1 )
if not x1 then x1 = 0 end
if not y1 then y1 = 0 end

local dX = x1 - x0
local dY = y1 - y0
local dist = math.sqrt((dX * dX) + (dY * dY))
return dist
end

--------------------------------------------------------------------------------
-- TODO
--------------------------------------------------------------------------------
function math.normalize( x, y )
local d = math.distance( x, y )
return x/d, y/d
end

--------------------------------------------------------------------------------
-- TODO
--------------------------------------------------------------------------------
function math.getAngle( a, b, c )
local result
if c then
local ab, bc = { }, { }

ab.x = b.x - a.x;
ab.y = b.y - a.y;

bc.x = b.x - c.x;
bc.y = b.y - c.y;

local angleAB = math.atan2( ab.y, ab.x )
local angleBC = math.atan2( bc.y, bc.x )
result = angleAB - angleBC
else
local ab = { }

ab.x = b.x - a.x;
ab.y = b.y - a.y;
result = math.deg( math.atan2( ab.y, ab.x ) )

end
return result
end

--------------------------------------------------------------------------------
-- TODO
--------------------------------------------------------------------------------
function math.clamp( v, min, max )
if v < min then
v = min
elseif v > max then
v = max
end
return v
end


return M

0 comments on commit 2198afd

Please sign in to comment.