Skip to content

Get Euler angles from a rotation matrix

July 26, 2017
Matlab function:

function rho=fcn_EulerFromRotation(R)
% R is the rotation from body to world frame

% assume -pi/2<tht<pi/2

%R31=-sin(tht)
tht=-asin(R(3,1));

%R32=sin(phi)*cos(tht), R33=cos(phi)*cos(tht)
phi=atan2(R(3,2),R(3,3));

%R21=cos(tht)*sin(psi), R11=cos(tht)*cos(psi)
psi=atan2(R(2,1),R(1,1));

rho=[phi,tht,psi]';
Advertisements

matlab generate the same random number everytime

June 16, 2017

use the following command before the rand function, you will get the same random number everytime you run the m file.

rand(‘seed’, 0);

rand

Set latex font

June 12, 2017

The command is:

\renewcommand*\rmdefault{ptm} %ppl

if you want to understand the three letter word: ptm or ppl. Read the table III of this document: http://tug.ctan.org/macros/latex/required/psnfss/psnfss2e.pdf

Here is a good introduction:

https://www.tug.org/pracjourn/2006-1/schmidt/schmidt.pdf

Abbrivation

March 16, 2017

Theorem -> Thm.
Corollary -> Cor.
See https://en.wikipedia.org/wiki/List_of_mathematical_abbreviations

Chapter -> Chap.

see https://en.wikipedia.org/wiki/List_of_legal_abbreviations

 

Insert Youtube video to powerpoint

February 28, 2017

Keywords: youtube, video, PPT, powerpoint, starting time

  • First, go to youtube and find the video. Then click Share->Embed. You will get a code as below:

link1

  • Second, paste the code to word and modify it. Specify the starting and ending times as shown below.

link2

  • Third, go to PPT and click Insert->Video->Online Video->From a Video Embed Code (not the Youtube one). Copy and paste and nail it.

 

 

Bearing Laplacian: Matlab code

February 27, 2017

Bearing Laplacian is important in the area of bearing rigidity. Here is the matlab code to generate the bearing Laplacian of a given network. If the rank of the bearing Laplacian is equal to d*n-d-1, then the network is bearing rigid.

keywords: bearing rigidity, bearing Laplacian

clc;clear;close all
% positions of the nodes in the network
p_all=[0 0 0;
   0 1 0;
   -1 0 0;
   0 0 1]';
d=size(p_all,1); % dimension
n=size(p_all,2); % number of nodes
% The symmetric adjacent matrix
neighborMat=zeros(n,n);
neighborMat(1,2)=1;neighborMat(1,4)=1;
neighborMat(2,3)=1;
neighborMat(3,4)=1;
neighborMat=neighborMat+neighborMat';

% Calculate the bearing Laplacian L
L=zeros(d*n,d*n);
for i=1:n
    for j=1:n
        if neighborMat(i,j)~=0 && i~=j
            pi=p_all(:,i);
            pj=p_all(:,j);
            gij=(pj-pi)/norm(pj-pi);
            Pgij=eye(d)-gij*gij';
            L(d*(i-1)+1:d*(i-1)+d,d*(j-1)+1:d*(j-1)+d)=-Pgij;
            L(d*(i-1)+1:d*(i-1)+d,d*(i-1)+1:d*(i-1)+d)...
             =L(d*(i-1)+1:d*(i-1)+d,d*(i-1)+1:d*(i-1)+d)+Pgij;
        end
    end
end

% See if the rank of L is equal to d*n-d-1. If so, the network is bearing rigid
rank(L)-(d*n-d-1)

A special but useful orthogonal projection matrix

February 18, 2017

untitled

untitled

untitled

 

See details in the memo