A Quadrilateral Rendering Primitive - PowerPoint PPT Presentation

1 / 31
About This Presentation
Title:

A Quadrilateral Rendering Primitive

Description:

Quaternion multiplication tell us how to compose rotations in the parameter space. ... If the quaternion is a rotation, the formulas is quite simple (just invert q... – PowerPoint PPT presentation

Number of Views:147
Avg rating:3.0/5.0
Slides: 32
Provided by: institutfr8
Category:

less

Transcript and Presenter's Notes

Title: A Quadrilateral Rendering Primitive


1
A QuadrilateralRendering Primitive
Computer Graphics 2
  • Federico Ponchio

TU Clausthal
2
Problem parametrize 3d rotations
  • Equivalent parametrize 3d orientation...

3
Euler angles
  • Rotation matrix can be written as a product of 3
    rotations MABC around 3 axis
  • If the 3 axis are chosen in advance, 3 angles are
    enough.

4
Euler angles
  • The sequence is
  • rotate around z-axis
  • rotate around (the new) x-axis
  • rotate around (the new) z-axis again

5
Rotation matrix
  • C cos(c) sin(c) 0 -sin(c) cos(c)
    0 0 0 1
  • B 1 0 0 0
    cos(b) sin(b) 0 -sin(b) cos(b)
  • A cos(a) sin(a) 0 -sin(a) cos(a)
    0 0 0 1

6
Different choices
  • One could also use a different sequence of axis
    (x,y, z) and get a different parametrization.
  • But there are a few problems...
  • ... the parametrization is not unique.

7
Gimbal lock
  • Gimbal lock is the phenomenon of two rotational
    axis of an object pointing in the same direction.
  • The reason for this is that Eular angles evaluate
    each axis independently in a set order.
  • The problem with gimbal lock occurs when you
    rotate the object down the Y axis, say 90
    degrees. Since the X component has already been
    evaluated it doesn't get carried along with the
    other two axis. What winds up happening is the X
    and Z axis get pointed down the same axis.

8
Gimbal lock
  • In other words a rotation in one axis could
    'override' a rotation in another, making you lose
    a degree of freedom.
  • No matter the order of axis you pick gimbal lock
    will always occur...

9
Rotations in 2D
  • Really easy to parametrize...
  • there is another interestingparametrization
    using complex numbers
  • a ib eiq/2
  • Where of course
  • a2b2 1

10
Algebra of 2D rotations
  • Relate this to the matrix multiplication rule
  • A cos(a) -sin(a) B cos(b) -sin(b)
  • sin(a) cos(a) sin(b)
    cos(b)
  • AB cos(ab) -sin(ab)
  • sin(ab) cos(ab)
  • AB cos(a)cos(b)-sin(a)sin(b)
    -cos(a)sin(b)-sin(a)cos(b)
  • sin(a)cos(b)cos(a)sin(b)
    cos(a)cos(b)-sin(a)sin(b)
  • so with a cos(a) and b sin(a) we get exactly
    the complex mutiplication.

11
Quaternions
  • Add to the real number i,j,k such that
  • i2 j2 k2 ijk -1
  • We can immediately derive (how?)
  • ij k ji -k
  • jk i kj -i
  • ki j ik -j
  • So what we get is not commutative anymore!

12
Basic rules derivation
  • Ijk -1 ijkk -k ij(-1) -k ij k
  • ijj kj -i kj
  • ijk -1 iijk -i jk i
  • and so on and so forth...

13
Quaternions
  • Quaternions are a non-commutative extension of
    complex numbers.
  • We can write a quaternion as
  • q a bi cj dk
  • where a, b, c, and d are real numbers.
  • We can look at it as a vector space (like complex
    numbers but with 4 components).

14
Quaternions
  • Multiplication rules for the quaternions can be
    derived from the linearity and the multiplication
    rules for ijk.
  • Example
  • x 3ik
  • y 2i j -2k
  • xy ?
  • xy ?
  • yx ?

15
Quaternions
  • An alternative representation
  • q a ib jc kd (a,u) with u a 3d vector.
  • Then if p (b, v) we have
  • p q (ab, uv)
  • pq (ab uv, av bu u?v)

16
Rotations and quaternions
  • M a2-b2 -2ab
  • 2ab a2-b2
  • this is a rotation in 2d (with a2b21).
  • We can build an analogous matrix in 3D
  • R(q) q02q12-q22-q22 2q1q2-2q0q3
    2q1q3-2q0q2
  • 2q1q2-2q0q3
    q02-q12q22-q22 2q2q3-2q0q1
  • 2q1q3-2q0q2
    2q2q3-2q0q1 q02-q12-q22q22

17
Quaternions and rotations
  • You can verify that it is an orthogonal matrix
  • colicolj 0 if i?j
  • colicolj (q02q12q22q22)2
  • so if we require q02q12q22q22 1 a point in
    the 3D sphere in R4, we get a rotation.
  • Note q and -q results in the same rotation.

18
Why quaternions?
  • It turns out that if we multiply two matrices
  • R(q1) and R(q2) the multiplication rules yield
  • R(q1)R(q2) R(q1q2)
  • If we use for q1 and q2 the quaternion
    multiplication.

19
Geometric intuition
  • We can describe a rotation with an axis and an
    angle.
  • We can also write
  • q (q0, q) (cos(q/2), nsin(q/2))
  • where n is the unit axisof the rotation

20
Geometry intuition
  • Quaternion multiplication tell us how to compose
    rotations in the parameter space.
  • An example lets k 1/?2
  • A rotation of 90 degrees around x axis
  • p (cos(p/4), xsin(p/4)), (k, k,0,0)

21
Geometry intuition
  • A rotation of 90 degrees aroun y axis
  • q (cos(p/4), ysin(p/4)), (k, 0,k,0)
  • What is the result of the composition pq?

22
Example
  • Remember the formula?
  • pq (ab uv, av bu u?v)
  • pq (k2, k2x k2y k2x?y)
  • (1/2, (1/2)1,1,1 ) (cos(p/3), sin(p/3)n)

23
A couple of useful formulas
  • Conjugate of a quaternion
  • p a ib jc kd
  • p a ib -jc -kd
  • Inverse of a quaternion
  • p-1 p/(pp)
  • Do someone of you remembers the same formula for
    the complex numbers?

24
A couple of useful formulas
  • If the quaternion is a rotation, the formulas is
    quite simple (just invert q...)
  • q (q0, q) (cos(q/2), nsin(q/2))
  • q-1 (q0, -q) (cos(-q/2), nsin(-q/2))

25
Slerp
  • Spherical linear interpolation
  • a linear interpolation of p0 and p1
  • on the circle. Linear in the
  • sense of geodesic distance.
  • Slerp(p0,p1,t)
  • p0sin((1-t)a)/sin(a) p1sin(ta)/sin(a)

26
Slerp woks on the sphere also
  • Using the great circles we can interpolate on the
    spere also.
  • Can we interpolate rotations?
  • Not easy at all with euler angles or matrices...

27
Direct interpolation
  • What about
  • q(t) (1-t)q0 tq1 ?

28
Doesn't work because...
  • q(t) ? 1
  • that means it is not anymore a rotation...
  • We could reproject it on the sphere in 4D...
  • what could possibly go wrong?

29
Equal speed...
  • The speed of the interpolation would be greater
    near the endpoints...
  • We have to use the SLERPfunction
  • Slerp(q0,q1,t)
  • q0sin((1-t)a)/sin(a) q1sin(ta)/sin(a)

30
Crazy mathematicians
  • Since pq composes rotations not pq we could
    write the interpolation as p(1-t)qt...
  • Does that means anything at all?
  • Well... we can define an exponential function
  • eq 1 q q2/2 q3/6 ... qn/n!
  • ea(cos(u) sin(u)u/u)
  • We also have a logarithm function
  • ln(q) ln(q) arcos(aq)/u/u

31
Crazy mathematicians
  • So we can define a power
  • ax exln(a)
  • lo and behold...
  • Slerp(p,q, t) p(p-1q)t (qp-1)t p
  • (We have to be a bit careful... it is not
    commutative!)
Write a Comment
User Comments (0)
About PowerShow.com