Jorg s Graphics Lecture Notes Coordinate Spaces 1

Similar documents
Visual Recognition: Image Formation

Visualizing Quaternions

CS354 Computer Graphics Rotations and Quaternions

Orientation & Quaternions

3-D D Euclidean Space - Vectors

Homogeneous coordinates, lines, screws and twists

Quaternions and Rotations

Animating orientation. CS 448D: Character Animation Prof. Vladlen Koltun Stanford University

Geometric transformations in 3D and coordinate frames. Computer Graphics CSE 167 Lecture 3

CS 475 / CS 675 Computer Graphics. Lecture 16 : Interpolation for Animation

Animation Curves and Splines 2

Animation. Keyframe animation. CS4620/5620: Lecture 30. Rigid motion: the simplest deformation. Controlling shape for animation

Computer Animation II

CS 445 / 645 Introduction to Computer Graphics. Lecture 21 Representing Rotations

GEOMETRIC TOOLS FOR COMPUTER GRAPHICS

Lecture 3 Sections 2.2, 4.4. Mon, Aug 31, 2009

1 Transformations. Chapter 1. Transformations. Department of Computer Science and Engineering 1-1

Geometric transformations assign a point to a point, so it is a point valued function of points. Geometric transformation may destroy the equation

Transformations Week 9, Lecture 18

Multiple View Geometry in Computer Vision

Visualizing Quaternions

Analysis of Euler Angles in a Simple Two-Axis Gimbals Set

3D Viewing. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

Autonomous Navigation for Flying Robots

Computer Vision I - Appearance-based Matching and Projective Geometry

IMAGE-BASED RENDERING AND ANIMATION

Quaternions and Rotations

3D Viewing. Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

Projective geometry for Computer Vision

Part II: OUTLINE. Visualizing Quaternions. Part II: Visualizing Quaternion Geometry. The Spherical Projection Trick: Visualizing unit vectors.

For each question, indicate whether the statement is true or false by circling T or F, respectively.

CS-9645 Introduction to Computer Vision Techniques Winter 2019

Animation. Animation

Homogeneous Coordinates and Transformations of the Plane

Motivation. Parametric Curves (later Surfaces) Outline. Tangents, Normals, Binormals. Arclength. Advanced Computer Graphics (Fall 2010)

Transformations: 2D Transforms

Fundamentals of Computer Animation

Shadows in Computer Graphics

CSC418 / CSCD18 / CSC2504

Overview. By end of the week:

3D Transformations. CS 4620 Lecture Kavita Bala w/ prior instructor Steve Marschner. Cornell CS4620 Fall 2015 Lecture 11

Transformation Algebra

Animation. CS 4620 Lecture 32. Cornell CS4620 Fall Kavita Bala

Homogeneous Coordinates. Lecture18: Camera Models. Representation of Line and Point in 2D. Cross Product. Overall scaling is NOT important.

Computer Graphics: Viewing in 3-D. Course Website:

How to Project Spherical Conics into the Plane

Today. Today. Introduction. Matrices. Matrices. Computergrafik. Transformations & matrices Introduction Matrices

DD2423 Image Analysis and Computer Vision IMAGE FORMATION. Computational Vision and Active Perception School of Computer Science and Communication

Rigid Body Motion and Image Formation. Jana Kosecka, CS 482

Quaternions & Rotation in 3D Space

Inertial Measurement Units II!

Advanced Computer Graphics Transformations. Matthias Teschner

Chapter 9. Linear algebra applications in geometry

Animation and Quaternions

Geometric Transformations

COMPUTER AIDED GEOMETRIC DESIGN. Thomas W. Sederberg

Quaternions and Rotations

Chapter 15: Functions of Several Variables

3D Polygon Rendering. Many applications use rendering of 3D polygons with direct illumination

Quaternions and Rotations

Computer Graphics 7: Viewing in 3-D

3D Transformations World Window to Viewport Transformation Week 2, Lecture 4

Central issues in modelling

Transforms. COMP 575/770 Spring 2013

