Difference between revisions of "Discussion8S16"

From Immersive Visualization Lab Wiki
Jump to: navigation, search
(Added slide.)
 
m (Moving Points Along the Axes)
 
(5 intermediate revisions by one user not shown)
Line 5: Line 5:
  
 
==Mystery of the Orientation==
 
==Mystery of the Orientation==
 +
As we move our coaster along the track, not only do we have to translate it, we must rotate it to look natural as well. How do we achieve this?
 +
 +
[[File:Axisrotation00.PNG|400px]]
 +
 +
Well, since rotating the whole pod should be achievable by rotating the toWorld, let's think of this in terms of the toWorld's axis.
 +
 +
[[File:Axisrotation01.PNG|400px]]
 +
 +
Our goal is to transform the axis on the left, to the one on the future. This is looking very much like a coordinate transformation, much like what we did with our cameras! (If coordinate transform doesn't ring a bell, read up on the [[Media:03_ProjectionS16.pdf|Projection lecture]] to see how coordinate transformation are defined.)
 +
 +
Remember that the coordinate transformation matrix can be found by finding the x, y, and z basis vectors and the translation. So how will we go about finding those x, y, and z?
 +
 +
First off z is most simple right? It's simply the direction our pod is moving down the curve. In other words, it will be:
 +
<pre>Z = target - pos</pre>
 +
Well, we're not quite done yet though. We have to normalize that Z so that we don't unintentionally introduce a scale factor.
 +
<pre>Z = normalize(target - pos)</pre>
 +
 +
Next, between X and Y, which do we look for first? Think back to the order in which we calculated the Camera Matrix. Only one of these is certain from Z, and that's going to be the X vector. As long as our pod is staying upright, we can assume our up vector is going to be <code><0, 1, 0></code>, i.e. straight up in world coordinates. Given Z and up, we can find the vector that is perpendicular, to both of them, which will be our X vector.
 +
<pre>X = normalize(cross(<0, 1, 0>, Z))</pre>
 +
 +
Now, finally we can find the final Y axis, by again finding the vector that is perpendicular to both the Z and X. Be careful of your ordering!
 +
<pre>Y = normalize(cross(Z, X))</pre>
 +
 +
We can now complete this picture and find the basis vectors:
 +
[[File:Axisrotation02.PNG|400px]]
 +
 +
Again, if you're not sure what to do with the bases once you've found them, refer back to the [[Media:03_ProjectionS16.pdf|Projection lecture]].
  
 
==Point Control==
 
==Point Control==
 +
Now that our static tracks are set up, and we have the ability to select our points, let's add the ability to move them.
 +
 +
Probably the most immediate intuitive way to move the points is to move it in relation to the camera's view:
 +
 +
[[File:pointtranslation00.PNG|400px]]
 +
 +
How do we accomplish this? Well, in essence we're moving the object in the camera's X and Y axes. So if we find the camera's X and Y axes, we will be able to move our object along the camera's X-Y plane.
 +
 +
===Finding the Camera's Axes===
 +
 +
So do we remember how to find the camera's X-Y plane from the [[Media:03_ProjectionS16.pdf|Projection lecture]]? Fear not, we've reproduced it down below:
 +
 +
(Note: We've crossed out the y-axis being <code>up</code> normalized because that's not always true.)
 +
 +
[[File:pointtranslation01.PNG|400px]]
 +
 +
Now that we've found the desired axes that we want to move the points along, how do we move points along them?
 +
 +
===Moving Points Along the Axes===
 +
 +
Well, let's simplify the problem: how do we move a point along a single axis?
 +
 +
Let's say we have a point <code>p</code> and the normalized vector <code>v</code> that represents an axis. How do I move length one across the vector? We can simply add <code>v</code> to <code>p</code> such that
 +
 +
<pre>
 +
result = p + v
 +
</pre>
 +
 +
How about moving one length in the opposite direction along <code>v</code>? Well we can subtract <code>v</code>.
 +
 +
<pre>
 +
result = p - v
 +
</pre>
 +
 +
The common idea here is that we're moving along the axis <code>v</code> by adding some scalar multiplication of <code>v</code>. Thus moving the point along <code>v</code> some arbitrary amount <code>s</code> would look like:
 +
 +
<pre>
 +
result = p + s * v
 +
</pre>
 +
 +
Great! We've now seen how we can move a point an arbitrary amount along an axis. How about two axes? Well it turns out it's just the linear combination of those two axes. Let's say our x-axis is represented by <code>x</code> and the y-axis by <code>y</code>, and the desired amount of movement along each axis (for example, the amount the mouse moved) is <code>sx</code> and <code>sy</code> respectively. Our final equation would look like such:
 +
 +
<pre>
 +
result = p + sx * x + sy * y
 +
</pre>
 +
 +
There you have it. That's the equation to translate our point <code>p</code> parallel to our camera's image plane.

Latest revision as of 09:35, 26 May 2016

Contents

Overview

Week 8 Discussion recap(05/16/16)

Slides: Download here

Mystery of the Orientation

As we move our coaster along the track, not only do we have to translate it, we must rotate it to look natural as well. How do we achieve this?

Axisrotation00.PNG

Well, since rotating the whole pod should be achievable by rotating the toWorld, let's think of this in terms of the toWorld's axis.

Axisrotation01.PNG

Our goal is to transform the axis on the left, to the one on the future. This is looking very much like a coordinate transformation, much like what we did with our cameras! (If coordinate transform doesn't ring a bell, read up on the Projection lecture to see how coordinate transformation are defined.)

Remember that the coordinate transformation matrix can be found by finding the x, y, and z basis vectors and the translation. So how will we go about finding those x, y, and z?

First off z is most simple right? It's simply the direction our pod is moving down the curve. In other words, it will be:

Z = target - pos

Well, we're not quite done yet though. We have to normalize that Z so that we don't unintentionally introduce a scale factor.

Z = normalize(target - pos)

Next, between X and Y, which do we look for first? Think back to the order in which we calculated the Camera Matrix. Only one of these is certain from Z, and that's going to be the X vector. As long as our pod is staying upright, we can assume our up vector is going to be <0, 1, 0>, i.e. straight up in world coordinates. Given Z and up, we can find the vector that is perpendicular, to both of them, which will be our X vector.

X = normalize(cross(<0, 1, 0>, Z))

Now, finally we can find the final Y axis, by again finding the vector that is perpendicular to both the Z and X. Be careful of your ordering!

Y = normalize(cross(Z, X))

We can now complete this picture and find the basis vectors: Axisrotation02.PNG

Again, if you're not sure what to do with the bases once you've found them, refer back to the Projection lecture.

Point Control

Now that our static tracks are set up, and we have the ability to select our points, let's add the ability to move them.

Probably the most immediate intuitive way to move the points is to move it in relation to the camera's view:

Pointtranslation00.PNG

How do we accomplish this? Well, in essence we're moving the object in the camera's X and Y axes. So if we find the camera's X and Y axes, we will be able to move our object along the camera's X-Y plane.

Finding the Camera's Axes

So do we remember how to find the camera's X-Y plane from the Projection lecture? Fear not, we've reproduced it down below:

(Note: We've crossed out the y-axis being up normalized because that's not always true.)

Pointtranslation01.PNG

Now that we've found the desired axes that we want to move the points along, how do we move points along them?

Moving Points Along the Axes

Well, let's simplify the problem: how do we move a point along a single axis?

Let's say we have a point p and the normalized vector v that represents an axis. How do I move length one across the vector? We can simply add v to p such that

result = p + v

How about moving one length in the opposite direction along v? Well we can subtract v.

result = p - v

The common idea here is that we're moving along the axis v by adding some scalar multiplication of v. Thus moving the point along v some arbitrary amount s would look like:

result = p + s * v

Great! We've now seen how we can move a point an arbitrary amount along an axis. How about two axes? Well it turns out it's just the linear combination of those two axes. Let's say our x-axis is represented by x and the y-axis by y, and the desired amount of movement along each axis (for example, the amount the mouse moved) is sx and sy respectively. Our final equation would look like such:

result = p + sx * x + sy * y

There you have it. That's the equation to translate our point p parallel to our camera's image plane.