Top Banner
autorob.github.io Linear Algebra Refresher UM EECS 398/598 - autorob.github.io
78

Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Aug 18, 2018

Download

Documents

donhu
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

autorob.github.io

Linear Algebra Refresher

UM EECS 398/598 - autorob.github.io

Page 2: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

ObjectiveGoal: Given the structure of a robot arm, compute – Forward kinematics: inferring the pose of the end-effector, given the state (angle) of each joint. – Inverse kinematics: inferring the joint states necessary to reach a desired end-effector pose.

But, we need to start with a linear algebra refresher

UM EECS 398/598 - autorob.github.io

Page 3: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Reset: Kinematics

• State comprised of degrees-of-freedom (DOFs)

• DOFs describe translation and rotation axes of system

��

��

��

��

334 15. Physical Simulation

!"#$%&'"(!"#$%&'"( )*&+&('$+,-.'".#)*&+&('$+,-.'".#

! "#$%&''&()*+)%,-,()*.(+)/,0&123,4'

5 6,-,()*.(,&')4.00&43&()*+)7.,03'

5 892%243&%)$.'&)(&:,0&()*+)%.323,.0)

.:)7.,03'

5 ;&43.%)!<3=)%&$%&'&03')$.'&

23)2)-,>&0),0'3203).:)3,1&

!"#$%&'"(!"#$%&'"( )*&+&('$+,-.'".#)*&+&('$+,-.'".#

! "#$%&''&()*+)%,-,()*.(+)/,0&123,4'

5 6,-,()*.(,&')4.00&43&()*+)7.,03'

5 892%243&%)$.'&)(&:,0&()*+)%.323,.0)

.:)7.,03'

5 ;&43.%)!<3=)%&$%&'&03')$.'&

23)2)-,>&0),0'3203).:)3,1&Figure 15.11. Humanoid characters are composed of rigid bodies connected byjoints. Rotations about joints allow the character to pose in a variety of configurations(top). The character’s kinematics define degrees-of-freedom, specifying how jointscan rotate. Early research into physics-based animation by Hodgins et al. useddynamics that explicitly held the bones of humanoid character together (bottomleft). However, most dynamics engines used in modern games have independentrigid bodies that are held together by constraints, similar to how magnetism holdsGeomag structures together (bottom right).

a Lagrangian formulation24 or a Newton-Euler formulation25.Implicitly constrained dynamics, in contrast, does not explicitly enforce

constraints. Instead, constraints are expressed as implicit functions on thestate of the rigid bodies. Such constraints are satisfied when its functionevaluates to zero. The states where a constraint function evaluates tozero form an equilibrium region of state space. As states move furtherfrom this equilibrium region, their values, as evaluated by the constraintfunction, increase. Forces are generated from these constraint functions by

24The temporal derivative of the partial derivative of kinetic minus potential energywith respect to each generalized coordinate.

25At each time step, velocities and accelerations are propagated “forward” from theroot to outboard bodies and corrected “backward” to the root with forces and torquesbackward.

UM EECS 398/598 - autorob.github.io

Page 4: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

DOFs and Coordinate Spaces

• Each body has its own frame

• Joints connect two links (rigid bodies)

• e.g., hinge, prismatic, ball-socket

• A motor exerts force on a DOF axis

• Matrix transformations used to relate coordinate systems of bodies and joints

• Spatial geometry attached to each link, but does not affect the body’s coordinate frame

frames

UM EECS 398/598 - autorob.github.io

hinge

prismatic

ball

Linear algebra

Page 5: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Notation

UM EECS 398/598 - autorob.github.io

Page 6: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Planar 2-link Arm

UM EECS 398/598 - autorob.github.io

Page 7: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

SCARA Arm Selective Compliance Assembly Robot Arm

UM EECS 398/598 - autorob.github.iohttps://youtu.be/7X5Nmk85kQo

Page 8: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Motoman SK16

UM EECS 398/598 - autorob.github.iohttps://youtu.be/Wj17z5iSzEQ

Page 9: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Biped Hopper (MIT Leg Lab)

UM EECS 398/598 - autorob.github.iohttp://www.ai.mit.edu/projects/leglab/robots/robots.html

Page 10: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Big Dog (BDI)

UM EECS 398/598 - autorob.github.io

Page 11: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Quad Rotor Helicopter

Safety is most importantUM EECS 398/598 - autorob.github.iohttps://youtu.be/0mDiH_ajStQ

Page 12: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

ETH-Zurichhttps://www.youtube.com/watch?v=XxFZ-VStApo UM EECS 398/598 - autorob.github.io

Page 13: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

PR2

How to express kinematics as the state of an articulated system? We need some math first.

UM EECS 398/598 - autorob.github.io

Page 14: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

