Download presentation
Presentation is loading. Please wait.
1
GAM 325/425: Applied 3D Geometry
Lecture 4, Part A: (Extra Topics) Matrix Information and Coordinate Change
2
World Matrix Information
z x π 1 π 2 π 3 Consider our friendly TGO again place in world space. Assume its current position/orientation is given by W which, in turn was created in TRS form. Looking at W, what do we know? Specifically: Without the picture and just W, what could you tell about the TGO ? Actually: quite a bitβ¦ If W was created from an unknown set of TRS matrices, then we can assume π= π€ 00 π€ 01 π€ 02 π€ 03 π€ 10 π€ 11 π€ 12 π€ 13 π€ 20 π€ 21 π€ 22 π€ 23 π€ 30 π€ 31 π€ 32 π€ 33 π= π πππ = π π π for some values π, π and π π= π‘ π₯ π‘ π¦ π‘ π§ for some vector π= π‘ π₯ π‘ π¦ π‘ π§ and π= πβ² π π π 1 = π 00 π 01 π π 10 π 11 π π 20 π 21 π for some rotation matrix R.
3
World Matrix Information
Therefore So W actually has a lot of structures for us to exploit. Letβs looks at these structures more closely π= π€ 00 π€ 01 π€ 02 π€ 03 π€ 10 π€ 11 π€ 12 π€ 13 π€ 20 π€ 21 π€ 22 π€ 23 π€ 30 π€ 31 π€ 32 π€ 33 = π‘ π₯ π‘ π¦ π‘ π§ π 00 π 01 π π 10 π 11 π π 20 π 21 π π π π = π‘ π₯ π‘ π¦ π‘ π§ π π 00 π 10 π π π 01 π 11 π π π 02 π 12 π = π π 00 π 10 π π π 01 π 11 π π π 02 π 12 π π‘ π₯ π‘ π¦ π‘ π§
4
World Matrix Information
What can we know from this? The last column contains that center/position for the TGO in world coordinate The upper-left 3x3 is the combination of the TGOβs scale and rotation What if π=π=π=1 (very common), or you know R or πβ² ? HINT: for any linear/affine transform, the columns of the matrix form are computed by transforming the basis vectors. In local space, it must be the that that Local x axis is π 00 π 10 π 20 , local y axis is π 01 π 11 π and local z axis is π 02 π 12 π 22 Since R is a rotation matrix, you know these vector are also unit length Note: if π πππ β π and/or you didnβt know R, then the above axis vectors would be scaled by a, b and c respectively π= π π 00 π 10 π π π 01 π 11 π π π 02 π 12 π π‘ π₯ π‘ π¦ π‘ π§
5
World Matrix Information
Putting it all together: Given a world matrix created in TRS form You can immediately identify: The origin of the local space π=( π‘ π₯ , π‘ π¦ , π‘ π§ ) The column vectors are the local axis (perhaps scaled) π± β² =π( π 00 , π 10 , π 20 ), π β² =π( π 02 , π 12 , π 22 ) and yβ not shown here But Importantly: the reverse is also true! If you know The position of an object Its scale The direction of its main axes (where is forward, up, left) You can reconstruct the W matrix! π= π π 00 π 10 π π π 01 π 11 π π π 02 π 12 π π‘ π₯ π‘ π¦ π‘ π§ z x π z' xβ
6
World Matrix Information
Example: If you know that the TGO is: At position (14, 0, 10) Has its forward axis along (1, 0, 1) Has itβs up axis along (0, 1, 0) Has scale (2, 2, 2) Then we can recover W. Step 1: Normalize the axes. Up is ok, but normalized forward is (0.707, 0, 0.707) Step 2: Get the Left axis = Up x Fwd = (0.707, 0, ) π= π π 00 π 10 π π π 01 π 11 π π π 02 π 12 π π‘ π₯ π‘ π¦ π‘ π§ = β z x π z' xβ
7
World Matrix Information
Similarly: If you know that the TGO was placed in world with the follow matrix: Then you can recover the scale, rotation and translation: From the last column π= π (14,0,10) Taking the length of each of the first 3 columns, we have π= π (2,2,2) Dividing each of the first 3 columns by its associated length, we get R π=πππ= β z x π z' xβ π= β
8
Coordinate Change (a.k.a Change of Basis)
A change of basis allows you to compute what the world looks like from a specific point and orientation in space. Neither Blue nor Purple are moved here!!! Weβre only expressing position and orientation relative to different spaces, namely World, Local to Blue and Local to Purple z x z x x z World Space: Blue: (5,0,5), Rot-y Ο/4 Purple: (12,0,16), Rot-y 3Ο/4 Blue Object Space: Blue: (0,0,0) and no rotation Purple: (-2.83,0, 12.73), Rot-y Ο/2 Purple Object Space: Blue: (12.72,0, 2.83), Rot-y βΟ/2 Purple: (0,0,0) and no rotation
9
Coordinate Change Coordinate changes are very useful because they can simplify some operations Example: Last week, we saw that rotations about a point C other than the origin was accomplished by first applying a translation by βC. This was, in effect, a simplified coordinate change Two places where these coordinate change will come in handy: Camera projection/processing Collision detection So letβs see how we can compute there coordinate changes
10
Coordinate Change: Translation Only
Letβs consider a simple case: A coordinate change involving only a translation. How does the world look from Blueβs perspective? Visually: you need to shift every point in space by (minus) Blueβs translation. Or, in other words: apply the transform π π΅ππ’π β1 = π βπ΅ to everything in the world IMPORTANT: Neither Blue nor Purple are moved in this process!!! The relative positions would likely be used by some algorithm/process x z World Space: π π΅ = (5,0,5) π π = (12,0,16) π π΅ππ’π = π π΅ π ππ’ππ = π π x z Blue Object Space: Blue Object Space: Blueβs position: π βπ΅ π π΅ 1 = π π΅ β π π΅ 1 = π 1 Purpleβs position: π βπ΅ π π 1 = π π β π π΅ 1 =
11
Coordinate Change: Translation Only
Letβs consider a simple case: A coordinate change involving only a translation. How does the world look from Purpleβs perspective? Visually: apply the transform π ππ’ππ β1 = π βπ As you can see: in both cases we βundidβ whatever translation that had been applied to the object for which we want the βlocal spaceβ x x z Purple Object Space: World Space: π π΅ = (5,0,5) π π = (12,0,16) Purple Object Space: Blueβs position: π βπ π π΅ 1 = π π΅ β π π 1 = β7 0 β11 1 Purpleβs position: π βπ π π 1 = π π β π π 1 = π 1 π ππ’ππ = π π z π π΅ππ’π = π π΅
12
Coordinate Change: Translation & Rotation
Letβs add the rotation element now: what are the relative position and rotations? We already know how to correct for the translation using π βπ΅ To correct for the rotation, we need to βundoβ Blueβs rotation: π π², π
π β1 = π π², βπ
π Blueβs apparent Transform becomes: πβ² π΅ππ’π = π π², βπ
π π βπ΅ π π΅ π π², π
π =π Purpleβs apparent transform becomes πβ² ππ’ππ = π π², βπ
π π βπ΅ π π π π², ππ
π = π π², βπ
π π πβπ΅ π π², ππ
π This requires some visualizationβ¦. x z Blue Object Space: (applying π π², βπ
π π βπ΅ ) x z World Space: π π΅ = (5,0,5) π π = (12,0,16) π π΅ππ’π = π π΅ π π², π
π π ππ’ππ = π π π π², ππ
π x Blue Object Space: (applying π βπ΅ ) z
13
Coordinate Change: Translation & Rotation
Whatβs Purpleβs position/orientation using πβ² ππ’ππ = π π², βπ
π π πβπ΅ π π², ππ
π ? Letβs take it in steps (right to left, of course). Step 0: Purpleβs default/base position and orientation Step 1: Apply π π², ππ
π Step 2: Apply π πβπ΅ (recall that πβπ΅=(7,0,11) ) Step 3: Apply π π², βπ
π (R works around the origin!) Note: this induces both a rotation and a translation Mathematically: π π¦, βπ = cos βπ sin βπ β sin βπ cos βπ = β And this matches the previous diagram x z Blue Object Space: Step 0 Step 2 Step 1 Step 3
14
Coordinate Change: Technique:
In both cases weβve just seen, the approach was the same: Given two objects A and B in world space using world matrices π π΄ and π π΅ , we can compute the relative world matrices πβ² π΅ of object B in Aβs local space using the following formula: πβ² π΅ = π π΄ βπ π π΅ Furthermore, if π π΄ was produced in TRS form, then πβ² π΅ = π π΄ π π΄ π π΄ βπ π π΅ = π π΄ β1 πΉ π΄ β1 π» π΄ β1 π π΅ Now you see why matrix inverses are so important! Remember: The inverse of a product is the REVERSE product of inverses
15
Coordinate Change: Translation, Rotation & Scaling
The technique used so far also works in general (even without TRS forms). However, showing it in action using two objects each changing rotation, translation and scaling gets to be a bit hard to visualize. To simplify a bit, letβs assume that Only the Blue object changes its scale Blueβs scale is changed by a uniform π 1 2 x z World Space: π π΅ = (5,0,5) π π = (12,0,16) π π΅ππ’π = π π΅ π π², π
π π π π π ππ’ππ = π π π π², ππ
π
16
Coordinate Change: Translation, Rotation & Scaling
Given this set up: Clearly the relative orientations will be the same as before. But surprisingly, the position information will not be the same. Letβs compute Purpleβs matrix in Blueβs local space: πβ² ππ’ππ = π π΅ π y, π 4 π 1 2 βπ π ππ’ππ = π 2 π y, βπ 4 π βπ΅ π ππ’ππ But whatβs the effect of that final π π ? x z Blue Object Space: x World Space: π π΅ = (5,0,5) π π = (12,0,16) π ππ’ππ = π π π π², ππ
π Note: in local space, Blue is not scaled z π π΅ππ’π = π π΅ π π², π
π π π π
17
Coordinate Change: Translation, Rotation & Scaling
Given this set up: Clearly the relative orientations will be the same as before. But surprisingly, the position information will not be the same. Letβs compute Purpleβs matrix in Blueβs local space: πβ² ππ’ππ = π π΅ π y, π 4 π 1 2 βπ π ππ’ππ = π 2 π y, βπ 4 π βπ΅ π ππ’ππ Sidebar: This is why uniform scaling is so desirable: Non-uniform scaling distorts objects in local space. For example: collision systems relying on bounding spheres donβt work with non-uniform scaling is since the radius becomes meaningless in local space. x z x World Space: π π΅ = (5,0,5) π π = (12,0,16) Blue Object Space: (applying π π², βπ
π π βπ΅ ) π π β = β π ππ’ππ = π π π π², ππ
π Scale changes affect both size & distance in local space Ex: To Ant-man, things look bigger and he has to run βrelatively fartherββ¦ z π π΅ππ’π = π π΅ π π², π
π π π π
18
World Matrix and Coordinate Change
Weβve covered: Reconstructing a world matrix from an objectβs position and direction information Extracting position/direction from a world matrix in TRS form Converting between world space and local space Taken together, these techniques will be extremely useful for manipulating 3D scenes and objects.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.