libs/lua-math-polygon: spaces after commas, rm unneded parentheses, simplify rectangle convert function
Signed-off-by: Jan-Tarek Butt <tarek@ring0.de>
This commit is contained in:
parent
07e14fa2f5
commit
68e2c63caf
|
@ -14,7 +14,7 @@ function M.cross_prod_test(x_a,y_a,x_b,y_b,x_c,y_c)
|
|||
end
|
||||
return 1
|
||||
end
|
||||
if not ((y_a == y_b) and (x_a == x_b)) then
|
||||
if not (y_a == y_b and x_a == x_b) then
|
||||
if y_b > y_c then
|
||||
-- swap b and c
|
||||
local h = x_b
|
||||
|
@ -24,7 +24,7 @@ function M.cross_prod_test(x_a,y_a,x_b,y_b,x_c,y_c)
|
|||
y_b = y_c
|
||||
y_c = h
|
||||
end
|
||||
if (y_a <= y_b) or (y_a > y_c) then
|
||||
if y_a <= y_b or y_a > y_c then
|
||||
return 1
|
||||
end
|
||||
local delta = (x_b-x_a) * (y_c-y_a) - (y_b-y_a) * (x_c-x_a)
|
||||
|
@ -55,16 +55,12 @@ end
|
|||
|
||||
-- Convert rectangle defined by two point into polygon
|
||||
function M.two_point_rec_to_poly(rec)
|
||||
local poly = {};
|
||||
poly[1]["lon"] = rec[1].lon
|
||||
poly[1]["lat"] = rec[1].lat
|
||||
poly[2]["lon"] = rec[2].lon
|
||||
poly[2]["lat"] = rec[1].lat
|
||||
poly[3]["lon"] = rec[2].lon
|
||||
poly[3]["lat"] = rec[2].lat
|
||||
poly[4]["lon"] = rec[1].lon
|
||||
poly[4]["lat"] = rec[2].lat
|
||||
return poly
|
||||
return {
|
||||
rec[1],
|
||||
{ lon = rec[2].lon, lat = rec[1].lat },
|
||||
rec[2],
|
||||
{ lon = rec[1].lon, lat = rec[2].lat },
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Reference in New Issue