UM EECS 398/598 - autorob.github.io

What does algebra provide beyond arithmetic?

Page 15: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

• Arithmetic applies to addition and multiplication of known numbers

• Algebra includes abstractions as variables

• Unknown numbers or expressions that can take on many values

• An algebra supports addition and multiplication of variables and numbers.

• For example, from: x2 = 5x – 6 • we get: (x – 2)(x – 3) = 0 • and thus: x = 2 or x = 3.

UM EECS 398/598 - autorob.github.io

Page 16: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Many important complex systems are described by collections of linear equations. UM EECS 398/598 - autorob.github.io

What does is linear algebra provide beyond algebra?

Page 17: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Many important complex systems are described by collections of linear equations. UM EECS 398/598 - autorob.github.io

• Describes spaces where vector operations are closed with respect to:

• addition

• scalar multiplication

Page 18: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Many important complex systems are described by collections of linear equations. UM EECS 398/598 - autorob.github.io

• Describes spaces where vector operations are closed with respect to:

• addition

• scalar multiplication

Page 19: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Arithmetic Algebra Linear Algebra

Addition

Scalarmultiplication

UM EECS 398/598 - autorob.github.io

Abstraction

Page 20: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Many important complex systems are described by collections of linear equations.

• Many important complex systems are described by collections of linear equations.

• An algebra of scalars, vectors, and matrices helps us work with these systems, keeping track of the complexity.

• Manipulate groups of known and unknown parameters, just like manipulating numbers.

• Linear algebra is essential for representing frames of reference, rotation, translation, and general 3D homogeneous transforms.

UM EECS 398/598 - autorob.github.io

Page 21: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Linear Algebra (Rough) Breakdown• Geometry of Linear Algebra

• Vectors, matrices, basic operations, lines, planes, homogeneous coordinates, transformations

• Solving Linear Systems

• Gaussian Elimination, LU and Cholesky decomposition, over-determined systems, calculus and linear algebra, non-linear least squares, regression

• The Spectral Story

• Eigensystems, singular value decomposition, principle component analysis, spectral clustering

primary focus for AutoRob

needed for iterative IK

UM EECS 398/598 - autorob.github.io

Page 22: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

is solved by

UM EECS 398/598 - autorob.github.io

Page 23: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

=

is solved by

linear systems expressed in general matrix form as

UM EECS 398/598 - autorob.github.io

Page 24: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

=

vector of N unknowns to be found

M linear equations

each equation yields a hyperplane in N-D

UM EECS 398/598 - autorob.github.io

Page 25: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

=

vector of N unknowns to be found

M linear equations

If #unknowns > #equations, underdetermined system, usually with infinite solutions

If #unknowns < #equations, overdetermined system usually with no solutions

If #unknowns = #equations, usually has a unique solution

each equation yields a hyperplane in N-D

UM EECS 398/598 - autorob.github.io

Page 26: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

=

vector of N unknowns to be found

M linear equations

If #unknowns > #equations, underdetermined system, usually with infinite solutions

If #unknowns < #equations, overdetermined system, usually with no solutions

If #unknowns = #equations, usually has a unique solution

each equation yields a hyperplane in N-D

UM EECS 398/598 - autorob.github.io

Page 27: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

2D Exampleonly single point satisfies both lines

UM EECS 398/598 - autorob.github.io

Page 28: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

2D Example

any point on the line satisfies

only single point satisfies both lines no point satisfies

all three lines

UM EECS 398/598 - autorob.github.io

Page 29: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

3D Example

Each equation yields a 2D plane

in 3D space

A single point satisfies all equations

UM EECS 398/598 - autorob.github.io

Page 30: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

3D Example

How many solutions?

UM EECS 398/598 - autorob.github.io

Page 31: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Coordinate Spaces (2D)• Two coordinate frames o0x0y0

and o1x1y1, and a point p.

• The location of point p can be described with respect to either coordinate frame: p0 = [5, 6]T and p1 = [-2.8, 4.2]T.

• The vector v1 is direction and magnitude from o0 to p, and v2 is from o1 to p.

UM EECS 398/598 - autorob.github.io

Page 32: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Coordinate Spaces (2D)• Point p has a location.

• Vectors v1 and v2 have directions and magnitudes.

• v10 = [5, 6]T

• v11 = [7.77, 0.8]T

• v20 = [-5.1, 1]T

• v21 = [-2.8, 4.2]T Note: Vectors can only be added when they are in the same coordinate frame.

vector 1 in frame 0

vector 1 in frame 1

vector 2 in frame 0

vector 2 in frame 1

UM EECS 398/598 - autorob.github.io

Page 33: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Coordinate Spaces (2D)• Point p has a location.

• Vectors v1 and v2 have directions and magnitudes.

