lecture 4c geometry and transformations n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Lecture 4c Geometry and transformations PowerPoint Presentation
Download Presentation
Lecture 4c Geometry and transformations

Loading in 2 Seconds...

play fullscreen
1 / 29

Lecture 4c Geometry and transformations - PowerPoint PPT Presentation


  • 120 Views
  • Uploaded on

Lecture 4c Geometry and transformations. Rotations around an arbitrary axis Rotations Using rotation matrices Using a Householder reflection matrix Using a quaternion. Rotation. 3 degrees of freedom (DOF) 2 angles that specify the orientation of the rotation vector

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Lecture 4c Geometry and transformations' - theophilia-xylia


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
lecture 4c geometry and transformations
Lecture 4cGeometry and transformations
  • Rotations around an arbitrary axis
    • Rotations
    • Using rotation matrices
    • Using a Householder reflection matrix
    • Using a quaternion
rotation
Rotation
  • 3 degrees of freedom (DOF)
    • 2 angles that specify the orientation of the rotation vector
    • 1 angles that specifies the amount of rotation
rotation1
Rotation
  • We know the following:
    • We can concatenate rotations about our standard axes x, y, and z to create a general rotation
    • We can always rotate about the origin if we translate everything first
    • We can easily undo rotations and translations by negating the angle of rotation or distances.
rotation around an arb axis
Rotation around an arb. axis
  • We will use this information to find a rotation around an arbitrary axis, R(),where
  • R() = T-1 Rx-1(x) Ry-1(y) Rz() Ry(y) Rx(x) T

Note: , x,and y,are three different angles.

Note: Apply transformations from left to right so that translation to origin is done first, then a rotation around the x axis, then around the y and z, and then the inverses are applied.

rotation around an arb axis1

p2

v

p1

x

p0

z

Rotation around an arb. axis
  • The problem:
    • Rotate an object centered at p0° around an axis defined by v = p2 - p1
  • Graphically:

y

translation

y

u = (x, y,z)

x

z

p0

Translation
  • First:
    • Normalize v

vUNIT = u = (p2 - p1) / |p2 - p1|

    • Translate all points to the origin
  • Giving:
translation1
Translation
  • This takes care of the translation.
  • R() = T-1 Rx-1(x) Ry-1(y) Rz() Ry(y) Rx(x) T
  • T = 1 0 0 -p1x
  • 0 1 0 -p1y
  • 0 0 1 -p1z
  • 0 0 0 1
how shall we perform rotation
How shall we perform rotation?
  • Our goal:
    • To rotate our object around a standard axis (because we know how to do this). Let’s choose the z axis.
    • If we were to align our rotation axis, v, with the z axis, we could easily rotate our °
  • Then:
    • The problem becomes how to align v with z.
    • We will do this with a series of rotations.
direction angles
Direction angles
  • Let’s look at some tools we can use:
    • The angles, x,y,z, that u makes with the x, x,y,z axes respectively, are called the direction angles
    • The cosines of these angles are called the direction cosines

cosx= x

cosy= y

cosz = z

x2+y2+z2= 1 (u unit vec)

=> cosx2+cosy2+cosz2= 1

y

(x, y,z)

y

x

x

z

z

rotations about x y z axes
Rotations about x,y,z axes
  • Here is our strategy:

1.Rotate u about x axis into the xz plane - call the rotated vector u.

2.Rotate u about the y axis into the yz plane, which will align it with the z axis - call the rotated vector u.

3.Rotate our object about u (which is now the z axis).

4.Undo rotations 1. and 2., which brings u back to u.

rotation of u to xz plane

y

u=(x, y,z)

x

x

u

z

Rotation of u to xz plane
  • First:
  • Rotate u about x axis into the xz plane - call the rotated vector u.

But, how do we find x?

rotation of u to xz plane1

y

u=(x, y,z)

up=(0, y,z)

x

x

x

u

z

Rotation of u to xz plane
  • If we project u onto the yz plane, then the angle that up makes with the z axis is also x.
  • Again, how do we find x?
