Wednesday, April 27, 2011

Slow by, sorry, how many years?



Since JC I have been walking home from Tampines Interchange, and it is because I like walking, not because there's always long queues for 291. No, not because of that.

Monday, April 25, 2011

if you think you are good...

EDIT: On second thoughts, I have no evidence that this is done by who I think it is. For all I know it may be the work of the rivals instead, with a motive to generate hatred in us. As the politicians go all out to win the voters' hearts, the strategies they employ are getting more sophisticated too, so I can no longer look at things simply from the surface anymore. This is more exciting than 無間道。

...why the need to resort to this?



Courtesy of fakeMOE.

And to that "Jane Ngoh", its ok to put a celebrity as your profile picture, but if you do not intend to be exposed as a fake, at least put one that cannot be easily found.

Sunday, April 24, 2011

GE2011

I have already quite made up my mind on who to vote for, but I still hope I will be able to spare some time to go down and listen to the rallies.

Pardon the political apathy on my part, while I know that Group Representation Constituencies, or GRCs, must be formed such that one of the candidates must be from a minority community, it was only recently that I realised that the ruling does not mean the minority candidate in each GRC can come from any of the minority communities; election rules actually dictate which GRCs must have their minority candidates from which minority community. For example, for GRCs like Tampines, Aljunied and Marine Parade, the minority candidate must be a Malay, while for GRCs like Nee Soon, Ang Mo Kio and Holland-Bukit Timah, the minority candidate must be an Indian or from other minority communities.

The Government has always maintained that the GRC scheme is to ensure minority representation in Parliament, but I wonder why can't the Government apply the same rules without the GRC scheme, ie, there are only single seat wards, and have rules to govern which seats must be contested by candidates from which minority communities.

I'm still pissed at the kind of carrots the incumbent tangled at the residents of my estate: a drop off porch at my [and some other] void deck, more sheltered walkways, a jogging path and some exercise station right in front of my flat, and landscaping works at the traffic light near my house. I felt cheap.

I recall my Secondary 2 Higher Chinese teacher asking my class back then, if 浜崎 歩 and Lee Kuan Yew both stand for elections, who will the younger generation vote for? With the whole hype surrounding Nicole Seah recently, we might just have an answer soon.

Friday, April 15, 2011

2010/2011 Sem 2 last day

The 5th and last CS3241 assignment was to 'build' anything on a plot of land; can be a house, a school, a temple, a farm etc, and the grand plan was to combine all our submissions into one big plot of land.

I drew a stadium haha.



1) There were only three 'sides' because the land was too small to have all four 'sides' surrounding the field. If I were to put the field in the middle, as is usually the case, I could only do a Jalan Besar Stadium at best [ie, only two sides], so I shifted the field to one side and added in a slightly complicated semicircle spectator stand to not make it too simple a design. The fourth 'side' was a large screen that is usually present at stadiums haha.

2) The four pillars were supposed to be stadium lights ala National Stadium, but I decided to draw roofs instead [the main point of this assignment is texture mapping anyway].

3) I think it is quite obvious to see, I started off enthusiastically drawing out all the lines on the field, but by the end I was getting tired of it, so after I drew the two roofs I just drew lines to connect them to the pillars haha. The tiring part was actually the steps on the spectator stand, which I drew them out with for loops instead of hardcoding. It was even more tiring to do the curved stand because I need to feed in the correct angles.

4) The texture mapping looked a little weird to me, not quite sure where I have gone wrong yet, partially because I don't know what the correct mapping should look like.

And that is all for my Computer Graphics module, with only the final exam left. Overall I have enjoyed this module very much, hopefully I can continue to get my hands dirty in it during the summer vacation. However I think I am a little weak in the maths that CG requires, which is [for now] linear algebra, something that I need to recap and brush up.

********************************

CS3215 is finally over too, though there will be a presentation come Monday. While there was the initial disappointment of not being able to join my friends in the iPad programming module, I am glad to be able to meet awesome teammates in CS3215, whom I have learnt a great deal from. I do feel bad that I am not as good as them.

The obsession with speed:


Before(top) and after(below) optimisation:



********************************

CS2105 is only my second module where assignments were explicitly stated to be done in Java, with CS1102S being the first. While Java is the norm for most people in the School, its C/C++ instead for me: CS2103 [we were given a choice of Java, C++ and C#], CS2106 [low level C], CS3215 and CS3241. That means most people in the School know more Java than me, but C++ is still my weapon of choice any day.

Anyway, like CS1102S labs, CS2105 assignments had base code provided for us, so I could focus on the network portion rather than the Java portion. Overall network is quite okay; I will probably go on to take advanced network modules as soon as next semester.

*******************************

PC1143 is difficult; way more difficult than I expect from a Level 1 module. The theories are okay, but the maths requirements are off the chart. Let's hope I can understand them soon.

SSA2205 is a little unknown though, I admit I have been neglecting it the entire semester, listening to lectures half heartedly and attending tutorials unprepared, but being rather open ended like General Paper in JC, I don't quite know what else I can do besides eating the entire textbook and understanding the various issues.

May I survive the examinations!

Sunday, April 03, 2011

teapot

CG Assignment 4 was to draw a teapot [or rather, the teapot] given a set of points. I kind of liked it even though it was quite difficult for me; maybe because there was no creative component :p

First step was to draw the control net that defined the teapot, the same way we use points in drawing software to define curves. First step was easy; just connect the points together in 3 for-loops.



With that done, next step was to draw out the actual teapot, which was also not difficult, by using Bezier curves.



Then we had to implement both flat and smooth shading on the teapot. In general, normal vectors are needed to determine the degree of shading, because we use them to find out which parts are facing the light source, and which parts are not. For flat shading, we find out the normal vector of each polygon, which results in each polygon having one same colour, hence the 'patches'. To find the normal vector, use three vertices either in a clockwise or anticlockwise manner.



Smooth shading was the most difficult part of the entire assignment. Instead of finding out the normal vector of each polygon, we had to find out the normal vector of each vertex, and that involved using the partial derivatives of the Bezier curve to find the two tangent vectors on each vertex, then applying cross product of the two tangent vectors to find the normal vector. This took me a hell lot of time.



And the green lines are the normal vectors of each vertex.



Finally, apply the reflection model.



One challenge of this assignment was the obscene number of calculations required. In particular, the front UI of this assignment included a slider allowing users to change the number of subdivisions, which determined the number of vertices used to represent a polygon. Larger subdivisions == more vertices needed == more detailed polygon representation == more calculations needed. And of course, each time a user dragged the teapot to rotate it or change its direction, the teapot had to be redrawn, so recalculating each time the user rotated the teapot would cause the program to lag badly.



The difference between small and large subdivisions.



Since apparently the markers would be looking at the speed of the program, I thought I should do some optimization. Basically, before the UI came up, the program would calculate the coordinates of the position and normal of each vertex of each polygon of each patch [28 patches made up the teapot] of each subdivision [subdivisions range from 1 to 50], then dumped all points into a giant 51x28x51x51 array. Getting each coordinate would then be a fast O(1) operation.



End result was great! A small hint of lag still existed, but otherwise the program was fast. The problem was that the user would have to wait ~10 seconds before the teapot got drawn.

In conclusion this was a difficult assignment, but I had a lot of fun doing it ;) Hopefully I have time to try out texture mapping [planting some image onto the teapot, much like putting labels on a soft drink can], and another method of obtaining the normal vector without resorting to differentiation, which is to find the normals of the polygons surrounding the vertex, and obtaining the average of all those normals.

That's all from me for now; till the next time!