Presentation is loading. Please wait.

Presentation is loading. Please wait.

Basic Math Review (you already know this stuff ...)

Similar presentations


Presentation on theme: "Basic Math Review (you already know this stuff ...)"— Presentation transcript:

1 Basic Math Review (you already know this stuff ...)
Robotics has a language and, as always in scientific matters, the language is MATH ... We’ll try to introduce this math “softly” ... as painless as we can ... What’s a function (1 slide) Some Trigonometric Functions (3 slides) Matrices and Determinants (5 slides – the robot moves in the 3D or R3 space ... ) Scalars and Vectors (1 slide) Coordinate Systems in 2D & 3D (2 slides) Vectors including Dot & Cross products (5 slides) Torque definition (1 slide) Quaternions (5 slides – in a way ... aw ... THIS IS NEW!!!) Groups, SO(3), SE(3) definitions (1 slide)

2 Functions … f(x) We are always taking about functions:
We call a function a quantity (the dependent variable) whose value depends on the value of another quantity (the independent variable) Several functions come to mind: y = 2x or f(x) = 2x + 3 y = x or f(x) = x y = sin x or f(x) = sin x y = x³ - 5x² or f(x) = x³ - 5x² y = log (x + 3) or f(x) = log(x + 3) Y = sin(x+2) or f(x) = sin(x+2) In all cases, the value of “y” is a “function of the value of x”. For the time being we want to “refresh” the trigonometric functions …`

3 The trigonometric functions we need to recall are the following:
sine, cosine & tangent + a few properties. Consider the right triangle shown below: sin a = b/c (opposite side over hypotenuse) cos a = a/c (adjacent side over hypotenuse) tan a = b/a = sin a /cos a sin² a + cos² a = 1 (Pythagorean Theorem) b Two most used relations: The projection of side c on the horizontal: a = c * cos a The projection of side c on the vertical: b = c * sin a c b = c sin a Also for any two angles j and q: sin (j + q) = sin j cos q + cos j sin q = s j c q + c j s q = s c + c s sin (j - q) = sin j cos q - cos j sin q cos (j + q) = cos j cos q - sin j sin q = c j c q - s j s q = c c - s s cos (j - q) = cos j cos q + sin j sin q If q = j then we have the functions of the double and half angle … a 90° a = c cos a

4 The trigonometric values and the angles, a way to remember:
degrees 30 45 60 90 180 270 360 radians /6 /4 /3 /2 2/3 2 sine 1/2 1/2 3/2 1 -1 cosine tangent 1/3 3   -/+  2 1 3 30° 60° 90° 1 45° 90° 2 IF YOU FEEL UNSURE ABOUT THESE LAST TWO SLIDES ASK QUESTIONS NOW!!!

5 The inverse trigonometric functions:
If we are given for example sin a = d, then the inverse function would be a = sin-1 (d) where the “-1” does not mean a negative exponent but just a “notation” for the inverse function and thus sin-1 (d) is not 1/sin(d). Other notations for this inverse function are “arcsin a” or simply “asin a”. Most programming languages use this last notation (with the letter “a” preceding the name of the trig function) to identify the inverse trigonometric functions. Therefore, we may encounter “acos a” or ”atan a” when programming the inverse trigonometric functions. EXAMPLES: Given: sin 30o = 0.5 then asin 0.5 = 30o. Also, tan 45o = 1, then atan 1 = 45o. In many cases the trig functions are expressed in “radians” instead of degrees and thus the two previous examples would read: Given: sin = 0.5 then asin 0.5 = (where = p/6 = 30 degrees). Also, tan = 1, then atan 1 = (where = p/4 = 45 degrees). IF YOU FEEL UNSURE ABOUT THESE LAST SLIDE ASK QUESTIONS NOW!!!

6 Matrices and Determinants…
A matrix for us will be a rectangular arrangement of numbers (typically real numbers) organized in “m” rows and “n” columns and called an m by n or m x n matrix. The most interesting matrices for us are the squared or n x n matrices. The example below is a 3 by 4 (3 x 4) matrix (where the letters are representing numbers or any other object). The determinant is a number (typically a real number) associated with a square matrix. Determinants are not easy to calculate and require a lot of algorithmic skills. For this reason, in most cases, we will simply use Matlab (or Octave) or Mathematica if the evaluation requires an algebraic expression rather than a number. In the example below we have a 2 by 2 matrix whose determinant is “ad – cb”, that is, the product of the numbers in the main diagonal minus the product of the numbers in the counter-diagonal. a b c d p q r s u v t w 3x4 det = ad – cb a b c d 2x2 =

7 Determinant of a 3 by 3 matrix (Sarrus’ Rules)
The determinant of 3 x 3 matrices also have a simple known algorithm. After that, the calculations are rather cumbersome and we’ll leave it at that. For the 3 by 3 determinant we have two procedures: (1) We add the 1st and 2nd columns to the right of the matrix after the third column. Then we multiply the 3 numbers on each main diagonal and we add them. Next, to this number we subtract the products of all counter-diagonals. (See picture below). (2) We add the 1st and 2nd rows below the matrix after the third row. Then we multiply the 3 numbers on each main diagonal and we add them. Next, to this number we subtract the products of all counter- diagonals. (See picture below). 3x3 a11 a12 a13 a21 a22 a23 a31 a32 a33 = a11 a22 a33 + a12 a23 a31 + a13 a21 a32 – – (a31 a22 a13 + a32 a23 a11 + a33 a21 a12 ) a11 a12 a21 a22 a31 a32 = a11 a22 a33 + a21 a32 a13 + a31 a12 a23 – – (a31 a22 a13 + a11 a32 a23 + a21 a12 a33 )

8 Product of matrices The product of two matrices is possible only if the number of columns of the first matrix matches the number of rows of the second matrix, that is, multiplication of an mxp matrix with a pxn matrix to generate an mxn matrix. The algorithm is quite simple. Let Cmxn = Amxp x Bpxn the algorithm (in pseudo code) is: for i = 1 to m for j = 1 to n C(i, j) = 0 for k = 1 to p C(i, j) = C(i, j) + A(i, k)*B(k, j) The example below illustrates this algorithm for two 3 by 3 matrices, (that is: m = n = p = 3): A x B = = C 2*3 + 3*4 + 5*2 2*1 + 3*2 + 5*3 2*2 + 3*1 + 5*7 3*3 + 3*4 + 2*2 3*1 + 3*2 + 2*3 3*2 + 3*1 + 2*7 4*3 + 1*4 + 6*2 4*1 + 1*2 + 6*3 4*2 + 1*1 + 6*7 =

9 Properties of matrices: Summary
To simplify the discussion let’s define the more convenient notation for a matrix. It is shown below. In this representation a(i, j) represents the entire matrix and also element (i, j) in the matrix. 1. Two matrices can be added only if they have the same m x n dimension. If A = a(i, j) and B = b(i, j) then their addition C = c(i, j) = A + B = a(i, j) + b(i, j) term to term. 2. Multiplication of a matrix by a scalar k multiplies all the terms of the matrix by k that is: kA = ka(i, j). 3. The unit matrix I is defined as a(i, j) = 1 if i = j and a(i, j) = 0 if i ≠ j, that is, 1’s along the main diagonal and 0’s elsewhere. 4. Multiplication of an m x n and p x q matrix is possible only if p = n, that is the number of columns of the first matrix factor must be equal to the number of rows of the second matrix factor as shown earlier. 5. The inverse of a matrix A is A-1 and is such that: A A-1 = A-1 A = I (we’ll use MATLAB/Octave to do this) 6. The transpose of a matrix Amxn = a(i, j) is (At)nxm= a(j, i), that is, At rows are A’s columns (and viceversa). a11 a12 a13 … a1j … a1n a21 a22 a23 … a2j … a2n …………………………………… ai1 ai2 ai3 … aij ain am1 am2 am3 … amj … amn mxn A = a (i, j) =

10 The minor of a matrix and the determinant
Each term of an mxn matrix has an associated minor matrix of dimension (m-1)x(n-1) obtained from the main matrix by eliminating the column and the row corresponding to said element. Minor Mij corresponds to the element aij by eliminating the i-row and the j-column. The determinant of an nxn matrix is equal to the elements along any row (or column) times their minors times (-1)i+j, that is, if A = a(i, j) then: det(A) = Sum for a fixed i of the products (-1)i+j aij * Mij for j = 1 to n. = Sum for as fixed j of the products (-1)i+j aij * Mij for i = 1 to n. Example (expansions using the first row and then the first column): And this is a rule valid for any n x n matrix, that is, this rule is applied recursively for higher order matrices. a11 a12 a13 a21 a22 a23 a31 a32 a33 = a22 a23 a32 a33 a11 a21 a23 a31 a33 - a12 a21 a22 a31 a32 + a13 a12 a13 - a21 + a31

11 Quantities: Scalars and vectors …
Quantities that are fully described but their magnitude (or “size”) only are usually called “scalars”. For example: 160 lbs weight, 87 degrees temperature, 6’3” height, 20 meters, 5 gallons, … Quantities that need more than just a number (magnitude) to be fully described but in addition need a direction and an orientation are called “vectors”. For example: Velocity: driving at 65mph in magnitude, in the E-W direction, heading E in orientation. Force: the robot is moving 80 lbs in magnitude, in the vertical direction, going down in orientation. Vectors are usually represented geometrically by an arrow. All parallel arrows with the same magnitude, direction and orientation represent the same vector (free vectors). That is, a vector can move back and forward along its direction and parallel to itself away from is line of direction and still be the same vector! A unit vector is one whose magnitude is 1. (One unit of length!). Sometimes we need to define the POSITION and ORIENTATION of an object. The combination of Position and Orientation is called POSE. An indefinite line with an orientation defined on it is called AXIS (plural axes).

12 Coordinate Systems … Since a robot lives in the physical world we use preferably the 3-dimensional (3D or R3) system of coordinates with the 2-dimensional (2D or R2) system used to help us better understand some basic notions of the 3D or R3 world … A system of 2D coordinates consists of two axes intersecting in 90o (degrees) from each other (or perpendicularly or orthogonally or normally) on the plane they define. The typical 2D (R2) system of coordinates consists of a horizontal axis (the X-axis) and a vertical axis (the Y-axis). Associated to the 2D system there are the unit i and j vectors. The i unit- vector in the X-axis direction and orientation and the j unit-vector in the Y-axis direction and orientation. A 3D (R3) system of coordinates includes a 3rd axis perpendicular to the plane X-Y described above, the Z-axis with its unit k vector, forming a right-hand three-finger system with the middle finger pointing in the X-direction and orientation, the thumb pointing in the Y- direction and orientation and the index finger pointing in the Z-direction and orientation.

13 The 2D & 3D Coordinate Systems …
A 2D and 3D “pictorial” or geometric representation of a vector by its components and its corresponding unit vector “connected” to the origin of the coordinate system. Y Y Z j k x r = ai + bj + ck = |r|r i X bj ai ck |r| = a²+ b² + c² r r = ai + bj = |r|r bj x j |r| = a²+ b² r i ai X In any coordinate system the unit vector corresponding to vector r is: r = r/|r|

14 Multiplication of vectors by an scalar …
Scalar multiplication has a nice geometric interpretation in 2D (R2) and also in 3D (R3) if we are using real numbers). If a is a positive number and x is a vector in 2D or 3D, then ax is the vector that points in the same direction as x and whose length is a times the length of x. In other words, to get ax, we shrink or stretch x by a factor of a, depending upon whether a < 1 or a > 1. The next picture (approximately) illustrates this point. x ~ 0.5x ~ 1.5x Multiplication by positive scalars If a is a negative number and x is a vector in 2Dor 3D, then ax is the vector that points in the opposite direction as x and whose length is a times the length of x, as illustrated in the next picture. x ~ -0.5x ~ -1.5x Multiplication by negative scalars

15 Scalar or Dot product of two vectors …
One of the most important multiplication or product between two vectors is the Dot Product or Scalar Product. This product has a very nice simplification in 2D or 3D where we can use the (i, j) or the (i, j, k) set of unit vectors to represent them. Definition: The dot or scalar product of two vectors is defined as the product of the magnitude of the vectors times the cosine of the angle between them, that is, if a and b are vectors and the angle between them is q, then their dot or scalar product is: a . b = |a|*|b|*cos(q) Clearly, if the angle between a and b is 90° then a . b = 0. The dot product of two orthogonal (perpendicular) vectors is zero. (A most important property!). If the vectors are expressed by their coordinates, then the dot product is expressed as the product of their corresponding components. Let consider the 3D (3R3) case where a = axi + ayj + azk and b = bxi + byj + bzk, then: a . b = axbx + ayby + azbz (Because i . j = j . i = 0, i . k = k . i = 0, j . k= k . j = 0, … they are perpendicular to each other and since i, j, k are all unit vectors i . i = j . j = k . k = 1)

16 Geometric Interpretation of the Dot product …
The dot product of two vectors can be easily interpreted as the magnitude of one of the vectors times the projection of the other vector on the first one, that is a . b = |a|*[|b|*cos q] = |b|*[|a|*cos q] b b |a| cos q q q |b| cos q a a a . b = |b|*[|a|*cos q] a . b = |a|*[|b|*cos q] IF YOU FEEL UNSURE ABOUT THESE LAST TWO/THREE SLIDES ASK QUESTIONS NOW!!!

17 Vector or Cross product of two vectors …
The other most important multiplication or product of two vectors is the Vector Product or Cross Product. This product has a very nice visualization in 3D when we use the (i, j, k) set of unit vectors. Definition: The vector or cross product of two vectors is defined as a vector perpendicular to the plane created by the two vectors whose magnitude is equal to the product of the magnitude of the vectors times the sine of the angle between them, that is, if a and b are vectors and the angle between them is q, then their cross or vector product is: a x b = |a|*|b|*sin(q) n where “n” is a unit vector perpendicular to the plane that contains a and b pointing in the positive direction (the “up” direction following the right-hand rule for vectors). If the angle between a and b is 0° then a x b = 0. The cross product of two parallel vectors is zero. (A most important property!). If the vectors are expressed by their coordinates, that is if a = axi + ayj + azk and if b = bxi + byj + bzk then we can express their cross product in algebraic and matrix form: a x b = (aybz - azby) i + (azbx - axbz) j + (axby - aybx) k = (Because i x i = j x j = k x k = 0 and i x j = - j x i = k, j x k = - k x j = i, k x i = - i x k = j ) i j ay ax by bz bx k az

18 Geometric Interpretation of the Cross product …
The cross product can be seen as the “oriented” area of the rectangle comprised by the two vectors a and b as follows: a x b = |a|*[|b|*sin q] * n q b a |b| sin q n q b a |a| sin q n a x b = |b|*[|a|*sin q] n a x b = |a|*[|b|*sin q] n with the “orientation” given by the “n” vector following the “right hand” convention for vectors a, b and n. Therefore, the cross product b x a has the “n” vector pointing down and thus b x a = - a x b. IF YOU FEEL UNSURE ABOUT THESE LAST TWO SLIDES ASK QUESTIONS NOW!!!

19 The Right Hand Convention …
the “orientation” given by the “right hand” convention: Z Z X X Y Y IF YOU FEEL UNSURE ABOUT THESE LAST TWO SLIDES ASK QUESTIONS NOW!!!

20 So what’s torque? From Physics we need to consider four vectors: velocity, acceleration, force and torque. We will consider enough familiarity with the first three vectors. We will discuss them only if needed! We will say a few words about the fourth vector: torque. Torque is a measure of how much a force acting on an object causes that object to rotate. The object rotates about an axis, called the pivot point. The distance from the pivot point to the point where the force acts (is applied) is called the moment arm. F Fx Fy O r q Refer to Figure on the right for a pictorial representation of these definitions. The pivot point is “O”. The moment arm vector is “r”. The force vector applied is “F”. Force F is decomposed in two components: Fx, parallel to the object’s arm and thus producing no torque (because it passes through O) and Fy, perpendicular to the object’s arm and the one generating the torque. W!!! Mathematically, torque or moment or moment of force, typically written as t (tau), is defined as the cross product of the moment arm “r” and the force “F”, that is: t = r x F where the magnitude of the torque is |t|= |r||F|sin q (By definition the torque is a vector. In the figure, due to the right hand rule, the torque vector comes out of the page perpendicularly to the plane defined by “r” and “F”). IF YOU FEEL UNSURE ABOUT THIS LAST SLIDE, ASK YOUR QUESTIONS NOW!!!

21 Quaternions… (William R. Hamilton, 1843)
Quaternions, discovered in (Monday October 16th) 1843 began to be relegated (since mid 1880) to a minor role in mathematics and physics by vector analysis which described the same phenomena as quaternions but in a conceptually simpler manner with a cleaner notation. However, quaternions have had a revival since the late 20th century, primarily due to their utility in describing spatial rotations. The representations of rotations by quaternions are more compact and quicker to compute than the representations by matrices. Quaternions are used in: computer graphics, computer vision, robotics,, control theory, signal processing, attitude control, physics, bioinformatics, molecular dynamics, computer simulations, orbital mechanics ...

22 Quaternions… (Con't) ... Definition: A quaternion q can be regarded as a 4-tuple of real numbers (q0, q1, q2, q3), its components, where q0 is its scalar part and (q1, q2, q3) is its vector part (in R3), that is, q = q0 + q1i+ q2 j+ q3k , where (i, j, k) is the well known triad of unit vectors defined in R3. We can write instead, q = q0 + q where q = q1i+ q2 j+ q3k . (This definition suffices to show that quaternions are closed under addition and multiplication by a scalar) To complete the definition we need to add the fundamental (Hamilton’s) special products (not the “dot” nor the “cross” products) associated with i, j and k: i2 = j2 = k2 = ijk = -1; ij = -ji = k ; jk = - kj = i; ki = -ik = j. (and then we can show other properties including that the product of quaternions is non-commutative.)

23 Product of quaternions and other properties ...
Let q = q0 + q (with q = q1i+ q2 j+ q3k) and p = p0 + p (with p = p1i+ p2 j+ p3k) be two quaternions, then qp = (q0 + q ) (p0 + p ) = q0p0 + q0p + p0q + qp where the “product” qp = q x p – q . p that is: qp = q0p0 – q . p + q0p + p0q + q x p (here the scalar part is “q0p0 – q . p“, the rest are vectors).

24 Product of quaternions and other properties ...
Quaternion conjugates: Quaternions q = q0 + q and q* = q0 - q are called conjugates. (Note q + q* = 2q0) Magnitude (Size, Norm) of a quaternion: Given q = q0 + q1i + q2 j + q3k, then qq* = q*q = |q| = (q1)2 + (q2)2 + (q3)2 Inverse of a quaternion: Given q = q0 + q1i+ q2 j+ q3k, then q-1 = 1/q = q*/|q|2 Unit quaternion: A quaternion such that |q| = 1. Also for this quaternion q-1 = q*. Here q = 1 + 0, that is, the unit quaternion has the scalar part of 1 and the vector part of 0. The zero and the negative (additive inverse) quaternions are trivially defined as “0” and “-q”.

25 An example using quaternions ...
Let p = 3 + i – 2j +k and q = 2 – i + 2j +3k. Verify that p . q = - 2 and p x q = -8i – 4j and thus their product is: pq = 8 – 9i – 2j + 11k. We can use this example to verify that the product of quaternions can be expressed using algebra of matrices. For this let: p = p0 + p = p0 + p1i+ p2 j+ p3k, and q = q0 + q = q0 + q1i+ q2 j+ q3k, and let’s designate the product as the quaternion r = pq = r0 + r = r0 + r1i+ r2 j+ r3k. We can verify that the product pq can be written in matrix notation as follows: p0 -p1 -p2 -p3 p1 p0 -p3 p2 p2 p3 p0 -p1 p3 -p2 p1 p0 = r0 r1 r2 r3 q0 q1 q2 q3 And using the example at the top of the page: = r0 r1 r2 r3 2 -1 3 8 -9 -2 11 IF YOU FEEL UNSURE ABOUT THESE LAST TWO SLIDES ASK QUESTIONS NOW!!!

26 Three definitions we may encounter: Groups, SO(3), SE(3).
Groups: algebraic structure consisting of a set of elements equipped with an operation that combines any two elements to form a third element and that satisfies four conditions called the group axioms, namely closure, associativity, identity and invertibility. A set has closure under an operation if performance of that operation on members of the set always produces a member of the same set; in this case we also say that the set is closed under the operation. In abstract algebra, the idea of an inverse element generalizes concepts of a negation (sign reversal) in relation to addition, and a reciprocal in relation to multiplication. Within an expression containing two or more occurrences in a row of the same associative operator, the order in which the operations are performed does not matter as long as the sequence of the operands is not changed. That is, rearranging the parentheses in such an expression will not change its value. In mathematics, an identity element or neutral element is a special type of element of a set with respect to a binary operation on that set, which leaves other elements unchanged when combined with them. SO(3): Special Orthogonal group in three dimensions.  Coordinate frames corresponding to right handed frames are represented by orthogonal matrices with determinant +1 (this is why it’s special, it’s not -1). The set of all 3 x 3 matrices which satisfy these two properties is SO(3) ⊂ R3x3  (a group  under matrix multiplication). SE(3): Special Euclidean group. Used for the kinematics of a rigid body, in classical mechanics. An arbitrary rigid transformation in SE(3) can be separated into two parts, namely, a translation and a rigid rotation.


Download ppt "Basic Math Review (you already know this stuff ...)"

Similar presentations


Ads by Google