Computer Viewing. CITS3003 Graphics & Animation. E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley

Transformations. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Generalized barycentric coordinates

Rotations in 3D Graphics and the Gimbal Lock

Viewing with Computers (OpenGL)

Computer Animation Fundamentals. Animation Methods Keyframing Interpolation Kinematics Inverse Kinematics

Rotation and Orientation: Fundamentals. Perelyaev Sergei VARNA, 2011

12.1 Quaternions and Rotations

Rotation parameters for model building and stable parameter inversion in orthorhombic media Cintia Lapilli* and Paul J. Fowler, WesternGeco.

Vector Algebra Transformations. Lecture 4

with slopes m 1 and m 2 ), if and only if its coordinates satisfy the equation y y 0 = 0 and Ax + By + C 2

Outline. ETN-FPI Training School on Plenoptic Sensing

METR Robotics Tutorial 2 Week 2: Homogeneous Coordinates

CS612 - Algorithms in Bioinformatics

Computer Graphics I Lecture 11

2D TRANSFORMATIONS AND MATRICES

2D and 3D Coordinate Systems and Transformations

3D Transformations. CS 4620 Lecture 10. Cornell CS4620 Fall 2014 Lecture Steve Marschner (with previous instructors James/Bala)

Differential Geometry: Circle Patterns (Part 1) [Discrete Conformal Mappinngs via Circle Patterns. Kharevych, Springborn and Schröder]

Transformations. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Mathematical Tools in Computer Graphics with C# Implementations Table of Contents

3D Computer Vision II. Reminder Projective Geometry, Transformations. Nassir Navab. October 27, 2009

Basic Elements. Geometry is the study of the relationships among objects in an n-dimensional space

Objectives. transformation. General Transformations. Affine Transformations. Notation. Pipeline Implementation. Introduce standard transformations

Vectors and the Geometry of Space

Chapter 5. Projections and Rendering

Algebraic Geometry of Segmentation and Tracking

Freeform Curves on Spheres of Arbitrary Dimension

3D Computer Vision II. Reminder Projective Geometry, Transformations

Humanoid Robotics. Projective Geometry, Homogeneous Coordinates. (brief introduction) Maren Bennewitz

Unit Activity Correlations to Common Core State Standards. Geometry. Table of Contents. Geometry 1 Statistics and Probability 8

Chapter 8 Three-Dimensional Viewing Operations

Isometries. 1 Identifying Isometries

Today s Agenda. Geometry

CSE452 Computer Graphics

UNIT 2 2D TRANSFORMATIONS

Transcription:

