Saturday, September 4, 2010

Rotation Matrix 2

http://rip94550.wordpress.com/2008/05/20/axis-and-angle-of-rotation/

http://en.wikipedia.org/wiki/Rotation_representation_%28mathematics%29

http://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula

Rotation Matrix

A rotation matrix is a matrix which, when multiplied by the vector representing a point, has the effect of rotating that point around the origin. A rotation around the origin is a linear geometrical transformation.
In general, any orthogonal matrix with a determinant of 1 is a rotation matrix.
In two dimensions, the 2×2 matrix that rotates a 2D vector around the origin by an angle of θ is:
R(θ)

    | cos(θ) -sin(θ) |
  = |                 |
    | sin(θ)  cos(θ) |
(Note: the matrix should be multiplied from the right by a column vector.)
As with any other linear geometrical transformation, rotations may be composed by multiplying the matricies (see matrix multiplication) that represent them.
Rotations in 2D commute. That is, the rotation of a column vector v by θ1 and followed by the rotation by θ2 has the same effect as a single rotation by θ12. Of course, this seems obvious in 2D. In matrix form, this means that:
R2)(R1)v) = R12)v
The vectors forming the columns of the matrix are what the unit vectors along the axes are transformed to. In three dimensions, rotation matricies are more complex. It's easiest to start with rotations around the three coordinate axes:
Rx(θ)


    | 1    0       0    |
  = | 0 cos(θ) -sin(θ) |
    | 0 sin(θ)  cos(θ) |
Ry(θ)

    |  cos(θ) 0 sin(θ) |
  = |     0    1    0   |
    | -sin(θ) 0 cos(θ) |
Rz(θ)

    | cos(θ) -sin(θ) 0 |
  = | sin(θ)  cos(θ) 0 |
    |    0       0    1 |
Here, Rx(θ) represents a rotation of θ around the x axis. Rotation about an arbitrary axis u is given by the following formula:
Ru(θ)


  = uuT + cos(θ) (I - uuT) + sin(θ) cross(u)
where u = [ ux uy uz ]T is a unit column vector and cross(u) is the cross product operator matrix. In addition, I is the 3×3 identity matrix, and the 3×3 matrix uuT is a projection matrix. Expanding the formula into a matrix, we get
|  uxuxvθ+cθ  uxuyvθ-uzsθ uxuzvθ+uysθ |
  = | uyuxvθ+uzsθ  uyuyvθ+cθ  uyuzvθ-uxsθ |
    | uzuxvθ-uysθ uzuyvθ+uxsθ  uzuzvθ+cθ  |
where vθ = 1-cos(θ), cθ = cos(θ) and sθ = sin(θ). Given an rotation matrix, you can extract the axis u and angle θ of the rotation that it represents. Suppose the rotation matrix R is given by
R
    | r11 r12 r13 |
  = | r21 r22 r23 |
    | r31 r32 r33 |
Then we can calculate
cosθ = ( r11 + r22 + r33 - 1) / 2
sinθ = ( (r21-r12)2 + (r13-r31)2 + (r32-r23)2 )1/2 / 2
ux = (r21-r12) / (2sinθ)
uy = (r13-r31) / (2sinθ)
uz = (r32-r23) / (2sinθ)
Note that u is undefined if θ is a multiple of 2π. That would mean that there actually is no rotation. Rotations in 3D do not commute. For example, a 90° rotation around the x axis followed by a 90° rotation around the z axis does not have the same effect as a 90° rotation around the z axis followed by a 90° rotation around the x axis.

Tuesday, August 31, 2010

Using vpnc for cisco vpn (pcf file)

  1. install vpnc with synaptic
  2. open terminal, type sudo pico /etc/vpnc/default.conf
    An example of default.conf:
    IPSec gateway ip.to.vpn.server
    IPSec ID VPNservergroupname
    IPSec obfuscated secret cryptedpasswordfrompcffile
    Xauth interactive
  3. ctrl+x
  4. y
  5. sudo vpnc-connect
  6. enter your vpn user name, enter
  7. enter pin code or what ever kind of system you have, enter. Now you're inside vpn tunnel
  8. after you're done, sudo vpnc-disconnect

Monday, August 16, 2010

Running Hardware Driver as sudo on xubuntu

 gksu -D /usr/share/applications/jockey-gtk.desktop /usr/bin/jockey-gtk

Wednesday, April 22, 2009

Building on 64 bit Linux system

If ./configure can't guess the right system try run a compiler like gcc:

> gcc -dumpmachine
x86_64-redhat-linux

If make gives error:
"xxx.so: could not read symbols: File in wrong format"

Maybe wrong library is loaded for compile:

./configure --target=x86_64-redhat-linux LDFLAGS=-L/usr/lib64

See http://www.c3.lanl.gov/~pakin/software/conceptual/userguide/Could-not-read-symbols.html

Saturday, September 20, 2008

ViEmu commands

If you use Ctrl-V or Ctrl-Q to enter visual block mode, and select a range, you can key in any operator directly and it will be applied to the range. Here are some samples:

d Deletes the block (and copies it to the default register for later pasting)
y Yanks the block (copies to the default register)
gU Makes all characters uppercase
gu Makes all characters lowercase
~ Toggles the case of all characters
c Change - deletes the region, enters insert mode, and then repeats the string input in all lines (if we were initially in block visual mode)
etc...

The docs have a complete list of ViEmu-supported operators.

'x' also works to delete a visual region.

Thursday, August 7, 2008

pthreads

To compile C++ code with pthread library on Linux

g++ --pthread main.cpp