35
Copyright © CISST ERC, 2001 Essential Math for CIS Part 2: Transformations and Frames of Reference Gabor Fichtinger, PhD Associate Research Professor of Computer Science, Mechanical Engineering and Radiology NSF-Funded Engineering Research Center for Computer- Integrated Surgical Systems and Technology, Johns Hopkins University

Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Embed Size (px)

Citation preview

Page 1: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Essential Math for CISPart 2: Transformations and

Frames of Reference

Gabor Fichtinger, PhD

Associate Research Professor of Computer Science, Mechanical Engineering and Radiology

NSF-Funded Engineering Research Center for Computer-Integrated Surgical Systems and Technology,

Johns Hopkins University

Page 2: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Matrices

{⎥⎥⎥

⎢⎢⎢

⎡=

×222120

121110

020100

33 aaaaaaaaa

A

⎥⎥⎥

⎢⎢⎢

⎡=

100010001

:Identity 3I

⎥⎦

⎤⎢⎣

⎡++++

=⎥⎦

⎤⎢⎣

⎡⎥⎦

⎤⎢⎣

⎡=

≠=

1111011010110010

1101010010010000

1110

0100

1110

0100

********

C

, :Product

babababababababa

bbbb

aaaa

ABBAC

An ordered table of numbers (or sub-tables)

Rows

columns

Page 3: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Matrix Addition (+)

Properties:1. Closed result is always a matrix2. CommutativeA+B = B+A3. Associative (A+B)+C = A+(B+C)4. Identity A+0 = A (null matrix)5. Inverse A+A-=0 (negated matrix)

a cb d

x uy v

a+x c+ub+y d+v+ =

1 52 6

0 -21 -7

1 33 -1+ =

Example:

Definition:

Page 4: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Matrix Multiplication (*)

Properties:1. Closed result is always a matrix2. NOT Commutative A*B != B*A3. Associative (A*B)*C = A*(B*C)4. Identity A*I = A (identity matrix)5. Inverse A*A-=I (difficult to obtain!)

a cb d

x uy v

ax+cy au+cvbx+dy bu+dv* =

1 52 6

0 -21 -7

5 -376 -46+ =

Example:

Definition:

Distributive from either side(A+B)C = AC + BCC(A+B) = CA + CB

Page 5: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Vector is a special matrix

⎥⎦

⎤⎢⎣

⎡=

21

1v

v=[x,y,z] row vector, 1x3 matrix

column vector, 2x1 matrix

Examples:

Page 6: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Vector addition: just like adding matrices

a cb d

x uy v

a+x c+ub+y d+v+ =

Column vector

a cb d

x uy v

a+x c+ub+y d+v+ =

Row vector

Page 7: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

⎥⎦

⎤⎢⎣

⎡++

=11

11

dycxbyax

⎥⎦

⎤⎢⎣

⎡++

=11

11

dycxbyax

Vector* Matrix Multiplication: just like multiplying matrices

⎥⎦

⎤⎢⎣

⎡=

dcba

M

Result is a new row vector

Row vector on the leftv1 = [x1,y1]

v2 = v1M

⎥⎦

⎤⎢⎣

⎡⎥⎦

⎤⎢⎣

⎡=

1

1

yx

dcba

[x1,y1] =v2 = [ ],

Page 8: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Matrix*Vector Multiplication: just like multiplying matrices

⎥⎦

⎤⎢⎣

⎡=

1

11 y

xv

⎥⎦

⎤⎢⎣

⎡=

dcba

M

12 Mvv =

⎥⎦

⎤⎢⎣

⎡⎥⎦

⎤⎢⎣

⎡=

1

1

yx

dcba

⎥⎦

⎤⎢⎣

⎡++

=11

11

dycxbyax

Result is a new column vector

Column vector on the right

Page 9: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Matrix*Vector Multiplication(example)

⎥⎦

⎤⎢⎣

⎡=

21

1v

⎥⎦

⎤⎢⎣

⎡=

3215

M

12 Mvv =

⎥⎦

⎤⎢⎣

⎡⎥⎦

⎤⎢⎣

⎡=

21

3215

⎥⎦

⎤⎢⎣

⎡=⎥

⎤⎢⎣

⎡++

=87

2*31*22*11*5

Page 10: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Matrices as transformations

⎥⎦

⎤⎢⎣

⎡=

1

11 y

xv

⎥⎦

⎤⎢⎣

⎡=

dcba

M

12 Mvv =

y

x

v1 v2

Matrix-vector multiplication creates a new vector.New vector means new location in space.If all points of an object is multiplied by a matrix,then the whole object assumes a new position (and may benew shape and size, too). This is called transformation.

Page 11: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Matrices as transformations (examples)

⎥⎦

⎤⎢⎣

⎡=

1011

M 12 Mvv =

y

x

Transform 4 points [0,0], [1,0],[1,1],[0,1] using the matrix M.

1

1

y

1

1

⎥⎦

⎤⎢⎣

⎡=⎥

⎤⎢⎣

⎡=

00

,00

21 vv ⎥⎦

⎤⎢⎣

⎡=⎥

⎤⎢⎣

⎡=

01

,01

21 vv

v2

v1

⎥⎦

⎤⎢⎣

⎡=⎥

⎤⎢⎣

⎡=

12

,11

21 vv ⎥⎦

⎤⎢⎣

⎡=⎥

⎤⎢⎣

⎡=

11

,10

21 vv

Page 12: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Scaling

⎥⎦

⎤⎢⎣

⎡=

21

1v

⎥⎦

⎤⎢⎣

⎡=

2005

S

⎥⎦

⎤⎢⎣

⎡⎥⎦

⎤⎢⎣

⎡=

21

3005

⎥⎦

⎤⎢⎣

⎡=⎥

⎤⎢⎣

⎡++

=65

2*31*02*01*5

sx 00 sy

S =1/sx 00 1/syS-1 = S * S-1 = I

sx 0 0 0 sy 0 0 0 sz

S = 3D scaling matrix

12 vv S= S

Page 13: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Rotation

y

x

α v1

v2

v2 v1Rα=

v1 v2R-α=

Page 14: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Rotation Matrix

α

β

v = v(x,y) and |v| = 1

u and |u| = 1

cos(α + β)sin(α + β)

cos(α) cos(β) – sin(α) sin(β)sin(α) cos(β) + cos(α) sin(β)= =

x = cos(β)

y=sin(β)

=_u

cos(α) x – sin(α) ysin(α) x + cos(α) y

cos(α) – sin(α)sin(α) cos(α)= x

y

cos(α) –sin(α)sin(α) cos(α)=

_v

yx

Page 15: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Inverse of Rotation Matrix

cos(α) –sin(α)sin(α) cos(α)= R-α

cos(- α) –sin(- α)sin(- α) cos(- α)=

Rα-1 = R-α R α * R-α = IThe proof:

R(α+β+γ) = Rα R β Rχ

Series of Rotations

cos(α) sin(α)-sin(α) cos(α)

=

=R-α

Page 16: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

3D Rotation Matrices

Rαcos(α) –sin(α) 0sin(α) cos(α) 00 0 1

=

Rotation by α around z axis

When applied on vector v1, it does not change z coordinate. Try it!

v2 = Rα v1

Rotation around all axes

Page 17: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Rotation Matrix: example

12

601 2/12/32/32/1,

02

60,θ

Rvv

Rv

=

⎥⎦

⎤⎢⎣

⎡ −=⎥

⎤⎢⎣

⎡==

Page 18: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Passage from reference system to another

Frame a

Frame b

pa in Fa

pb in Fb

α

_t

(1) scale, (2) rotate, and (3) translate to go from Fa to Fb

pb = RSpa + t

Page 19: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Change of reference systems backwards (inverse transform)

pb – t = Rspa //left multiply by R-1

S-1R-1(pb – t) = pa

Slight problem: mixes translation vector with matrices…Solution: make t translation vector appear as matrix T in multiplications. Then the equations will read as:

pb = (T(R(Spa)))

pb = RSpa + t //subtract t

R-1 (pb – t) = Spa //left multiply by S-1

Page 20: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Introduce 4x4 Translation Matrix

1 0 0 dx 0 1 0 dy0 0 1 dz0 0 0 1

=T

=Tv=

xyz1

v= Padding with 1 (If I padded with 0then inverse would not exist!)

1 0 0 dx 0 1 0 dy0 0 1 dz0 0 0 1

xyz1

x+dx y+dy z+dz 1

Problem: rotation and scaling matrices must also be padded,so that we can multiply all 4x4 matrices.

Page 21: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Homogeneous Matrices and Translation Vector

Rαcos(a) –sin(a) 0 0sin(a) cos(a) 0 00 0 1 00 0 0 1

=

Rotation matrix by α around z axis

S sx 0 0 00 sy 0 00 0 sz 00 0 0 1

=

Scaling matrix

1 0 0 dx 0 1 0 dy0 0 1 dz0 0 0 1

T =

Translation matrix

xyz1

v= Padding all vectors with 1

pb = (T(R(Spa)))

Page 22: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Series of transformations

Series of transformationsCBAp=q //Apply A,B, then C on p(C (B (Ap))) = q //use associative property

Inverse transformation:Ap=q //apply A on pA-1Ap = A-1q //mult both sides from left by A-1

p=A-1q //because A-1A=I

Inverse of series of transformationsCBAp=q //Apply A,B, then C on pA-1B-1C-1q=p //multiply by inverse from left

A B Cp q p q

A-1 B-1

C-1

forward inverse

Page 23: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Inverse of coordinate transformations

pb = TRSpa

S-1R-1T-1pb= pa

Multiply from the left by T-1

T-1 pb = RSpa

Multiply from the left by R-1

R-1T-1 pb = Spa

Multiply from the left by S-1

Page 24: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Reference frame transformations

b

pb = T*R*S* pa

pb = Fbapa

Fba is often called frame transformation or shortly frame

a

pb

Fba pa

Page 25: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Series of reference frame transformation

bc

Fba

Fcb

Most real systems involve complicated series of frames, where we traverse from frame to frame…

a

pc = FcbFbapa

Fca

pc

Fca pa

All frames must be known: some of them are measured/calculated during the procedure, some of them are pre-operatively known through “calibration”.

Page 26: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Example: Robot-Assisted Ultrasound-Guided Liver Surgery

R. Taylor, G. Fichtinger, C. Burdette, M. Choti

LARS ROBOT

Ultrasound System

Biopsy needle

JHU 5-DOF needle driving robot

JHU volume visualization and planning display

Credit: Emad Boctor, doctoral student,

Page 27: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Handle Robot

US

Tracker

Target picked in US

FHU

FTH

FRT

pR = FRTFTHFHUpU

Example cont’d: Some frames in the tracked dual-arm robot system

Page 28: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Example: CT-guided Needle Placement with RobotG. Fichtinger, R. Taylor, D. Stoianovici, et al.

Screen of the surgical planning and control workstation

Kavoussi & Stoianovici

Kidney biopsy

Patient in the scanner with robot

Digitalimages

Planning & control computer

Patient

Surgeon

CT Scanner

Robot

Coordinates

Page 29: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Example cont’d: Frames

FDC

FRDRobot

CT image

pCpR = FRD FDC pC

pRFD

FC

FRNeedle driver

Page 30: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

4-joint serial robot

p4= F43F32 F21F10 p0

F0

F1

F2

F3

F4

Example: Multi-Joint Serial Robots

p0

p4

Page 31: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

• M = (M1,M2,…Mi) tracker readings• P = F(M, C) function to get tool tip position from tracker readings, where C = (c1,c2,c3…)

is set of constants• How to get these constants? -- CALIBRATION

Example: Pointer Calibration

M2

M1

M3

Tracker

P

F(M, c)C

Page 32: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

• Determine pt translation between tip and marker coordinate system• Pivot around a fixed point

Generic Pivot Calibration

pt translation

marker coordinatesystem

tip coordinatesystem

M2

M1

M3

Page 33: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Pivot and measure many times…

• pt vector is constant if looking from marker coordinate system• Pivot point is constant if looking from the tracker base• M1,M2,M3… Mn are reported by tracker• Fi (Ri,pi) is easily calculated by software package• Fi (Ri,pi) takes the pt vector to the pivot point• Fi*pt =pp• First rotation by Ri, then translation by pi• Ri*pt + pi = pp• Unknowns: Pt and Pp• Two poses are sufficient to calculate Pt• Take many poses (i.e. redundancy) to reduce errors!!!

Pt

Pp

Fi (Ri,pi)

marker coordinatesystem

Tracker

Page 34: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Solve the math…(1) Ri*pt + pi = pp

(2) Rj*pt + pj = pp subtract and 1 and 2---------------------------------

Ri*pt - Rj*pt + pi - pj = 0(Ri- Rj)pt + pi - pj = 0(Ri- Rj)pt = -(pi – pj)

pt = - (Ri- Rj)-1(pi – pj)

Repeat the above on all pairs of measurements and then take the average pt

Page 35: Essential Math for CIS Part 2: Transformations and Frames of · PDF file10 00 11 10 10 01 11 11 00 00 01 10 00 01 01 11 10 11 00 01 10 11 00 01 * * * * * * * * C Product : , a b a

Copyright © CISST ERC, 2001

Now how to use the pointer

pt translation

marker coordinatesystem

tip coordinatesystem

M2

M1

M3

• Read M1,M2,M3… Mn are reported by tracker• Fi (Ri,pi) is easily calculated by software package• Plug pt into Ri*pt + pi = pp• If possible, take multiple measurements, reject outliers, and average the rest