Jorg s Graphics Lecture Notes Coordinate Spaces Coordinate Spaces Computer Graphics: Objects are rendered in the Euclidean Plane. However, the computational space is better viewed as one of Affine Space Projective Space Grassmann space Tensor Algebra Clifford space Euclidian Space Rules of the Space With the inner product ( ) and cross product ( ), we have angles ( v w ), lengths ( v v ), area ( v w ) and volume ( (u v) w ). Working with Multiple Vectors v w Projection of the vector v onto the vector w: Perpendicular component of v to w: ṽ := v v w Reflection of v across w: v 2ṽ w w w w w w w Point Transformations The linear map that maps four points p 0, p, p 2, p 3 to four points p 0, p, p 2, p 3 can be computed as follows: () set v i := p i p 0, v i := p i p 0. (2) Then v 3 = M M v 3, M := [v,v 2,v v 2 R 3 3. Exercise: Parameterize a rotation about a line in 3-space.

Jorg s Graphics Lecture Notes Coordinate Spaces 2 Affine Space Affine Space has two kinds of elements: points (location) p and vectors (direction) v. i λ iv i is a vector; i λ ip i is an allowable operation only if i λ i =. Affine coordinates in R 3 : append a 0 or as 4th coordinate [ p := [ p p 2 p 3 T ; [ v 0 := [ ṽ ṽ 2 ṽ 3 0 T. Translation 0 0 t x x x + t x 0 0 t y y 0 0 t z z = y + t y z + t z. 0 0 0 Rotation: with s := sin(θ), c := cos(θ) c s 0 0 x cx sy s c 0 0 y 0 0 0 z = sx + cy z. 0 0 0 Rigid transformations = translation, rotation and reflection. Orthographic projection 0 0 0 0 0 0 0 0 0 0 0 0 0 Plane with normal n, all (x, y, z) such that [ x n x n y n z n c y z = 0 Conic, all (x, y) such that [ x y Q Q 2 L Q 2 Q 22 L 2 x y = 0 L L 2 C 0 Quadric, all (x, y, z) s.t. [ x y z Q Q 2 Q 3 L x Q 2 Q 22 Q 23 L 2 y Q 3 Q 23 Q 23 L 3 z = 0 L L 2 L 3 C 0

Jorg s Graphics Lecture Notes Coordinate Spaces 3 The Bernstein-Bézier form is well-defined since i b i(u) = for b i (u) := ( d ) i ( u) d i u i. Shortcomings of Affine Space for Graphics: While vectors can be added to vectors and points, points can only be added under extra constraints. Therefore there are two disjoint copies of Euclidean space. P P i wipibi(u) i wibi(u) The rational Bernstein-Bézier form be represented because generally w i {0, }. Perspective projection cannot be represented i [ wipi w i b i (u) cannot Projector Object Object COP Projection plane vs DOP Projector Projection plane

Jorg s Graphics Lecture Notes Coordinate Spaces 4 Projective Space, Homogenous Coordinates Projective Space has two kinds of elements: Affine Points and Points at Infinity. The points can be modeled by embedding in a space of one more dimension, as homogenous coordinates. Homogenous Representation Of an affine point is [ x x 2... x n x n+ T for xn+ 0; Of a point at infinity is [ x x 2... x n 0 T ; Completes the geometry of Affine Space: A pair of lines always intersects in a point, possibly at infinity. (advanced) More generally, Bezout s Theorem holds in complex projective space: for polynomials p(x,y) and q(x,y) that have no common factor and are of degree m and n repectively, the curves p(x,y) = 0 and q(x, y) = 0 have mn intersections. Perspective Scaling 0 0 0 x 0 0 0 y 0 0 0 z = 0 0 0 /k x y z /k = kx ky kz. Frustum, Clipping (Projection into 3D double unit box) with x := x x = (xmax-xmin) etc. 2 x 0 0 x+x x glfrustum(xmin,xmax,ymin,ymax,near,far) 2 0 y 0 ȳ+y y 2 0 0 z z+z z 0 0 0 Maps a viewing frustum (rectangular box) to [, 3. Example: (A point between x and x is mapped to the interval [, ) x = 4, x = 0, x = 4, x+x x =, 2 x = /2. Then [ 3 is mapped to [ /2. Duality theorems hold: points and planes (represented by normals) behave (almost) identically. (advanced) Pascal s and Brianchon s Theorems hold: Pascal: inscribe a hexagon in a conic; then opposite edges intersect in three points that are collinear. Brianchon: circumscribe a hexagon about a conic; then the diagonals are concurrent.

Jorg s Graphics Lecture Notes Coordinate Spaces 5 Shortcomings of Projective Space for Graphics A point on a projective line does not split the line into two parts: a person looking in one unobstructed direction sees his on back. Construction of curves is unintutive. There is no notion of length. It is not a vector space. Addition of homogeneous coordinates (here n = 2) does not work: 2 = 2 4, 3 2 = 9 6, but 2 + 3 2 = 4 4 0 = 2 4 + 9 6. 3 6 3 3 4 9 6 3 Therefore i [ pi w i b i (u) does not make sense. To complete the algebra (to make sense of the addition of 4-vectors) we will need a Grassmann space.

Jorg s Graphics Lecture Notes Coordinate Spaces 6 Grassmann space A (n + dimensional) linear vector space where points are of the form [ wp w. Then addition of these weighted mass points is according to (Archimedes law of the lever): [ wp w + [ w2p2 w 2 = [ wp+w2p2 w +w 2 = (w + w 2 )[ wp +w 2p 2 w +w 2 In particular, the Euclidean component is w p + w 2 p 2 w + w 2.. [ wp+w2p2 w +w 2 [ w2p2 w 2 affine points [ wp w [ p [ p2 affine vectors [ w p +w 2 p 2 w +w 2 [ 0 0

Jorg s Graphics Lecture Notes Coordinate Spaces 7 Perspective Projection Let ˆn be the projection plane (ˆn := [ n d ; n is the normal and d the distance to the 0 R 3 ) and ê the eye position. The perspective projection matrix P in Grassmann coordinates is Then the projection is P := outerprod(ê, ˆn) diag(ê ˆn). p + := P ˆp = ê(ˆn ˆp) (ê ˆn)ˆp. To verify, intersect the line through the points ˆp := [ wp w and ê with the plane ˆnˆx = 0. and check that ˆn p + = 0. Example: (vertical z direction, horizontal x direction, no y) ê ˆx : ˆx ˆn = 0 p + (perspective projection) ˆn depth(p) p For example, in homogenous coordinates [ x z w (i.e. we drop the y dimension and the projection plane is a projection line), let ê := [ 4 4 ˆp, ˆp := [ 2 2 and ˆn := [ 0, i.e. the projection plane is the line {(x, z, ) : z = } (since [ x z [ 0 = 0 is the equation of the plane). Then p + := 3[ 4 4 3[ 2 2 = [ 6 6 [. 6 Tensor Algebra Transformation of normal: by inverse of vertex transformation matrix: ˆn T ˆx = 0 (ˆnM )(Mˆx). ˆx (points, tangents) are contra-variant. ˆn (normals) are co-variant. M (transformation) contra-variant 2-tensor. Q (conic section) co-variant 2-tensor.

Jorg s Graphics Lecture Notes Coordinate Spaces 8 3D interfaces Trackball Goal: convert a 2D (integer) change of mouse position to a rotation in 3D. Sample Code 4track.c Description Associate each mouse position = (i, j) with the point on a unit hemisphere: () For w=width, scale the x component to (2i w)/w and the y component to (2j w)/w. (2) set z := x 2 y 2. centered, but mouse starts at 0 Two consecutive points P and P 2 on the hemisphere define a normal direction n = P P 2. Rotate about n.

Jorg s Graphics Lecture Notes Coordinate Spaces 9 3D interfaces Problems with Euler angles Rotate about x, y, z axis Anisotropy, Coordinate system dependence: The ordering and orientation of the coordinate axes is important. (The parameters lack a simple, local geometric interpretation.) Finding the Euler angles for a given orientation is difficult. (although getmatrix() helps) Gimbal Lock: a degree of freedom can vanish. However, easy to implement and widely used. Gimbal lock: Mechanical problem that arises in the support of gyroscopes by three nested rotating frames. After a y-rotation by π/2 (rotates x-axis onto z-axis) an x-rotation by α equals z-rotation by α. Objects seem to stick. Some orientations are difficult to obtain from the wrong direction. interpolation through singularity behaves unpredictable. The effect is simple to see algebraically. If α y = π/2 (and c y = cos(α y ) etc.) then c y 0 s y 0 0 0 0 R y = 0 0 0 s y 0 c y 0 = 0 0 0 0 0 0 0 0 0 0 0 0 and 0 0 0 0 0 0 c z s z 0 0 R x R y R z = 0 c x s x 0 0 0 0 s z c z 0 0 0 s x c x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = s c 0 0 c s 0 0 0 0 0 where c = cos(α x α z ) and s = sin(α x α z ) : only one degree of freedom!

Jorg s Graphics Lecture Notes Coordinate Spaces 0 3D interfaces Quaternions Motivating Analogy: 2D rotation of the point x = (x, x 2 ) by the angle α can be expressed as multiplication with a matrix of the form [ c s c := cos(α),, s c s := sin(α). or, alternatively, expressing x as the complex number x +ix 2 where i :=, as multiplication in the complex field by e iα = cos(α) + i sin(α). The appropriate field for expressing rotations in 3D are the (normalized) quaternions ˆq := q 0 + iq + jq 2 + kq 3 = (q 0, q, q 2, q 3 ) =: (q 0,q), where q := (q, q 2, q 3 ) is a vector in R 3. Quaternions have the multiplication table i j k i k j j k i k j i The product of two quaternions ˆp and ˆq is again a quaternion: ˆp ˆq = (p 0 q 0 (p q + p 2 q 2 + p 3 q 3 ), p 0 q + q 0 p + p q). We define ˆq 2 = q 2 0 + q q. This implies (check that ˆq ˆq is real) Construction and Use ˆq = (q 0, q)/ ˆq 2 Quaternion for rotation about x R 3 by α: ˆq = (cos(α/2), sin(α/2) x x ) Rotation of the point v := (v, v 2, v 3 ): ˆq (0,v) ˆq. Note: ˆq and ˆq represent the same rotation and rotation by 0 and 360 degrees coincide.

Jorg s Graphics Lecture Notes Coordinate Spaces Interpolating Quaternions for Animation Spherical linear interpolation of rotations (for animation) where φ = acos(ˆp, ˆq) is the angle between ˆp and ˆq viewed as vectors in R 4 : slerp(ˆp, ˆq, t) = ˆp(ˆp ˆq) t = ˆp tˆq t = sin( t)φ ˆp + sin(tφ) sin φ sin φ ˆq. To move from ˆp to ˆq vary t from 0 to. If ˆp or ˆq are not of the same size then angular speed will vary. Hence use only unit quaternions (slerp moves on sphere in 4D along a great arc). Better: quaternion splines Sample Code 4quaternion.c Use the arrows to see motion along a B- spline Quaternions: (advanced) Derivation: The trace of any rotation matrix with angle α is + 2 cos(α). *Therefore* q 0 = cos(α/2) and for some scalar k q 0 = cos(α/2), q = kx. To normalize the quaternion choose k = sin(α/2)/ ˆq since = ˆq = cos(α/2) 2 + k 2 x x. Any rotation matrix can be expressed in terms of a quaternion as 2q2 2 2q2 3 2(q q 2 + q 0 q 3 ) 2(q q 3 q 0 q 2 ) 2(q q 2 q 0 q 3 ) 2q 2 2q3 2 2(q 2 q 3 + q 0 q ) 2(q q 3 + q 0 q 2 ) 2(q 2 q 3 q 0 q ) 2q 2 2q2 2 (more symmetric than Euler) Rotation about x-axis by α: ˆq = (c, s, 0, 0) where c = cos(α/2) and 0 0 0 2s 2 2sc, sin(α) = 2sc, cos(α) = 2s 2. 0 2sc 2s 2 One can also convert from rotation matrix to quaternion.

Jorg s Graphics Lecture Notes Coordinate Spaces 2 Camera Position A change of the model-view (multiplication by model-view matrix) can be interpreted either as (a) changing subsequent camera position or (b) applying the inverse motion to the world (and the camera always looks down negative z axis). In matrix notation, object O, camera C, transformation matrices M i M 3 M 2 M O and C is the same as M O and M 2 M 3 C Specification of the camera requires six scalars 3 for the position (View Reference Point) and 3 for the orientation (2 for the (normalized) view-plane normal and (angle) for the up-direction.) Instead of the normal to the view-plane, an unnormalized 3-vector at can be chosen. Instead of the up-direction v to the view-plane, an unnormalized 3-vector up can be chosen; the projection into the view plane v := up up at at at at defines the up direction in the view plane. (Check n v = 0.) glulookat(eyex, eyey, eyez, atx,aty,atz, upx,upy,upz) (at x, at y, at z ) y (up x, up y, up z ) x (eye x, eye y, eye z ) z

Jorg s Graphics Lecture Notes Coordinate Spaces 3 Relative Coordinates and Angle-based Coordinates y y y x x x z z Roll Pitch Yaw z n Elevation Azimuth