Sunday, April 12, 2009

Music to listen to while you're studying

And perhaps the neighbours are noisy and you needed to cancel them out, or you just don't want to fall asleep.

How to categorise that?
1. Not too slow or soft or soothing that you might fall asleep.
2. Nothing and I mean nothing that can distract you, (so you should not listen to any songs in languages that you understand or can sing along to).

These are the choices given by some people:

1. Brian Eno - Music for Airports

2. Boards of Canada -- > ooh I've been meaning to get their music.

3. Sigur Ros - They make me trip. I can't use this for studying.

4. Chicane - Ooh nice... must get their music.

5. Kaskade - Nice nice... Must get them too!!

6. Cirque du Soleil - oooooo?



Someone suggested these:
  • Sigur Rós - any of their albums are great, especially their b-sides/EPs
  • Mogwai
  • Boards of Canada as mentioned
  • Haibane Renmei - "Hanenone" - excellent soundtrack to an excellent anime
  • Any of the Final Fantasy Piano Collections (well, except IV and V, they're pretty unimaginative)
  • Film scores (particular favorites of mine are "Final Fantasy: The Spirits Within," "Crouching Tiger, Hidden Dragon," "Hero," "American Beauty," and "Crash")
I must say, Mac users are way cooler.... Their suggestions are good!! http://forums.macrumors.com/showthread.php?t=249125



http://www.amazon.com/Music-Listen-While-Youre-Studying/lm/CTMB4VPEAPU9


http://www.amazon.com/Trippy-chill-stoner-music/lm/1VQIBDTM9AQMU

My personal all time favourite has to be JAM and Yuki Isoya (solo effort), Shiina Ringo (given to me by accident). When I hear JAM, I just want to start Xcode or pick up my notes.

Animation: Classical Framework

In the classical animation framework, they're 4 models; 2 stimulus and 2 response.

Stimulus
1. Environment Model: Animation's environment where static and dynamic objects are created. Includes modeling and rendering.

2. Perception Model: Techniques of "perception" by the characters. Information detected by the character's sensory capabilities.
i. zonal approach
ii. sensory approach
iii. synthetic vision approach.

Response
3. Behavioural Model: Behavioural techniques provide the characters with ability to autonomous activity with its own decision. This can either be reactive or driven by internal desire/experiences (not so much Artificial Intelligence, but more Artificial Life....? )
i. Rule-based approach
ii. Network approach
iii. Artificial Intelligence approach
iv. Mathematical approach

4. Motor Model: Movement techniques - to move & animate the characters. Not related to planning of movement, that is done in behavioural model.
i. Basic dynamic approach
ii. Procedural approach


More references:
http://www.red3d.com/cwr/boids/

Wednesday, April 8, 2009

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