Moving forward: Cylinder

Web July 30th, 2007

Cylinder is much more difficult to implement than the other polygon-based 3D objects. Polygon is still polygon after 3d projection, but the circle is mapped to ellipse and the we need to draw the the outline of surface by all means.

First thing first, we may reuse the cap later, so we introduce the dojox.gfx3d.Orbit, which is the Circle in the 3D space, the first challenge is how to map the X-Y plate circle to the 3D space orbit? We know the new center, the semi major (this may not be true if the projection includes any scale of X, Y, Z axis), and marks which are the projection of artibitrary points in the original circle.

The algorithm is inspired by this mathematic lecture.

  1. The general equation is: ax² + 2bxy + cy² + dx + ey + f = 0, we can normalize the marks according to the new center, the equation is reduced as : ax² + 2bxy + cy² + f = 0
  2. Let a = 1, the other parameters are determined by marks. 2b, c, f.
  3. The rotation angle, theta, is defined as theta = Math.atan2(2b, a–c) /2.
  4. Then we can rotate the normalized mark by -theta to get the canonical equation: x²/a² + y²/b² = 1.
  5. Using the marks again to find out a and b, which are the rx, and ry.
Cylinder

The draw procedure would create a Ellipse on (0, 0) with rx = a, ry = b, rotate theta, then transpose to the center.

We could not use the Scene to simplify Cylinder drawing, since the curved surface is not a fixed rectangle. We draw the further cap first, then draw a rectangle with width of distance of two caps, height of major radius. A easier approach is to draw the path in (0, 0), rotate theta and transpose to the new center.

One picture is worthy the above. As usual, here is the snapshot.

Dilema of Kernel upgrade

Gentoo July 28th, 2007

I enjoy upgrading kernels in my Dell 700m laptop, the new kernel usually brings more functionalities and fixes bugs. In the recent upgrade to suspsend2-source-2.6.22, I found Fn + F7 VGA output does work any longer, which worked so perfect in suspend2-sources-2.6.18-r6 that I even regarded it as a built-in feature of BIOS. Right now, I need to explicitly call i855crt to output either shaking rawpipe or 8-bit color palette images to external monitor, both suck.

Maybe it required some other bleeding-edge components. I upgraded the x11-drm and xf86-video-i810 to the unstable ~x86 branch in the portage. Things got even worse. xf86-video-i810-2.0.0 could mirror screen to the external monitor if it was attached in X server launch, that suffice the need of presentation, however, there were two screen 1152×768 and 1280×800 sharing the same desktop in the sole head, that totally confused KDE, and windows’ behavior s were quite weired.

So I went back to xf86-video-i810-1.7.4 for the daily working environment, and reboot the machine to kernel 2.6.18-r6 for the presentation, — that is ridiculous but I could not stick to 2.6.18 kernel since the source tree is deleted, and also removed from the portage. What I have in the hand is the monolithic kernel only.

For the troubleshooting, I compared the .config of 2.6.18 and 2.6.22 head by head, and still could not figure it out what I did wrong. If you manage to make the VGA output work in 2.6.22 kernel, or point out the mistake I have made, please drop a comment here. Thanks.

Website remodeled

Web July 20th, 2007

I’ve been remodeling this website in last two weeks. It is really challenging to pursue the best user-experience, not technology, just the sense of beauty. It may take hours to find the most satisfying margin, padding and color scheme. Just post here for the record.

Fine tune the theme

The rtl theme was modified based upon Joe[y]’s Yadda, a fixed-width -two-column Wordpress theme. It was tailored to capitalize the wide screen since I listed the source code from time to time. The sidebar was moved from the left side to the right side for my personal taste.

I did not notice there was a big mistake of layout until yesterday, the #sidebar is composed by #main, instead of #content. This is legal, passing the XHTML validation, but not consistent to my original design, no wonder I had to put the sidebar explicitly using position: absolute . After the reorganizing the divs, the adjustHeight hack does not make sense any longer, so it is with the vertical separator.

Another pitfall is the #topbar, the tabs moved above the horizontal separator when text was zoomed in. After I assigned the horizontal separator to content’s border-top, and dropped the height by using padding, the tabs’ positions are managed by the layout engine automatically, and the #topbar works perfect.

Last but not the least, the color scheme. I love chic design, so I tried my best to use as few as possible colors in the whole site. I also stole the color pattern from Google Code for the #topbar

Advertisement management

To be honest, I never expect to get paid to cover my ISP expense. Well, it is not a big deal, I happened to catch the DreamHost’s 777 promotion and Globat’s FAR campaign. The Google Adsense advertisement is more or less a sign of profession. It collected very small amount of money every month. Once I got the payment, it would take at least 24 months or forever for the minimum payment, $100, I would drop it.

Eventually, I dropped the Firefox referral banner as I found most of my visitors were using Firefox. Lots of bloggers in 9rules are using Text link Ads, which is more like traditional banner, hopefully they can sell.

Miscellaneous fix

Thanks to Matthew’s report, I fixed the contact page. It may be interesting to AJAXize it later.

Update By using Yahoo’s YSlow for Firebug, I recognized a inaccessible background image in the CSS, removed. Scored A in YSlow by the way.

Update The favicon is generated via online favicon service, a mixture of Chinese calligraph and English characters for my family name. Hope you enjoy it.

Small fix for libnjb to transfer Chinese tags

Desktop, Gentoo July 17th, 2007

I once mentioned that some Chinese characters are missing in Creative ZenMirco when using Amarok + libnjb. I checked the libnjb-2.4.4 source code and found that the text codec conversion from UTF-8/ISO8859-1 to UCS2 big-endian is home-brew instead of the standard libiconv, maybe the libiconv is overkill since only three codecs are really needed. According to the specification of UTF-8

U-00000000 – U-0000007F: 0xxxxxxx
U-00000080 – U-000007FF: 110xxxxx 10xxxxxx
U-00000800 – U-0000FFFF: 1110xxxx 10xxxxxx 10xxxxxx
U-00010000 – U-001FFFFF: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
U-00200000 – U-03FFFFFF: 111110xx 10xxxxxx 10xxxxxx 10xxxxxx
10xxxxxx
U-04000000 – U-7FFFFFFF: 1111110x 10xxxxxx 10xxxxxx 10xxxxxx
10xxxxxx 10xxxxxx

while the libnjb developers made a small mistake, so all 0×80xx characters are categorized as abnormal.

if (numbytes == 2 && str[i+1] > 0×80) {
                        … …
                } else if (numbytes == 3 && str[i+1] > 0×80 && str[i+2] > 0×80) {
                        … …
                } else {
                  /* Abnormal string character, just skip */

Here is a patch against libnjb-2.2.4, you may adapt it to libnjb-2.2.5 as well. For Gentoo users’ convenience, here is the ebuild.

I am just curious why this bug has been here for such a long time. How many Chinese Linux/BSD users take UTF-8 as the locale, transfer music to Creative ZenMicro? Are these three factors are really small that make this almost never gonna happen?

HOWTO Gentoo 2007.0 on Dell 700m

Gentoo July 14th, 2007

During the last disaster, I lost the root partition, while the good news is the irresponsible mkstage4.sh backup the /etc that saves a huge amount of time for me to emerge world.

This post would summarize the efforts for my record and for your convenience. This HOWTO is originally posted in the official forum three years ago, and I once tried to update it in my previous post as well. Since then, some devices get supported, some software packages are obsolete, Life runs fast. Read the rest of this entry »