rotation of u to xz plane2
Rotation of u to xz plane
  • It happens that we don’t really need x, what we really need is the sin and cos of x which can be found geometrically
  • cosx = z /d and sinx = y /d

y

d = sqrt(y2+z2)

- the length of up, d,

is different than the

length of u

z

up=(0, y,z)

u=(x, y,z)

d

x

x

x

y

u

z

If we project u

onto the yz plane,

then the angle

up makes with z

is equal to x

rotation r x x
Rotation: Rx(x)
  • This takes care of the rotation of u around the x axis.
  • R() = T-1 Rx-1(x) Ry-1(y) Rz() Ry(y) Rx(x) T
  • Rx(x) =

1 0 0 0

0 cosx-sinx 0

0 sinx cosx 0

0 0 0 1

=

1 0 0 0

0 z/d -y/d 0

0 y/d z/d 0

0 0 0 1

rotation of u to yz plane

y

u=(x, y,z)

x

u

y

z

Rotation of u to yz plane
  • Second:
  • Rotate u about y axis into the yz plane - call the rotated vector u (or z!)

But, how do we find y?

If u is a unit vector

then u is a unit vector

(because we rotated u

instead of projecting it)

rotation of u to yz plane1
Rotation of u to yz plane
  • To find y we can use the same machinery we employed to find x, i.e.

y

1. If we rotate u to z (y)

we get u. What is the

sin and cos of y?

u=(x,y,z)

up =(0,y,z)

d

x

x

cos y

up

u

x

2. If we project u to z

then the length of up

will be equal to the

length of up = d (rotat-

ing u about x axis does

not change the length of

its projection onto yz)

u

y

z

3. cosy = z coord of u = length of up = length of up (rotating up about x does not change its length) = d, so cosy = sqrt(y2+z2)

Therefore, sin y = x(rotating u about x does not

change its x coord.) but we want a pos. rot. instead of

the neg we see in illustration, so sin y = -x

rotation of u to yz plane2
Rotation of u to yz plane
  • Or, we can use the direction angles and direction cosines of u to find y, i.e.

y

2. We know that x, the

direction angle of u, does

not change as u rotates

around x.

1. We know that the y axis

makes a 90° angle with

the xz plane.

u=(x, y,z)

90°

x

y

x

x

u

x

u

z

cos2x+cos2(90)+cos2y = 1

=> cosy2= 1- cos2x - cos2(90)= 1- x2= y2+z2

=> cosy = sqrt(y2 +z2 )

=> siny = +-sqrt(1- cos2y) = + -sqrt(1-1+x2) = -x

(x2 +y2 +z2 =1)

rotation r y y
Rotation: Ry(y)
  • This takes care of the rotation of u around the y axis.
  • R() = T-1 Rx-1(x) Ry-1(y) Rz() Ry(y) Rx(x) T
  • Ry(y) =

d 0 -x 0

0 1 0 0

x 0 d 0

0 0 0 1

cosy 0 -siny 0

0 1 0 0

siny 0 cosy 0

0 0 0 1

=

rotation r z
Rotation: Rz()
  • The rotation around z is the user- specified angle, 
  • This takes care of the rotation of the object around the z axis.
  • R() = T-1 Rx-1(x) Ry-1(y) Rz() Ry(y) Rx(x) T
  • Rz() = cos -sin 0 0
  • sin cos 0 0
  • 0 0 1 0
  • 0 0 0 1
rotation inverses
Rotation: Inverses
  • Now find the inverses
  • R() = T-1 Rx-1(x) Ry-1(y) Rz() Ry(y) Rx(x) T
  • That’s it!
  • Or is it?
householder matrices
Householder matrices
  • Using rotation matrices to align the rotation axis with the z axis we found:
  • R() = T-1 Rx-1(x) Ry-1(y) Rz() Ry(y) Rx(x) T
  • A more efficient way to do this is to use a reflection matrix to align the rotation axis with z:
  • R() = T-1 H Rz(-) H T
  • where H is a Householder matrix