• v10 = [5, 6]T

• v11 = [7.77, 0.8]T

• v20 = [-5.1, 1]T

• v21 = [-2.8, 4.2]T Note: Vectors can only be added when they are in the same coordinate frame.UM EECS 398/598 - autorob.github.io

Page 34: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Vectors and Matrices

N-dimensional vector M-by-N matrix

UM EECS 398/598 - autorob.github.io

Page 35: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

2D Vector

    var a = [ [2],              [3] ];

A vector is a motion in space

UM EECS 398/598 - autorob.github.io

Page 36: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

3D Vector

    var a = [ [ax],              [ay],              [az] ];

UM EECS 398/598 - autorob.github.io

Page 37: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Vector Addition and Subtraction

vector addition is order independent

vector addition visually

vector subtraction is additionwith negated vector

vector result

UM EECS 398/598 - autorob.github.io

Page 38: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Magnitude and Unit VectorThe magnitude of a vector is the square root of the sum of

squares of its components

A unit vector has a magnitude of one.Normalization scales a vector to unit length.

A vector can be multiplied by a scalar

UM EECS 398/598 - autorob.github.io

Page 39: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Dot Product

Measures the similarity in direction of two vectors

scalar result

UM EECS 398/598 - autorob.github.io

Page 40: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Projections

Scalar projection of one vector onto another

Vector projection

Dot products related to projections onto vectors.

UM EECS 398/598 - autorob.github.io

is unit length

Page 41: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Checkpoint

• What is the dot product of a vector with itself?

• the square of the vector length

• What is the dot product of two orthogonal vectors?

• 0

UM EECS 398/598 - autorob.github.io

Page 42: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Checkpoint

• What is the dot product of a vector with itself?

• the square of the vector magnitude

• What is the dot product of two orthogonal vectors?

• 0

UM EECS 398/598 - autorob.github.io

Page 43: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Checkpoint

• How many unit vectors are perpendicular to a 2D vector?

• 2 (positive and negative)

• How many unit vectors are perpendicular to a 3D vector?

• Infinite and lie in plane

UM EECS 398/598 - autorob.github.io

Page 44: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Checkpoint

• How many unit vectors are perpendicular to a 2D vector?

• 2 (positive and negative)

• How many unit vectors are perpendicular to a 3D vector?

• Infinite and lie in plane

UM EECS 398/598 - autorob.github.io

Page 45: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Given two vectors, how to compute a vector orthogonal to both?

UM EECS 398/598 - autorob.github.io

Page 46: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Cross Product

Results in new vector c orthogonal toboth original vectors a and b

Length of vector c is equal to area of parallelogram formed by a and b

Assumes a and b are in same frame

UM EECS 398/598 - autorob.github.io

Page 47: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Relating linear and angular velocity

angular velocity for rotation of p about vector k

vector to a point p

linear velocity of point p

r

v

k

p

UM EECS 398/598 - autorob.github.io

Page 48: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Matrices• A Matrix is a rectangular array of numbers

var mat = [ [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0],

[0, 0, 0, 1] ];

What is this matrix?

UM EECS 398/598 - autorob.github.io

Page 49: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Matrix-vector multiplication

UM EECS 398/598 - autorob.github.io

Page 50: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

For example

UM EECS 398/598 - autorob.github.io

Page 51: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

For example

UM EECS 398/598 - autorob.github.io

Page 52: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Matrix-vector multiplication (two interpretations)

1) Row story: dot product of each matrix row

2) Column story: linear combination of matrix columns

UM EECS 398/598 - autorob.github.io

Page 53: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Revisiting the cross product: Skew-symmetric matrices

A given 3D vector

can be expressed as a skew-symmetric matrix

such that the cross product with another vector is a matrix multiplication

UM EECS 398/598 - autorob.github.io

Page 54: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Linear SystemsWe can use a variable instead of a vector, which gives us a linear system.

Enabling the general form:

UM EECS 398/598 - autorob.github.io

Page 55: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Matrices• A Matrix is a rectangular array of numbers

var mat = [ [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0],

[0, 0, 0, 1] ];

var mat = [ [1, 0, 0, tx], [0, 1, 0, ty], [0, 0, 1, tz],

[0, 0, 0, 1] ];

What is this matrix?

UM EECS 398/598 - autorob.github.io

Page 56: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Translation matrix example

jsmat for Assignment 3

UM EECS 398/598 - autorob.github.io

Page 57: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Translation matrix example

jsmat for Assignment 3

UM EECS 398/598 - autorob.github.io

Page 58: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Matrix Geometry: Column Story

UM EECS 398/598 - autorob.github.io

Page 59: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Matrix Multiplication• Scalar Multiplication

• Multiplication of two matrices

