2008年7月4日
#
-- util.lua
-- Common Lua Function
-- Author: Liu Denghong
-- Date: 20080702
require "liu"
liu.util = liu.util or {version = 0.1;};
liu.util.Print=function(msg)
print(msg);
end;
-- Min
liu.util.Min = function(a,b)
return (a<b and a) or b;
end;
-- Max
liu.util.Max = function(a,b)
return (a>b and a) or b;
end;
-- IsTrue
liu.util.IsTrue = function(a)
return (a~=false and a~=nil);
end;
-- 只適用于表: a={"liu","deng","hong"};
-- 不適用于記錄型表: b={name="liu", name1="deng", name2="hong"}
-- 等價(jià)于ipairs(t)
liu.util.TableIter = function(t)
local i = 0
local n = table.getn(t)
return function ()
i = i + 1
if i <= n then return t[i] end
end
end
2008年7月2日
#
-- liu.lua
-- Common Lua Function
-- Author: Liu Denghong
-- Date: 20080630
liu = liu or {version='0.1';};
-- Examp: liu.Apply(liu, {a=1,b=2});
liu.Apply = function(o, c, defaults)
if defaults then
liu.Apply(o, defaults);
end
if (o and c and type(c)=="table") then
for p,v in pairs(c) do
o[p] = v;
end
end
end
liu.Apply(liu, {
EmptyFn = function() end;
Num = function(v, defaultValue)
if(type(v) ~= "number") then
return defaultValue;
end
return v;
end;
});
2008年1月4日
#
圖像旋轉(zhuǎn)是指把定義的圖像繞某一點(diǎn)以逆時(shí)針或順時(shí)針?lè)较蛐D(zhuǎn)一定的角度,通常是指繞圖像的中心以逆時(shí)針?lè)较蛐D(zhuǎn)。
假設(shè)圖像的左上角為(left, top),右下角為(right, bottom),則圖像上任意點(diǎn)(x0, y0)繞其中心(xcenter, ycenter)逆時(shí)針旋轉(zhuǎn)angle角度后,新的坐標(biāo)位置(x′, y′)的計(jì)算公式為:
xcenter = (right - left + 1) / 2 + left;
ycenter = (bottom - top + 1) / 2 + top;
x′ = (x0 - xcenter) cosθ - (y0 - ycenter) sinθ + xcenter;
y′ = (x0 - xcenter) sinθ + (y0 - ycenter) cosθ + ycenter;
與圖像的鏡像變換相類似,也采用按行逐點(diǎn)變換的方式實(shí)現(xiàn)圖像的旋轉(zhuǎn)
(摘錄自http://v3.7880.com/Info/Article-79ea53c0.html)
hhh
2007年12月25日
#
今天要用c++處理一個(gè)XML文件,但是又不想用很龐大的庫(kù)。
最后在網(wǎng)上找到了一個(gè)小巧的類CMarkup. 感覺(jué)非常好用。
http://www.firstobject.com/dn_markup.htm
2007年12月22日
#
摘要: 慶祝我的C++博客開(kāi)通
閱讀全文