householder matrices1

Reflection

plane, Rp

b

a

b

b

n=(b-a)/|b-a|

a

n

Householder matrices
  • Given an arbitrary axis of rotation, u, translate it to the origin as usual
  • Find a plane that we can reflect u (b) through to give us the z axis (a) (assume a,b unit vectors)

1. Find n; the reflection plane is defined by its normal

2. Find vector, v,

from b to Rp

v = -(b*n) n,

where (b*n) is

length and

-n is direction

Subtract a from b

(and normalize)

to find normal, n, of Rp

len=(b*n)

is b projected to n

householder matrices2

b

a

Householder matrices
  • To find vector a we add 2*v to vector b

a = b + 2*(-(b*n)n)

= b - 2n(b*b)

= b - 2nnTb

= (I - 2nnT)b

rearrange terms

rewrite in matrix form, n*b = [nxnynz][bx] = nTb

[by]

[bz]

Householder matrix

H = (I-2nnT)/|n||n| = (I-2nnT)/nTn

|n| = sqrt(nx2+ny2+nz2)

|n|2 = nx2+ny2+nz2

= [nxnynz][nx]

[ny]

= nTn [nz]

the general form makes no

assumptions about normalization

householder matrices3
Householder matrices
  • The Householder matrix:
  • H(n) = (I - 2nnT)/nTn
  • = I + cnnT, where c = -2/nTn (a scalar)

nx2 nxny nxnz

nxny ny2 nynz

nxnz nynz nz2

1 0 0

0 1 0

0 0 1

=

+ c

nnT = [nx][nx ny nz]

[nx]

[nx]

Bonus: a Householder matrix is its own inverse (H=H-1)!

quaternions
Quaternions
  • Using rotation matrices to align the rotation axis with the z axis we found:
  • R() = T-1 Rx-1(x) Ry-1(y) Rz() Ry(y) Rx(x) T
  • Using a Householder reflection matrix to align the rotation axis with z we found:
  • R() = T-1 H Rz(-) H T
  • Using a quaternion is even more efficient:
  • Rq() = T-1 MR() T
quaternions1
Quaternions
  • The most efficient way to perform a rotation about an arb. axis is with a quaternion
  • A quaternion is a:
    • 4D generalization of a 2D complex number
      • q = s + ia + jb + kc
      • s,a,b,c  R
      • i,j,k imaginary terms with property i2=j2=k2=-1
    • Super-concise representation of a matrix
      • the most efficient way to do rotations
      • very easy to interpolate orientations
quaternions2
Quaternions
  • Representation
    • q = (s,v), s a scalar and v a vector
    • Given  and u, arguments of a rotation matrix,

s = cos(/2), v = u*sin(/2), u a unit vector

  • Multiplication
    • Concatenating 2 rotations is equivalent to multiplying 2 quaternions

q1q2= (s1s2 - v1*v2, s1v2 + s2v1 + v1xv2)

    • Treat a point as p=(0,v), a pure imaginary

p=Rq(p)=qp-q= s2 p + v(p*v) 2s(vxp) + vx(vxp)

quaternions3
Quaternions
  • Rotate (ax,ay,az,deg) {
  • Quat quat = new Quat(ax,ay,az,deg);
  • Mat3D mat = quat.toMatrix();
  • }
  • Class Quat {
  • double s, a, b, c;
  • Quat(ax,ay,az,deg) {
  • rad = deg * PI/180; s = cos;
  • cos = cos(rad/2); a = sin * ax;
  • sin = sin(rad/2); b = sin * ay;
  • c = sin * az;
  • }
quaternions4
Quaternions
  • Mat3D toMatrix () {
  • M[0][0] = 1-2b2-2c2;
  • :
  • :
  • M[3][3] = 1-2a2-2b2;
  • }
  • }

1-2b2-2c2 2ab-2sc 2ac-2sb

2ab+2sc 1-2a2-2c2 2bc-2sa

2ac-2sb 2bc+2sa 1-2a2-2b2

Rq = M =