Each entry of product matrix AB is a dot product of a row of A with a column of B

UM EECS 398/598 - autorob.github.io

Page 60: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Matrix multiplication

Do this dot product for each row/column combination

AB

AB

row 3 of Acol 4 of B

Finger sweeping rule should be second nature! - Left finger sweeps left to right - Right finger sweeps top to bottom

UM EECS 398/598 - autorob.github.io

Page 61: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Matrix Multiplication Reminders

• Number of columns of A must match number of rows of B

• Multiplying a (MxK) matrix with a (KxN) matrix will produce an (MxN) matrix

• Matrix multiplication is not commutative: AB != BA

UM EECS 398/598 - autorob.github.io

Page 62: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Example

(1, 2, 3) • (7, 9, 11) = 1×7 + 2×9 + 3×11 = 58

(1, 2, 3) • (8, 10, 12) = 1×8 + 2×10 + 3×12 = 64

(4, 5, 6) • (7, 9, 11) = 4×7 + 5×9 + 6×11 = 139

(4, 5, 6) • (8, 10, 12) = 4×8 + 5×10 + 6×12 = 154

UM EECS 398/598 - autorob.github.io

Page 63: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

For example

UM EECS 398/598 - autorob.github.io

Page 64: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

For example

UM EECS 398/598 - autorob.github.io

Page 65: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Checkpoint

• Which of the following matrix multiplications are valid?

UM EECS 398/598 - autorob.github.io

Page 66: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

UM EECS 398/598 - autorob.github.io

Page 67: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Notable Matrices and Operations• Matrix identity (I) causes no change: A = ImA = AIn

• Diagonal elements Aii = 1

• Off-diagonal elements Aij = 0, i≠j

• Matrix inverse (A-1): if AA-1 = A-1A = I

• Distributing matrix inverse: (AB)-1 = B-1A-1

• Matrix transpose (AT): a matrix’s reflection about its diagonal

• Distributing matrix transpose: (AB)T = BTAT

UM EECS 398/598 - autorob.github.io

Page 68: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Matrix Geometry: Row Story

UM EECS 398/598 - autorob.github.io

Page 69: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Solving linear systems

What would be the direct way to solve for x?

Invert A an multiply by b

Can this always be done?

Can we approximate the solution?

Pseudoinverse least-squares approximation

UM EECS 398/598 - autorob.github.io

Page 70: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Solving linear systems

What would be the direct way to solve for x?

Invert A and multiply by b

UM EECS 398/598 - autorob.github.io

Page 71: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Matrix rank and inversion

• Let A be a square n by n matrix. A is invertible if full rank and a matrix B exists such that

• Rank of a matrix A is the size of the largest collection of linearly independent columns of A

• A is invertible (nonsingular) if it has full rank

• Gaussian elimination can find matrix inverse

• Singular matrix cannot be inverted this way

UM EECS 398/598 - autorob.github.io

Page 72: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Solution by Decomposition• In real applications, inverse not computed to solve linear systems

• Efficiency, numerical precision, etc.

• Matrix decomposed into product of lower and upper triangular matrices

• LU decomposition

• Cholesky decomposition

• Permits finding solution by forward substitution followed by backward substitution

UM EECS 398/598 - autorob.github.io

Page 73: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Solving linear systems

What would be the direct way to solve for x?

Can this always be done?

Can we approximate the solution?

Pseudoinverse least-squares approximation

Invert A and multiply by b

UM EECS 398/598 - autorob.github.io

Page 74: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Solving linear systems

What would be the direct way to solve for x?

Can this always be done?

No. But, we can approximate. How?

Pseudoinverse least-squares approximation

Invert A and multiply by b

UM EECS 398/598 - autorob.github.io

Page 75: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Pseudoinverse

• For matrix A with dimensions N x M with full rank

• Find solution that minimizes squared error:

• Left pseudoinverse, for when N > M, (i.e., “tall”)

• Right pseudoinverse, for when N < M, (i.e., “wide”)

s.t.

s.t.

UM EECS 398/598 - autorob.github.io

Page 76: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Polynomial Regression• Given n data points as input-output (xi,yi), estimate parameters β of

best fitting m-order polynomial:

• Model in matrix form:

• each data point forms a row

• Solve for least squares best fit:

UM EECS 398/598 - autorob.github.io

Page 77: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Julien’s Demohttps://herojeanpierre.github.io/Least_Squared_Best_Fit/

Page 78: Linear Algebra Refresher - web.eecs.umich.eduweb.eecs.umich.edu/~ocj/courses/autorob/autorob_05_linear_refresh.pdf · But, we need to start with a linear algebra refresher UM EECS

Forward Kinematics

autorob.github.io

Next Class

UM EECS 398/598 - autorob.github.io