Friday, March 27, 2009

A historical timeline for Computer Graphics & Animation

http://sophia.javeriana.edu.co/~ochavarr/computer_graphics_history/historia/

Matrix Vector hints

Matric and various vector math hints and tips.
-------------------------------------------------------------------------------
General Matrix calculation is by

[x,y,z] * M => [x',y',z']

|x| |x'|
or M * |y| => |y'|
|z| |z'|

The result is the same in either case. As long as the matrix was created using
row vectors OR column vectors to match!

Which style is used is up to the matrix library version you use. I prefer
the former, which The perl Math::MatrixReal library seems to like the later.
Just note the order.


-------------------------------------------------------------------------------
Matrix and what the terms actually mean...

From the povray matrix page..
http://enphilistor.users4.50megs.com/matrix.htm

Generally a matrix is defined (at least in Povray) as...

| A.x A.y A.z 0 |
| B.x B.y B.z 0 |
| C.x C.y C.z 0 |
| D.x D.y D.z 1 |

This can be thought of a a matrix of four (row) vectors A, B, C, D
where A = | A.x, A.y, A.z, 0 | etc. (NB: A.x is the x component of A)

What this matrix does is wrap the 3D space so that the X axis moves (rotates,
scales, shear, etc) to vector A, ditto for Y -> B and Z -> C. The last vector
D is the new location for the Origin (translate).

As the page above specifies this means that if you create a set of orthogonal
vectors A,B,C general rotations are very easy to do, and goes on to provide a
two part solution to rotating any general vector to any other general vector
(while retaining an general up direction).

-------------------------------------------------------------------------------
Orthogonal Matrices

A matrix is orthogonal if each of the three vectors making up the matrix
are orthogonal. That is they are all perpenducular to each other.

This is true of all rotation matrices (no scaling or shear).

What is interesting is that the inverse of such matrices is also its
transpose. And that matrix in itself is also orthogonal.

This means if we have a rotation matix

| A.x A.y A.z |
| B.x B.y B.z |
| C.x C.y C.z |

To rotate the x,y,z axises to the A,B,C vectors, then it so happens that
the inverse (rotate A,B,C vectors to the x,y,z axises) is the matrixes
transpose (diagonal mirror).

| A.x B.x C.x |
| A.y B.y C.y |
| A.z B.z C.z |

-------------------------------------------------------------------------------
Rotation Matrices are...

Normilized or Each row or column are unit vectors (vector length = 1)
Orthogonal or Dot product of any row to to any other row
or column to column is 0
EG: All row or column vectors are perpendicular to each other
Its Inverse is also its Transpose (due to orthogonality)

-------------------------------------------------------------------------------
Rotation Matrix about axis (x,y,z) and angle a

Given that s = sin(a) c = cos(a) t = (1 - cos(a))
and x, y, z defines the axis you want to rotate around
then, the rotation matrix is...

| txx+c txy+sz txz-sy |
R = | txy-sz tyy+c tyz+sx |
| txz+sy tyz-sx tzz+c |

For very small angles (and you later occasionally re-normalize)
A technique often used for interactive rotations using a mouse.
Then s = sin(a) => a c = cos(a) => 1 t => 0
and thus rotation becomes
| 1 za -ya |
R = | -za 1 xa |
| ya -xa 1 |

Given a orthogonal rotation matrix
Then the axis and angle of rotation can be found using...

cos(a) = ( R[0][0] + R[1][1] + R[2][2] - 1 ) / 2

axis = ( R[1][2]-R[2][1], R[2][0]-R[0][2], R[0][1]-R[1][0] ) / 2*sin(a)

-------------------------------------------------------------------------------
General Rotatation of a unit vector V to unit vector W
(rotation in same plain as both vectors - ie: the minimal rotation)

This is complex and difficult if you try to generate it using the
above general axis and angle method. The following generates it faster
and more simply, without need for sin() and cosin() functions, using the
meaning of the three vectors in a roatation matrix.

To do this requires three steps...

1/ Matrix to rotate the Vector V onto some arbatary axis (eg: X)
but such that the vector W also rotates to W' in the XY plan!
2/ One to rotate about the Z axis so that the rotated vector V'
(which is now at the X axis) is rotated to W' in that frame work.
3/ Rotate back to the original axis frame work by using the
inverse (transpose) of the original rotation.

First Step
It is easier to calculate the last step and invert the matrix, so...

We need to find two more unit vectors orthogonal to the original
vector V. One of these vectors must be the axis of rotation
so it can be moved to the Z axis for the second step.

Find the axis of rotation N
N = normalised ( V x W )
And the other orthogonal axis to complete the axis frame work.
M = N x V (note M is unit length as N and V are orthoginal)
alturnativally...
M = normailzed( V x W x V )

to rotate the X Y Z axis to this frame work would thus be...
| Vx, Vy, Vz |
Q = | Mx, My, Mz | (NB: a matrix of row vectors)
| Nx, Ny, Nz |
But for this step we want to do the oppisite! So inverse the orthogonal
matrix by transposing (diagonal flip). So the first step is....
transpose(Q)

Second Step
The new location of V (or V') which is now the X axis, needs to be rotated
around Z (now the axis of rotation), to the new location of W or W'

W' = W * transpose(Q)

As the Z axis does not rotate we only need the new location of the Y
axis in this step to complete this step.

Y' = W' Zrotate(90deg)
= Z x W'

The actual rotaton matrix in this axis framework is thus...
| W'x, W'y, W'z |
T = | Y'x, Y'y, Y'z |
| Zx, Zy, Zz | <- This is just (0, 0, 1)

Third Step
We just rotate back to the original coordinate system...
This was the original matrix Q calculated in step one.


The completed rotation matrix is thus..

Rotate_V_to_W = R = transpose(Q) * T * Q


===============================================================================

The following is vector stuff, not matrix...

-------------------------------------------------------------------------------
Distance of a point to a line.

Given line AB, Point C some distance away.
Minimim distance of C to line (perpendicular to line)

r = (AB . AC) / |AB|^2

WRONG: that is the distance of C from A in the direction of A to B!
That is length along the line!

-------------------------------------------------------------------------------


From http://www.cit.gu.edu.au/~anthony/info/graphics/matrix_vector.hints

Thursday, March 26, 2009

Some info on Matrix & Quaternion... need to consolidate with the other posts

http://www.j3d.org/matrix_faq/matrfaq_latest.html

Perl RegEx reference

Conventions

The following conventions are used in the examples.

   metacharacter(s) ;; the metacharacters column specifies the regex syntax being demonstrated
=~ m// ;; indicates a regex match operation in perl
=~ s/// ;; indicates a regex substitution operation in perl

Also worth noting is that these regular expressions are all Perl-like syntax. Standard POSIX regular expressions are different.

[edit] Examples

Unless otherwise indicated, the following examples conform to the Perl programming language, release 5.8.8, January 31, 2006. The syntax and conventions used in these examples coincide with that of other programming environments as well (e.g., see Java in a Nutshell - Page 213, Python Scripting for Computational Science - Page 320, Programming PHP - Page 106 ).

Metacharacter(s) Description Example
Note that all the if statements return a TRUE value
. Normally matches any character except a newline. Within square brackets the dot is literal.
$string1 = "Hello World\n";
if ($string1 =~ m/...../) {
print "$string1 has length >= 5\n";
}
( ) Groups a series of pattern elements to a single element. When you match a pattern within parentheses, you can use any of $1, $2, ... later to refer to the previously matched pattern.
$string1 = "Hello World\n";
if ($string1 =~ m/(H..).(o..)/) {
print "We matched '$1' and '$2'\n";
}

Output:

We matched 'Hel' and 'o W';

+ Matches the preceding pattern element one or more times.
$string1 = "Hello World\n";
if ($string1 =~ m/l+/) {
print "There are one or more consecutive letter \"l\"'s in $string1\n";
}
Output:

There are one or more consecutive letter "l"'s in Hello World

? Matches the preceding pattern element zero or one times.
$string1 = "Hello World\n";
if ($string1 =~ m/H.?e/) {
print "There is an 'H' and a 'e' separated by ";
print "0-1 characters (Ex: He Hoe)\n";
}
? Modifies the *, +, or {M,N}'d regexp that comes before to match as few times as possible.
$string1 = "Hello World\n";
if ($string1 =~ m/(l.+?o)/) {
print "The non-greedy match with 'l' followed by one or ";
print "more characters is 'llo' rather than 'llo wo'.\n";
}
* Matches the preceding pattern element zero or more times.
$string1 = "Hello World\n";
if ($string1 =~ m/el*o/) {
print "There is an 'e' followed by zero to many ";
print "'l' followed by 'o' (eo, elo, ello, elllo)\n";
}
{M,N} Denotes the minimum M and the maximum N match count.
$string1 = "Hello World\n";
if ($string1 =~ m/l{1,2}/) {
print "There exists a substring with at least 1 ";
print "and at most 2 l's in $string1\n";
}
[...] Denotes a set of possible character matches.
$string1 = "Hello World\n";
if ($string1 =~ m/[aeiou]+/) {
print "$string1 contains one or more vowels.\n";
}
| Separates alternate possibilities.
$string1 = "Hello World\n";
if ($string1 =~ m/(Hello|Hi|Pogo)/) {
print "At least one of Hello, Hi, or Pogo is ";
print "contained in $string1.\n";
}
\b Matches a word boundary.
$string1 = "Hello World\n";
if ($string1 =~ m/llo\b/) {
print "There is a word that ends with 'llo'\n";
} else {
print "There are no words that end with 'llo'\n";
}
\w Matches an alphanumeric character, including "_".
$string1 = "Hello World\n";
if ($string1 =~ m/\w/) {
print "There is at least one alphanumeric ";
print "character in $string1 (A-Z, a-z, 0-9, _)\n";
}
\W Matches a non-alphanumeric character, excluding "_".
$string1 = "Hello World\n";
if ($string1 =~ m/\W/) {
print "The space between Hello and ";
print "World is not alphanumeric\n";
}
\s Matches a whitespace character (space, tab, newline, form feed)
$string1 = "Hello World\n";
if ($string1 =~ m/\s.*\s/) {
print "There are TWO whitespace characters, which may";
print " be separated by other characters, in $string1";
}
\S Matches anything BUT a whitespace.
$string1 = "Hello World\n";
if ($string1 =~ m/\S.*\S/) {
print "There are TWO non-whitespace characters, which";
print " may be separated by other characters, in $string1";
}
\d Matches a digit, same as [0-9].
$string1 = "99 bottles of beer on the wall.";
if ($string1 =~ m/(\d+)/) {
print "$1 is the first number in '$string1'\n";
}

Output:

99 is the first number in '99 bottles of beer on the wall.'

\D Matches a non-digit.
$string1 = "Hello World\n";
if ($string1 =~ m/\D/) {
print "There is at least one character in $string1";
print " that is not a digit.\n";
}
^ Matches the beginning of a line or string.
$string1 = "Hello World\n";
if ($string1 =~ m/^He/) {
print "$string1 starts with the characters 'He'\n";
}
$ Matches the end of a line or string.
$string1 = "Hello World\n";
if ($string1 =~ m/rld$/) {
print "$string1 is a line or string ";
print "that ends with 'rld'\n";
}
\A Matches the beginning of a string (but not an internal line).
$string1 = "Hello\nWorld\n";
if ($string1 =~ m/\AH/) {
print "$string1 is a string ";
print "that starts with 'H'\n";
}
\Z Matches the end of a string (but not an internal line).
$string1 = "Hello\nWorld\n";
if ($string1 =~ m/d\n\Z/) {
print "$string1 is a string ";
print "that ends with 'd\\n'\n";
}
[^...] Matches every character except the ones inside brackets.
$string1 = "Hello World\n";
if ($string1 =~ m/[^abc]/) {
print "$string1 contains a character other than ";
print "a, b, and c\n";
}


http://en.wikipedia.org/wiki/Regular_expression_examples

Sunday, March 22, 2009

Thursday, March 19, 2009

Semester 2: Them

Animation
Prof Q

"How's my english? Ok?"
"A lot of maths har? It's not my fault. It's your fault. You chose engineering."
"Ah-har! Let's prove that! Good!"
"So we've proven that! Great. Good. Hehe. Maths again? Well, it is after all the tradition now."
"If you are going to do research on computer vision, you will definitely hear of this guy... And use his snake method and wavelet form... Clever clever guy." (in awe)



VR
Prof Fox

"I can't help you there if your partner is a virtual partner..." Laughs to himself.
-When I told him I am not sure if my partner still wants me in her team for the paper reading.

"Here let me show you. If you sweep in parallel from x-axis, this polo mint will look like it's colliding with this object. But iterate the sweep through all 3 axis and you will realise it was just visual occlusion... Take polo at own risk. Hehe." Pops a mint.

He does all the yar and says idea as "ide" like a typical german guy.

Common mathematical pdf

Ha... I was going scanning for k-means algorithm and stumbled on this guy's site.

Very very nice. He's more into data mining so his algorithms' mostly on clustering and search.

http://www.autonlab.org/tutorials/index.html

Also like his humour:

Primary goal in life: Occasion to use the phrase: "Let me through---I'm a Computer Scientist!"

Monday, March 16, 2009

The best way to understand

... is immersion.


Either by reading or obsessing over it.

Semi-implicit Euler method

The semi-implicit Euler method produces an approximate discrete solution by iterating

v_{n+1} = v_n + g(t_n, x_n) \, \Delta t \quad

x_{n+1} = x_n + f(t_n, v_{n+1}) \, \Delta t \quad

where Δt is the time step and t_n = t_0 + n\,\Delta t is the time after n steps.

The difference with the standard Euler method is that the semi-implicit Euler method uses vn + 1 in the equation for xn + 1, while the Euler method uses vn.

The semi-implicit Euler is a first-order integrator, just as the standard Euler method. This means that it commits a global error of the order of Δt. However, the semi-implicit Euler method is a symplectic integrator, unlike the standard method. As a consequence, the semi-implicit Euler method almost conserves the energy (when the Hamiltonian is time-independent). Often, the energy increases steadily when the standard Euler method is applied, making it far less accurate.


From wikipedia: http://en.wikipedia.org/wiki/Symplectic_Euler_method

3GPP Specifications Numbering

http://www.3gpp.org/specification-numbering

Sunday, March 15, 2009

Friday, March 13, 2009

Sony Vegas wins hands down.

Lovely!

However, I just realised our happy dancing music was quite crap and turns out to be actually creepy. SO I've replace it with:



More on:

http://movie-tv-reviews.blogspot.com/


I love being asian. Look no further than any asian female music and it's all kawaii!!

Sony Vegas vs blender

Now in my impatient attempt to edit my animation short, I want to use something clever but intuitive (overated word these days).

How I wanted to use blender. I mean wow... blender is opensource and includes non-linear editting? I am impressed... But using it is a bitch! I tried following the instructions below... Too complicated for my brain to adhere.

http://eugenia.gnomefiles.org/2008/04/20/video-editing-with-blender/


So gotten a trial of Sony Vegas 7 (unfortunate eh? Since I am still on Windows 2000). Let's see who will win.

Thursday, March 12, 2009

Importing AVI to iMovie

This animation project has given me a thousand and one "a-har" moments, I've stopped being perplexed.

SO how??? Here I am with scene 1 - 5 ready to for audio editing and the idiot just won't add the clips!

Turns out I will need to convert it to an older avi version for iMovie to recognise and import properly... Wokay...

Follow this instructions: http://www.helium.com/items/1255708-how-to-convert-video-for-imovie

Ok, the above doesn't work. And MPG2 video that's muxed will not import into iMovies either. WHaaaaaaaaaaaaat?

http://support.apple.com/kb/HT1372


But I should use expert settings when exporting the movie:

http://forums.macrumors.com/showthread.php?t=302197


I've totally given up on using iMovie now....

Tuesday, March 10, 2009

Creating dust particles?

Oh... dust particles... how you eluded me....

The steps should be:
Create curve.
Particles --> Create emitter.

Then have fun from there onwards... But oh well...

http://forums.creativecow.net/archivethread/2/761053

http://www.highend3d.com/boards/index.php?showtopic=236247

http://forums.cgsociety.org/archive/index.php/t-416001.html

http://www.swinburne.edu.au/design/tutorials/P-maya/T-Maya-Dynamics-Transforming-objects-using-magic-star-dust-particles/ID-119/

This swinburne institution is really something... but the name... aiyo....

Sunday, March 8, 2009

3D text in Maya

We wanted an end credit ala Pixar. 3D words, and our protagonist messing/playing with it.

So we had to import the lettering from either Photoshop or Illustrator. We went with Photoshop as described in the tutorial below:
http://en.9jcg.com/comm_pages/blog_content-art-64.htm

Besides that, we also need to extrude the text. We've used Surfaces: Surfaces--> Loft and Surfaces--> Planar. Then group the each letter together.

However, from the same author, there's another way of doing it:

http://www.youtube.com/watch?v=JJwNOOmkZuU