1 of 42

Geometry: �Coordinates & Cameras

Instructor: Christopher Rasmussen (cer@cis.udel.edu)

Course web page:

https://goo.gl/th9HB2

February 13, 2018 ❖ Lecture 3

2 of 42

Outline

  • Coordinate systems
  • More 3-D transformations
    • Setting up the camera
  • Projections
    • Orthographic
    • Perspective
  • Marschner readings: 6.5-7.2

3 of 42

Coordinate Systems

  • What does it mean to say a point x = (x, y, z) is in a certain coordinate system or frame?
  • One way to think of x is as a weighted sum (aka linear combination) of basis vectors representing the frame’s axes
  • So x = x(1, 0, 0) + y(0, 1, 0) + z(0, 0, 1) in the local frame

x

Z

X

Y

4 of 42

Coordinate Systems

  • If the frame of interest is embedded in another frame F, then its origin and axes can be represented in F as a point o and unit vectors i, j, and k, respectively

x

k

i

j

F

o

Z

X

Y

5 of 42

Coordinate Systems

  • If the frame of interest is embedded in another frame F, then its origin and axes can be represented in F as a point o and unit vectors i, j, and k, respectively
    • These vectors can have any orientation in F, but are all orthogonal to each other
    • Later we will also refer to these with u, v, n or

u, v, w (sorry!)

x

w

(or n)

u

v

F

o

Z

X

Y

6 of 42

Coordinate Systems

  • Now x, which in the local coordinate frame is just (x, y, z), can be thought of in F as:

x = o + xi + yj + zk

x

k

i

j

F

o

Z

X

Y

7 of 42

Coordinate Systems

  • Now x, which in the local coordinate frame is just (x, y, z), can be thought of in F as:

x = o + xi + yj + zk

x

k

i

j

F

o

Z

X

Y

In Marschner: p + uu + vv + ww

8 of 42

3-D Transformations:� Arbitrary Change of Coordinates

  • A rigid transformation is used to represent a change in the coordinate system that “expresses” a point’s location

YA

XA

ZA

A

x

ZB

XB

YB

B

9 of 42

3-D Transformations:� Arbitrary Change of Coordinates

  • A rigid transformation is used to represent a change in the coordinate system that “expresses” a point’s location

YA

ZA

A

ZB

XB

YB

B

XA

Ax

10 of 42

3-D Transformations:� Arbitrary Change of Coordinates

  • A rigid transformation is used to represent a change in the coordinate system that “expresses” a point’s location

YA

ZA

A

ZB

XB

YB

B

XA

Bx

See Fig. 6.20 in Marschner for 2-D equivalent

11 of 42

3-D Transformations:� Arbitrary Change of Coordinates

  • A rigid transformation is used to represent a change in the coordinate system that “expresses” a point’s location

A

B

12 of 42

3-D Transformations:� Arbitrary Change of Coordinates

  • A rigid transformation is used to represent a change in the coordinate system that “expresses” a point’s location

A

B

M transforms x from A's to B's coordinate system

13 of 42

3-D Transformations:� Translation-only Change of Coordinates

  • A rigid transformation is used to represent a change in the coordinate system that “expresses” a point’s location

Location of A’s origin in

B’s coordinate system

A

B

14 of 42

3-D Transformations:� Arbitrary Change of Coordinates

  • A rigid transformation is used to represent a change in the coordinate system that “expresses” a point’s location

Rotation that makes

A’s axes parallel to B’s,

creating translation-

only case

A

B

15 of 42

3-D Transformations:� Arbitrary Change of Coordinates

  • A rigid transformation is used to represent a change in the coordinate system that “expresses” a point’s location

A

B

16 of 42

3-D Rigid Transformations

  • Combination of rotation followed by translation, without scaling, etc.
  • “Moves” an object from one 3-D pose to another

T

R

M

17 of 42

Rigid Transformations: Homogeneous Coordinates

  • Points in one coordinate system are transformed to the other as follows:

18 of 42

Rigid Transformations: Homogeneous Coordinates

  • Points in one coordinate system are transformed to the other as follows:

same as frame-to-canonical

matrix in Marschner 6.5

19 of 42

Rigid Transformations: Homogeneous Coordinates

  • Points in one coordinate system are transformed to the other as follows:

  • Rows of rotation matrix are B ’s axes “in” A ’s coordinate system

same as frame-to-canonical

matrix in Marschner 6.5

20 of 42

Rigid Transformations: Homogeneous Coordinates

  • Points in one coordinate system are transformed to the other as follows:

  • Rows of rotation matrix are B ’s axes “in” A ’s coordinate system
  • CWM takes the camera to the world origin, transforming points expressed in world coordinates into points expressed in camera coordinates
    • Info needed for M: (1) Camera axes in world coordinates, (2) world origin in camera coordinates

same as frame-to-canonical

matrix in Marschner 6.5

21 of 42

Controlling the camera position

  • Standard OpenGL frame: At (0, 0, 0)T in world coordinates looking in -Z direction (0, 0, -1) with up vector (0, 1, 0)T
    • Up vector controls camera roll (rotation around Z axis)
  • Changing position: "glm::lookAt" function
    • eye = (eyeX, eyeY, eyeZ)T: Desired camera position
    • center = (centerX, centerY, centerZ)T: Point at which camera is aimed (defining “gaze direction”)
    • up = (upX, upY, upZ)T: Camera’s “up” vector

from Woo et al.

22 of 42

glm::lookAt: What It Does

  • Moves scene points so that camera is at origin, “look at” point is on -Z axis, and camera +Y axis is aligned with up vector
  • Create and execute rigid transformation CWM making a change from world to camera coordinates

