Archive for journal

Cubic Splines Revealed

There are many forms of numerical approximation, and even more names for the different methods. Depending on how they are used, they are often called by a different name if certain parameters are different. For a recent implementation in a network game, I’ve had to become very familiar with these concepts.

For example a Parametric Free (or Natural) Cubic Spline,  is in fact, the Cubic Bézier Curve when defined in terms of Parametric coordinates ( e.g. where you interpolate the dependent variables x, y on t.)

Generally, a free cubic spline is defined as
y = S(x) = ax3 + bx2 + cx + d

However, when you parameterize S(x) with respect to [wrt] time, x = x(t), y = y(t), you get the Cubic Bézier curve.

x(t) = at3 + bt2 + ct + d
y(t) = et3 + ft2 + gt + h
(let t = 0, and then d,h simply become d = x0 and h = y0 )

A really nice explanation of the derivation of a-f is presented at:
http://www.tinaja.com/glib/fastbez.pdf   

Since general cubic splines always go through their end-points, the Cubic Bézier curve must also go through all of the end-points wrt to time t. This is where in the confusion lies as to whether or not the spline goes through all the points. It definately goes through all the end-points, but whether or not you define your “control points” to equal your end-points is up to you.

Since you generally use cubic splines to piece-wise approximate an extended curve between multiple fixed/known/measured points, I call all these piece-wise fixed end-points the control points. However, when defining the Cubic Bézier, you must approximate (or choose from your control points) two inner points between each of the end-points. The Cubic Bézier curve will not pass through these inner points. Some people call these inner points also “control points”, in which case the curve will not pass through all the control points. Thus, it’s a matter of perspective.

I personally believe that if the two inner points are an approximation (e.g. non-end-points), it’s unfair to call them control points because they are not guaranteed accurate (e.g. not measured). But if you select some of your end-points as your inner points (e.g now guaranteed accurate), beware the curve will not pass through them, even though you know it should! A real catch-22.

A little bit more explanation can be found at http://groups.google.com/group/comp.graphics.algorithms/msg/7276de840df9614c?hl=en&fwc=1

A sample implementation in C is on Wikipedia: http://en.wikipedia.org/wiki/B%C3%A9zier_curve

An alternate approach is to use the standard 2D Cubic Spline interpolation on an XY plane, fixing x and y wrt to t. If you do this, you can use the example in “Numerical recipies in C” at http://www.library.cornell.edu/nr/bookcpdf/c3-3.pdf to create a Cubic Spline in each dimension (x(t), y(t)). E.g. Instead of fixing x and interpolating for y, fix t and interpolate for x, then keeping the same fixed t interpolate for y.

Illegal Workers’ Rights

Living in California has imbred a kind of presumption in me and probably most people that illegal workers are the “Mexicans” . As with all blanket statements, they’re usually wrong and the same is true for this assumption. One group of these illegal workers are international students who come here and are expected to pay a tuition 2-3x a US Citizen would pay, probably even more once exchange rates (relatively speaking) are figured into the equation. On top of that, they are only allowed to work on campus and part-time, which is probably only at minimum wage. With such limited legal options, many work under the table performing jobs paid by the hour.

My girlfriend is in this situation, unable to work legally and not fortunate enough to have parents that can support her. She’s managed to keep a steady job, but not without incident. Her last job was at one of the hundred mobile phone shops in K-Town. Her employer, a first generation Korean guy had generally always respected his employees, but was uniformly late in paying them. It got to a point when she couldn’t pay her bills on time and risked hurting her credit. She made the decision to leave and hope to get paid the $1,800 owed to her later when her employer had the money. But when her boss found out, he lost it. He said “If you ever come around  here again, I’ll call the INS! You can forget about your pay check.” He seemed to think it was his right to pay her and not his obligation. I am sure the threat is an idle one, but it drives home the point. What rights does she have?

Turns out, there are many organizations representing illegal workers. For that, I am grateful. One in particular, respresents Korean laborers and has been very helpful to my girlfriend. By advising her of her rights, informing her how little legal power he has over her, she was able to get paid in the end… albiet 3 weeks later. She had kept insisting that he give her some money. He wrote her a bad check, that when she cashed, bounced twice. But that was his fatal mistake. It gave her all the bargaining power she needed to take him to small claims court. He conceeded he was a jerk and gave her cash! The funny thing is, he wanted the bounced check back. As if that would protect her? Bank records are immutable and photocopies hold up well enough in court.

 

 

West is craving Zen and Kanji

http://everything2.com/index.pl?node_id=489380

Found this quote the other day, that I felt really summed up the whole East-meets-West phenomenon.

I am not asian, but this is a thought:

One thing that was particularly interesting in this node was the fact that you say that you prefer the company of American youth, and you criticize your fellow Asian youth for their floppy attempts at westernizing. The thing is, many of the young (North) Americans that I know are sucking down anime and sushi faster than you can say GAINAX!

I am willing to bet that, as objectively as possible, hip chyx walking down Queen Street W. wearing some Chinese printed t-shirt, (that for all they know says: I AM CHEAP AMERICAN WHORE), look every bit as ridiculous as your Korean boy bands. The West is craving Zen and Kanji at the same time as the East is going crazy for Rock and Roll and McDonald’s.

Fitness Resolution

By June 30th, I will be able to maintain a heart rate of 154 bpm for 45 minutes. I commit to myself that I will attend the Gym no less than 4 times a week until this resolution is met.

Status:
May 31 – 10 Minutes; 130 HR; 82 RPM
June 1 – 20 Minutes; 154 HR; 82 RPM
June 2 – 25 Minutes; 164 HR; 85 RPM
June 6 – 25 Minutes; 174 HR; 93 RPM