Online Graphics Basic Math: Creating a Coordinate Frame
Articles Blog

Online Graphics Basic Math: Creating a Coordinate Frame

October 24, 2019


Welcome. In this segment, we are going to
see how to use dot and cross products to create an orthonormal coordinate frame which will
be useful in many applications. Orthonormal bases and coordinate frames are
important for representing points, positions, locations. Often there are many different sets of coordinate
systems. So not just your single XYZ coordinate systems. In graphics this is very common that
you will have a coordinate system associated with the model, you will have a coordinate
system associated with the local coordinates, you will have a coordinate system associated
with the world, you may even have separate coordinate systems for the head, for the shoulder,
for the hands, for the torso, for the legs, for the shoes, so on. And a very important part is to get all of
these different objects in their consistent frame of reference. So a critical issue is
transforming between these different coordinate systems. In fact the next 3 lectures deal
with the transformations and viewing and the way in which you can use matrices and vectors
for that purpose. So what is a coordinate frame? It’s any set
of 3 vectors in 3 dimensions, such that the vectors are of unit norm. Such that the vectors
are mutually orthogonal to each other. And such that they obey this cross product relationship,
which is that w is equal to u cross v. You can think of all of these in terms of X, Y
and Z. Of course, the unit X, Y and Z vectors are of unit norm. Of course they’re mutually
orhtogonal with respect to each other. And, of course, the Z vector is simply equal to
X cross Y. One of the interesting things about this is
that a vector p can be written in terms of its projections onto the vectors u, v and
w. So, p dot u is the projection onto the vector u, with the vector u. p dot v is the
projection onto the vector v, times the vector v. p dot w is the projection onto the vector
w, times the vector w. How do you construct the coordinate frame?
So, the first question, why do you want to construct the coordinate frame? It’s often
the case that you’re given a vector a, which in homework 1, will be the viewing direction.
You want to create an orthonormal basis from this. But of course, an orthonormal basis
involves 3 unit vectors and you can’t get it from a single vector, so need a second
vector b, which in homework 1 is the up direction of the camera. So given 2 vectors a and b, how to you create
an orthonormal coordinate frame? Intuitively, you want to associate the vector w with a
and the vector v with b. But, a and b are neither orthogonal vectors nor are they a
unit norm, and we also need to find the u vector. First let’s try to find what the vector w
is equal to. And the vector w should just be given by the vector a in this case. But
the only problem with this is that A is not of unit norm, so we need to normalize it. And we simply divide by the magnitude of the
vector a. So that part is simple, the vector w is equal to the a divided by the unit norm
of a. But how do we get v and u? That part is complicated, so why is is complicated?
If the vector b is orthogonal to the vector a you’re completely fine, you can just define
b based on that. The vector b may not be orthogonal to the
vector a. So one thing to do is to remove its projection in the direction of a which
would be a dot product but there is in fact a more elegant way of doing this. Even though
b and now w are not necessarily orthogonal to each other we can use the cross product
to find the third vector which is orthogonal to both b and w. So instead of finding the
vector v, we first find the vector u. You write the vector u as equal to b cross product
with w and divide the whole thing by the norm of b cross w. And that’s the formula I have written here,
u is equal to b cross w divided by the norm of b cross w. The final step we need here,
is to find the vector v, but given w and u, v is given by, w cross product with u. In
this way you have created a complete coordinate frame, given 2 vectors, that need not be unit
norm, that need not be orthogonal. Of-course this fails when the norm, when this
quantity is equal to zero, so if b and w are aligned with each other, in which case their
cross product is equal to zero, then they are really the same vector, a and b are the
same vector and you cannot create the coordinate frame.

Only registered users can comment.

Leave a Reply

Your email address will not be published. Required fields are marked *