Code

2010年12月21日星期二

Kent Ridge Park

今天又去跑Kent Ridge Park的路线了。还是太久没跑了,整个路程都感到好累。进入Park的时候有一个很长,很陡的坡。跑上去的时候感觉好像在只用双腿让自己垂直上升。跑完之后,小腿还疼了好长一会时间。还好全程都没有走,难受的时候也只是放缓速度,保持了我跑步时的一贯作风,哈哈。回来之后用google earth测量了一下全程大概6K吧,我花了将近40分钟跑。很显然这个太慢了,尽管中间有坡路。



最近在考虑要不要加入MR25。据说这个是新加坡最大的跑步爱好者协会。为了保证自己的声誉,他们对会员都要求非常严格。每个月基本上都会有一次长跑在麦里芝蓄水池,其中会有time trial,并将成绩等到网站上。看了一下,12月份的那次最快的5K跑了18分钟,最慢的也有23分钟,水平还是有点高的相对于普通的群众性组织。里面有一个elite squad,一共30个人。都是每年选上达标的人。只有elite squad里的人才能代表MR25参加公开的比赛。如果参加MR25的话,我肯定是想要进这个squad的。虽然有会费,但不是很贵,一年20块。不过我还是有点犹豫,主要是在想时间问题。因为每次比赛在麦里芝蓄水池,离NUS太远了。恩。。再犹豫几天吧。

2010年12月16日星期四

Seven signs you're a healthy man

Fitness
To test your fitness, you don't have to run for miles or do 200 push-ups.

Experts say that the average person should be able to walk a mile in 15 minutes, carry two bags of shopping to the car, and climb the stairs in a house without getting breathless.

But that doesn't take into account age or gender. More specifically, a 30-year-old man with above average strength and fitness should be able to do over 25 push-ups in a minute and over 35 squats.



Vital signs
As long as you have a watch and the ability to count, you can measure a couple of your vital signs from the comfort of your armchair.

A resting pulse of around 70 beats per minute and a respiratory rate of around 16-20 breaths per minute don't make you an athlete, but they do make you a normal, healthy adult.



Nails
Men don't pay much attention to their fingernails, but they can give vital clues to general health.

Yellow nails are suggestive of respiratory disease, spoon-like nails curving outwards can mean iron deficiency anaemia, and lines going across the nails may be a symptom of diabetes.

Go to the doctor if there's any major change in the look or feel of your fingernails. Firm, pink nails, on the other hand, can be evidence of a decent general level of health.



Toilet time
If you're about to have lunch, it might be wise to skip this bit till you've finished. In a word, we're talking stools, because stools can speak volumes about overall health.

It's not so much how often you pass them that's important (unless this suddenly changes) - once a day, three times a day, or even every other day can all be healthy depending on the individual - but consistency and colour.

A good stool is torpedo shaped, soft and easy to pass. Colour can depend on what you've eaten, but it shouldn't generally be grey, very pale, too dark or bright red. A mid-brown stool, passed easily and regularly without any sudden change in bowel habits is one sign of decent digestive health.



Urine
And to continue the theme, if you have pale yellow pee you're drinking enough fluids and - in the absence of other symptoms - probably don't have any urinary tract infections.

A good colour is also a sign that your liver is working efficiently. Don't worry if you drink a lot of water and you're urine turns almost clear - apart from the inconvenience of all those trips to the toilet, that's no problem.

A darker yellow probably just means you've been drinking less - drink more to avoid the symptoms of dehydration.
But dark or red-tinged urine - or pee with a sweet or strange odour - can be a symptom of health problems.



Shiny, healthy hair
A fine and luscious head of shiny hair not only looks good, it's also a sign that good things are happening in your body.

In particular, healthy hair can be a sign of a healthy diet. Dull, dry and brittle hair can be caused by a lack or protein, vitamin E or essential fatty acids. Hair so healthy women want to run their fingers through it may be evidence that you're absorbing plenty of body-friendly nutrients.



Tongue
Doctors can tell a lot from your tongue.

A tongue with a warm, pinkish colour is one clue that you are absorbing sufficient iron, folic acid and vitamin B12.
An overly pale and smooth tongue can be a sign of anaemia, while a yellowish tint can suggest fungal infection.

2010年11月1日星期一

浅谈 potentially visible set (PVS) in Quake

现在一般3D或者2.5D的地图都会有一种划分地图的方式,比如说魔兽地图是将地图划分成小的方块,雷神之锤的用立体的凸面体来划分。这样的做法是整个地图能够更好的被掌控,不然按照一个个多边形划分的话,不仅数量巨大难以掌控,更对电脑性能是一大挑战。

John Carmack在雷神之锤里使用二叉树(BSP)来分割空间。在中间节点里储存分割面,枝头储存空间信息,我们称它为Area。这样搜索地图里一个坐标的Area的位置就非常方便了,只要从树根出发,确定坐标在分割面的那一边,然后到那一边的节点做相同的对比,直到枝头就可以了。自然而然的,Area的连接信息也可以很容易的得到。先找到Area的分割面的节点,然后再找到面的另一边Area。当然这些都是比较费时间的,所以只能在线下处理。而且这些信息都是静止的,所以得到的数据都是不会因为游戏的进行而改变的。

那么计算这些东西有什么用呢?答案是Potential Visible Set,潜在可视集合。这是一个非常有用的东西。它的具体原理很简单,就是为每一个Area计算其他每一个Area的可见度。所以当视角在一个Area的的时候,我们就可以知道周围哪些Area是看得见的了。但这里所谓的PVS是脱离视角的,它只跟Area有关。所以,一个玩家周围360度的Area都可以是在PVS里面。这个东西配合view frustum culling, back surface culling, 和 z-filling/buffering就有完美的quake engine。当年John Carmack绞尽脑汁才想到用这种方法预先计算需要渲染的图像,以达到游戏可运行的帧数。

计算PVS还需要知道Area的虚切面,也就是Area的一个并不存在于多边形集合里的切面。我们叫它Portal。Portal是从一个Area到另一个Area的必经之路,所以要计算从一个Area能不能看到另一Area就要检查它们之间有没有一条直线经过的面都是Portal。 这是我们还需要一个Adjacency Graph 来方便的得到连续的Portal。

然后我们可以用Depth First Search来进行Stabbing Line Checking。这个在3D里面是一个比较难的问题。 就像上面那个图,在三维空间里给你一连串的多边形,你需要判断是否有一天直线贯穿所有多边形。这个问题据说要用pluker coordinates来解决,但现在我还无法理解,等我理解了在写一篇解释一下吧。

一旦这个问题解决了,PVS就可以得到了。由于Area的数量比较多,PVS是Area数量的平方,所以必须compress 才能在游戏中使用。这里John Carmack用的是bit来表示可见度,然后使用run-length encoding。本来20多兆的数据,只剩下20多K。

在Seth Teller 92年的论文里有更详尽的解释,事实上他的algorithm精确到一个像素,所以不会有像素覆盖的现象。

除了在图像渲染方面的应用之外,PVS也可以用做手机游戏能量节省的算法。他的精确度相当高,所以,在一个密度不是很大的游戏里面,玩家有50%以上的时间是可以关闭网卡的。