Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3)...

44
Geometric Representations and Transformations J. Irving V´ asquez Centro de Innovaci´on y Desarrollo Tecnol´ogico en C´omputo 20 de febrero de 2020 1 / 44

Transcript of Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3)...

Page 1: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Geometric Representations and Transformations

J. Irving Vasquez

Centro de Innovacion y Desarrollo Tecnologico en Computo

20 de febrero de 2020

1 / 44

Page 2: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Introduccion

Image from[Kostas]

2 / 44

Page 3: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Body Frame

Figura: A sensor (red point) is not always in the center of the body frame.

3 / 44

Page 4: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Definitions

Espacio euclidiano Un espacio euclidiado de dimension n, es elconjunto de tuplas de dimension n,(x1, x2 . . . , xn),

que satisface la metrica(∑n

i=1 x2i

) 12

Point Una tupla de n-elementos, (x1, x2 . . . , xn)

Linea Dados dos puntos, una linea esta formada lacombinacion lineal de ellos.

αp1 + (1− α)p2 α ∈ R

Segmento de linea Un segmento de linea es la combinacionconvexa de dos puntos.

αp1 + (1− α)p2 α ∈ [0, 1]

4 / 44

Page 5: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Definitions

Convex set A set X ⊂ Rn is called convex if and only if, for anypair of points in X , all the points along the linesegment that connects them are contained in X .

λx1 + (1− λ)x2 ∈ X

Convex Hull The convex hull of a set of points, S , in En is theboundary of the smallest convex set in En containingS .

Polygon A polygon is a set of vertices and edges, Q = (V ,E ),where V is a set of points on the plane and E is a setof 2-d vertices tuples.

5 / 44

Page 6: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Geometric Modeling

The world W (R2 or R3) contains closed sets:

RobotsA ⊆ WObstaclesO ⊆ W

Representation approaches:

BoundarySolid

6 / 44

Page 7: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Polygonal Models

We can construct bodies by primitives and set theory operations.

Boundary representation

2D, convex polygons, G = {V ,E}Solid

Intersection of half planes

y < mx + b

7 / 44

Page 8: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Nonconvex polygons

Nonconvex polygon

A collection of convex polygons

O = O1 ∪ O2 ∪ · · · ∪ On (1)

8 / 44

Page 9: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Polyhedral models

A 3D world

Boundary:A set of vertices, edges and faces P = {V ,E ,F}Solid: half spaces representation

9 / 44

Page 10: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

3D triangles

A triangle = {(x1, y1, z1), (x2, y2, z2), (x3, y3, z3)}A set of triangles represents a body.Triangular meshes

Figura: Triangular Mesh of the Bebop drone

10 / 44

Page 11: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Semi algebraic models

for algebraic models, the functions are linear

for semi-algebraic models, the functions can be anypolynomial with real-valued coefficients.

11 / 44

Page 12: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Assignment

Implement in Python:

Notebook: “representacion poligono”Represent a robot with a polygonPlot the Polygon

Figura: A triangular representing a robot.

12 / 44

Page 13: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Assignment

Display the following geometric models in RViz:A Polygon

A Mesh (binary .stl or Ogre .mesh in 1.0, COLLADA (.dae) in1.1)

13 / 44

Page 14: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Rigid Motions

14 / 44

Page 15: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

We will use an analytic approach

The superscript is used to denote the reference frame:

p0 = [5, 6] , p1 = [−2.8, 4.2] (2)

p is a geometric entity and it is independent from itscoordinate representation.

a vector has direction and magnitude.

Thus, v1 and v2 are invariant with respect to the choice ofcoordinate systems,

The representation by coordinates of these vectors dependsdirectly on the choice of reference coordinate frame.

15 / 44

Page 16: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Rotations

Rotations in the plane

We can represent the coordinates of the point p1 in the frameO0 by getting the proyections of the verctors over the frame.

We obtain:R0

1 =[x0

1 |y01

]where x0

1 and y01 are the coordinates in frame O0 of unit

vectors x1 and y1.

It is called Rotation Matrix.

R01 =

[cos θ − sin θsin θ cos θ

]

16 / 44

Page 17: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Special orthogonal group

17 / 44

Page 18: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Assigment

Mestre que la inversa de una rotacion por el angulo θ es iguala la transpuesta.

18 / 44

Page 19: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Rotations in three dimensions