More details in Marschner, Chapter 7.1.3

23 of 42

glm::lookAt: How It Works

  1. Compute vectors u, v, n defining new camera axes in world coordinates (Marschner textbook uses w instead of n)
    1. “Old” axes are u’ = (1, 0, 0)T, v’ = (0, 1, 0)T, n’ = (0, 0, 1)T
  2. Compute location CoW of old camera position in terms of new location’s coordinate system
  3. Fill in rigid transform matrix

from Hill

center

C

W

24 of 42

glm::lookAt: Camera axes in world coords.

  • Form basis vectors
    • New camera Z axis: n = eye - center
    • New camera X axis: u = up x n
    • New camera Y axis: v = n x u (not necessarily same as up)
  • Normalize so that these are unit vectors

from Hill

center

C

W

25 of 42

glm::lookAt: Camera axes in world coords.

  • Form basis vectors
    • New camera Z axis: n = eye - center
    • New camera X axis: u = up x n
    • New camera Y axis: v = n x u (not necessarily same as up)
  • Normalize so that these are unit vectors

from Hill

center

C

W

26 of 42

glm::lookAt: Camera axes in world coords.

  • Form basis vectors
    • New camera Z axis: n = eye - center
    • New camera X axis: u = up x n
    • New camera Y axis: v = n x u (not necessarily same as up)
  • Normalize so that these are unit vectors

from Hill

center

up

C

W

up and n define a plane

which u is normal to—they

don’t have to be orthogonal

27 of 42

glm::lookAt: Camera axes in world coords.

  • Form basis vectors
    • New camera Z axis: n = eye - center
    • New camera X axis: u = up x n
    • New camera Y axis: v = n x u (not necessarily same as up)
  • Normalize so that these are unit vectors

from Hill

center

C

W

28 of 42

glm::lookAt: Camera axes in world coords.

  • Form basis vectors
    • New camera Z axis: n = eye - center
    • New camera X axis: u = up x n
    • New camera Y axis: v = n x u (not necessarily same as up)
  • Normalize so that these are unit vectors

from Hill

center

C

W

29 of 42

glm::lookAt: Camera axes in world coords.

  • Form basis vectors
    • New camera Z axis: n = eye - center
    • New camera X axis: u = up x n
    • New camera Y axis: v = n x u (not necessarily same as up)
  • Normalize so that these are unit vectors

from Hill

center

C

W

30 of 42

glm::lookAt: Camera axes in world coords.

  • Now make 3 x 3 rotation matrix from formula on rigid transform slide:

31 of 42

glm::lookAt: Location

  • : World origin in camera coordinates

from Hill

center

origin

-eye

C

W

32 of 42

glm::lookAt: Location

  • : World origin in camera coordinates
  • -eye is in world coordinates, so project onto camera axes (and don’t normalize):

from Hill

center

origin

-eye

C

W

33 of 42

glm::lookAt: Matrix

  • Letting and writing the vector components as u = (ux, uy, uz)T, etc., the final transformation matrix is given by:

34 of 42

Transformations vs. Projections

  • Transformation: Mapping within n-D space that “moves points around”
    • E.g., 2-D and 3-D rotation, translation, scaling, shear, but also nonlinear distortions

  • Projection: Mapping from n-D space down to lower-dimensional subspace

35 of 42

Transformations

  • Mapping within n-D space that moves points around
    • Linear transformations (= matrix multiplication) preserve straight lines
    • Some nonlinear transformations in n-D can be expressed by linear ones in (n + 1)-D – the idea behind homogeneous coordinates

36 of 42

Projections

  • Mapping from n-D space down to lower-dimensional subspace
    • E.g., point in 3-D space to point on plane (a 2-D entity) in that space
    • We will be interested in such 3-D to 2-D projections where the plane is the image
    • Things to know:
      • Where are the points?
      • Where is the plane?
      • What kind of projection?

Parallel projection along direction d onto a plane

from Hill

37 of 42

Parallel Projections

Oblique: d in general position

relative to image plane normal n

Orthographic: d parallel to n

from Hill

38 of 42

The Viewing Volume

  • Definition: The region of 3-D space visible in the image
  • Depends on:
    • Camera position, orientation
    • Field of view, image size
    • Projection type
      • Orthographic
      • Perspective

courtesy of N. Robins

39 of 42

Orthographic Projection

  • Projection direction d is aligned with Z axis
  • Viewing volume is “brick”-shaped region in space
    • Not the same as image size
  • No perspective effects—distant objects look same as near ones, so camera (x, y, z) image (x, y)

from Hill

40 of 42

Camera Orientation under Orthographic Projection (set by lookat)

  • Plan: Projection onto XZ (ground) plane
  • Elevations
    • Front: Projection onto XY plane
    • Side: Projection onto YZ plane

courtesy of http://glasnost.itcarlow.ie/~powerk/GeneralGraphicsNotes/projection/orthographicprojection.html

Z

X

Y

41 of 42

Camera Orientation under Orthographic Projection (set by lookat)

  • Isometric: "¾ view" -- axes equally scaled
  • Dimetric: 2 axes the same, 1 different
  • Trimetric: All axes different

By SharkD - Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=8497328

42 of 42

Camera Orientation under Orthographic Projection (set by lookat)

  • Isometric: "¾ view" -- axes equally scaled
  • Dimetric: 2 axes the same, 1 different
  • Trimetric: All axes different

some images courtesy of http://glasnost.itcarlow.ie/~powerk/GeneralGraphicsNotes/projection/orthographicprojection.html

SimCity 2000 (not quite isometric)

Diablo