In three dimensions, each axis of the frame x1, y1 y z1 isprojected onto coordinate frame x0, y0 y z0. The resultingrotation matrix is given by

19 / 44

Page 20: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Rotation in z

20 / 44

Page 21: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Rotation in z

21 / 44

Page 22: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

The basic rotations

22 / 44

Page 23: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Rigid Body

A rigid body is a geometric representation of a physical bodyso that its shape does not change over time.

Figura: Two rigid bodies in the environment (A Kinect Sensor and a box).

23 / 44

Page 24: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

The rotational transformation

Given the coordinates p1 of the point p (i.e., given thecoordinates of p with respect to the frame x1 y1 z1 ), we wishto determine the coordinates of p relative to a fixed referenceframe x0 y0 z0.

p = ux1 + vy1 + wz1

Recalling that the dot product of two unit vectors gives theprojection of one onto the other

p0 =

p · x0

p · y0

p · z0

24 / 44

Page 25: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

The rotational transformation

25 / 44

Page 26: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

The rotational transformation

26 / 44

Page 27: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Rigid motions

We can use rotation matrices to represent rigid motions thatcorrespond to pure rotations (In the same frame).

27 / 44

Page 28: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Rigid motions

We can rotate a point in the same reference frame by doing:

p0b = Rz,πp

0a

In general,p0b = Rp0

a

28 / 44

Page 29: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Note!

A rotation matrix can be interpreted in three distinct ways:

It represents a coordinate transformation relating thecoordinates of a point p in two different frames.

It gives the orientation of a transformed coordinate frame withrespect to a fixed coordinate frame.

It is an operator taking a vector and rotating it to a newvector in the same coordinate system.

29 / 44

Page 30: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Composition of Rotations

Consider two sequential rotations:

p0 = R01p

1

p1 = R12p

2

p0 = R02p

2

Then:

p0 = R01R

12p2

Composition law (post-multiplication)

R02 = R0

1R12

30 / 44

Page 31: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Composition of Rotations

Exercise. Suppose a rotation matrix R represents a rotation ofangle φ about the current y -axis followed by a rotation of angle θabout the current z-axis. What is the rotation matrix?

31 / 44

Page 32: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Rotations with respect of a fixed frame

Some times it is desired to perform a sequence of rotations,each about a given fixed coordinate frame, rather than aboutsuccessive current frames.

The matrices are multiplied in the reverse order

R02 = R0

1

[(R0

1

)−1RR0

1

]= RR0

1

32 / 44

Page 33: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Note!

33 / 44

Page 34: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Assignment

Lets suppose a mobile robot rotated by θ = 35o, that observes afeature point at probot = [10, 32, 52].

34 / 44

Page 35: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Parameterized representations

An arbitrary rotation ca be represented using only threeindependent variables.

Some conventions are:

Euler anglesYaw, pitch, rollAxis-angle

35 / 44

Page 36: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Euler Rotations

Given three sucesive angles (φ, θ, ψ):

First rotate about z by φThen rotate about y by θFinally rotate about the current z by ψ

RZYZ = Rz,φRy ,θRz,ψ

36 / 44

Page 37: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Roll, pitch, yaw angles

Given three sucesive angles (φ, θ, ψ):

First rotate about z by φThen rotate about y by θFinally rotate about the current x by ψ

RZYX = Rz,φRy ,θRx ,ψ

Figura:

37 / 44

Page 38: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Assigment

https://github.com/irvingvasquez/ra_programas

Resolver el ejercicio Rotaciones de Euler

38 / 44

Page 39: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Gimbal Lock

When all three gimbals are lined up, the system can only move intwo dimensions.

Figura:

39 / 44

Page 40: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Quaternions

A generalization of complex numbers

William Hamilton (1843)

i2 = j2 = k2 = ijk = −1

q = a + bi + cj + dk

40 / 44

Page 41: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Performing rotations

We need the quaternion

q = a + bi + cj + dk

and its inverse

q = a− bi − cj − dk

then

p = [xyz ]T

pnew = qpq

41 / 44

Page 42: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Euler to Quaternion

42 / 44

Page 43: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Quaternion to Euler

43 / 44

Page 44: Geometric Representations and Transformations€¦ · Geometric Modeling The world W(R2 or R3) contains closed sets: Robots A W Obstacles O W Representation approaches: Boundary Solid

Quaternion to Rotation

44 / 44