Discussion:
transforming tangent vectors
(too old to reply)
Miles Bader
2007-12-16 02:52:19 UTC
Permalink
Hi,

When transforming a normal vector (e.g. if you calculate the
intersection normal in object space , and subsequently transform it to
world space), you need to use the tranpose of the inverse of the nominal
transformation matrix:

N' = N * transpose (invers (M))

[and then re-normalize the normal after transformation]

So, how does one normally transform tangent vectors (which together with
the normal form an orthonormal basis)?

It seems that for _one_ of the tangent vectors, you could just use the
nominal transformation matrix, and it will remain perpendicular to the
normal after transformation.

However, what about the _other_ tangent vector (in 3d)? If one uses the
nominal transformation matrix, it also would remain perpendicular to the
normal after transformation, but it looks to me like it might _not_ end
up being perpendicular to the first tangent vector.

I suppose one could just recompute it as the cross product of the other
two transformed vectors:

N' = N * transpose (invers (M))
T1' = T1 * M
T2' = N' x T1'

but i'm not sure I really like this as it makes one tangent vector more
special than the other (which might matter, for instance if the tangent
vectors have some defined relationship to the geometry of the underlying
object)...

Thanks,

-Miles
--
o The existentialist, not having a pillow, goes everywhere with the book by
Sullivan, _I am going to spit on your graves_.
John Tsiombikas
2007-12-16 04:00:55 UTC
Permalink
Post by Miles Bader
When transforming a normal vector (e.g. if you calculate the
intersection normal in object space , and subsequently transform it to
world space), you need to use the tranpose of the inverse of the nominal
N' = N * transpose (invers (M))
[and then re-normalize the normal after transformation]
So, how does one normally transform tangent vectors (which together with
the normal form an orthonormal basis)?
Same way.
Post by Miles Bader
It seems that for _one_ of the tangent vectors, you could just use the
nominal transformation matrix, and it will remain perpendicular to the
normal after transformation.
However, what about the _other_ tangent vector (in 3d)? If one uses the
nominal transformation matrix, it also would remain perpendicular to the
normal after transformation, but it looks to me like it might _not_ end
up being perpendicular to the first tangent vector.
It shouldn't make any difference. All vectors representing "directions"
(as opposed to positions), should transform just fine with the
inverse-transpose.
Care to elaborate on what seems wrong with your second (bitangent?)
vector?
--
John Tsiombikas (Nuclear / Mindlapse)
http://nuclear.sdf-eu.org/
Miles Bader
2007-12-16 04:49:21 UTC
Permalink
Post by John Tsiombikas
It shouldn't make any difference. All vectors representing
"directions" (as opposed to positions), should transform just fine
with the inverse-transpose.
But I don't think that's true -- if you think about a transform
involving a non-inform scaling (e.g., scale by 2 in x-direction, but by
1 in y/z directions), then the normal needs the I-T, but the tangent
needs just the normal transform.

E.g., in 2d, if you imagine a 45-degree surface:

^ <=== normal
\ /
\ /
x
\
\

and you transform it so that it's "stretched" in the x-direction,
(M = [2 0, 0 1]):

^ <=== normal
\_ |
\_ /
x_
\_
\

then notice the _normal_ needs to be transformed by the I-T
(T(I(M)) = [0.5 0, 0 1]), which turns the "x stretch" into a "x shrink"...

[Sorry, the ascii art doesn't really show this well because of font
aspect ratios... :-]

But the tarngent vector, at least in this 2d case, obviously needs to be
transformed by the original M, because it's tangent to the underlying
surface (in this 2d example, the surface is just a line, and the two
need to remain parallel so that's pretty clear here).

[I've also verified this experimentally in a ray-tracer -- transforming
the tangent vectors across an instancing boundary by the I-T result in
clearly screwed up lighting in some cases involving non-uniform scaling;
changing the tangent vectors to just use the nominal transform (but
keeping I-T for the normal) result in "correct" looking lighting.]
Post by John Tsiombikas
Care to elaborate on what seems wrong with your second (bitangent?)
vector?
Well I didn't think up any examples yet, but it seems that with a
transformation involving non-uniform scaling, if you just transform both
tangent vectors by the nominal transform, you're guaranteed that they'll
both end up perpendiculat to the (transformed, by I-T) _normal_, but
they may not end up perpendicular to _each other_...

Thanks,

-Miles
--
Occam's razor split hairs so well, I bought the whole argument!
Miles Bader
2007-12-16 04:57:13 UTC
Permalink
BTW, I should mention, when I talk about "transforming by the nominal
transform", I'm assuming that it ignores translations for vectors (i.e.,
treats vectors as [x y z 0] for multiplying by the 4x4 matrix, as
opposed to positions which are treated as as [x y z 1]).

Thanks,

-Miles
--
Quidquid latine dictum sit, altum viditur.
Dave Eberly
2007-12-16 16:25:54 UTC
Permalink
Post by John Tsiombikas
Post by Miles Bader
When transforming a normal vector (e.g. if you calculate the
intersection normal in object space , and subsequently transform it to
world space), you need to use the tranpose of the inverse of the nominal
N' = N * transpose (invers (M))
[and then re-normalize the normal after transformation]
So, how does one normally transform tangent vectors (which together with
the normal form an orthonormal basis)?
Same way.
Incorrect. In differential geometric terms, normals are "covariant" and
tangents are "contravariant", so they transform differently.

Algebraically, consider a plane containing point P and having unit-length
normal N. An equation for the plane is
Trn(N)*X = Trn(N)*P= d
where "Trn" denotes the transpose operation and where X is any point
on the plane. The last equality defines the scalar d. Make the change
of variables Y = M*X+B, where M is an invertible matrix and B is a
translation vector; then X = Inv(M)*(Y-B), where "Inv" denotes the
matrix inverse operation. Substituting this into the plane equation
produces
Trn(Inv(Trn(M))*N)*Y = Trn(N)*P + Trn(Inv(Trn(M))*N)*B
This is of the form
Trn(N')*Y = d'
where N' = Inv(Trn(M))*N and d' = Trn(N)*P + Trn(N')*B. As the
original poster mentioned, the normals are transformed by the
inverse-transpose of M. N' is not necessarily unit-length, so if your
application requires this condition, you have to normalize N' (and
adjust the equation of the plane yet one more time).

The point P on the plane transforms to Q = M*P + B. Let U and V be
unit-length vectors for which {U,V,N} are mutually orthogonal. U and V
are tangent vectors for the aforementioned plane. The point P+U is on
the plane. This point transforms to M*(P+U) + B = Q + M*U. It must
be that U' = M*U is perpendicular to N'. This is easily verified by
Trn(N')*U' = Trn(Inv(Trn(M))*N)*M*U
= Trn(N)*Inv(M)*M*U
= Trn(N)*U
= 0
This shows the tangent vector U is transformed to the tangent vector
U' = M*B, so it is _not_ the case that tangents transform by the
inverse-tangent of M.

As the original poster also mentioned, you are guaranteed that M*U and
M*V are tangents, but they are not necessarily perpendicular. You can
use Gram-Schmidt orthonormalization or some other method to obtain
two unit-length and orthogonal tangents.

--
Dave Eberly
http://www.geometrictools.com
David Combs
2008-01-01 15:49:45 UTC
Permalink
In article <mkc9j.16999$***@newsfe15.phx>,
Dave Eberly <***@usemydomain.com> wrote:

...
Post by Dave Eberly
Incorrect. In differential geometric terms, normals are "covariant" and
tangents are "contravariant", so they transform differently.
Algebraically, consider a plane containing point P and having unit-length
normal N. An equation for the plane is
Trn(N)*X = Trn(N)*P= d
where "Trn" denotes the transpose operation and where X is any point
...

OK, ok, ok.

Now, for use while reading books/articles touching on
diff-g, when they're using those two terms, to comprehend
them (as in whatever example or drawn-figure they're talking
about righ then)?

Just how to map some complicated transformation onto
a gut physical "feel" or onto a mental image doesn't
seem so simple. Is something like it even possible,
or even approximable (sp?)?

Some kind of rule-of-thumb could be of immense help!

(Like when (unsuccessfuly) trying to read eg the 10?yr-old-book
(MIT) "Solid Shape" I think it was?)


Thanks!

David
Dave Eberly
2008-01-02 03:31:05 UTC
Permalink
Post by David Combs
Now, for use while reading books/articles touching on
diff-g, when they're using those two terms, to comprehend
them (as in whatever example or drawn-figure they're talking
about righ then)?
Just how to map some complicated transformation onto
a gut physical "feel" or onto a mental image doesn't
seem so simple. Is something like it even possible,
or even approximable (sp?)?
Some kind of rule-of-thumb could be of immense help!
It is not clear to me what your question is. For Euclidean
geometry, think of "normals" as covariant and "tangents" as
contravariant--simple rule of thumb. For Riemannian geometry,
I suppose it does become more complicated to visualize, but
the normals/tangents distinction is still really the rule of thumb.
Post by David Combs
(Like when (unsuccessfuly) trying to read eg the 10?yr-old-book
(MIT) "Solid Shape" I think it was?)
I have this book and used it in a graduate course at UNC. The
book attempts to get you to "visualize" many differential geometric
quantities (umbilics, ruffles, tacnodes, unodes, etc.) without
delving into the mathematical details. The author believes his
approach is superior to the mathematician's approach, but
unfortunately what I learned most from the book was that the
author has a severe distaste for mathematicians. In the end,
any computational requirements rely on the mathematical
descriptions, including visualizing these quantities, say, as
rendered surfaces that are colored according to the types of
points that you have.

--
Dave Eberly
http://www.geometrictools.com

Kaba
2007-12-16 12:01:47 UTC
Permalink
Post by Miles Bader
So, how does one normally transform tangent vectors (which together with
the normal form an orthonormal basis)?
It seems that for _one_ of the tangent vectors, you could just use the
nominal transformation matrix, and it will remain perpendicular to the
normal after transformation.
However, what about the _other_ tangent vector (in 3d)? If one uses the
nominal transformation matrix, it also would remain perpendicular to the
normal after transformation, but it looks to me like it might _not_ end
up being perpendicular to the first tangent vector.
For all the tangent vectors, just use the transformation matrix. You are
right in that for some transformations the tangent vectors may not end
up being orthogonal to each other. But this is usually the way it is
wanted to behave (think about a parametrization of the surface and the
tangents as partial derivatives).

If you actually need an orthogonal basis, you can construct it
afterwards from these vectors, like you suggest. I think there is no
matrix to do this at once.
--
Kalle Rutanen
http://kaba.hilvi.org
Miles Bader
2007-12-17 00:01:20 UTC
Permalink
Post by Kaba
For all the tangent vectors, just use the transformation matrix. You are
right in that for some transformations the tangent vectors may not end
up being orthogonal to each other. But this is usually the way it is
wanted to behave (think about a parametrization of the surface and the
tangents as partial derivatives).
If you actually need an orthogonal basis, you can construct it
afterwards from these vectors, like you suggest.
Hmm I'm not entirely sure whether I know what I want... :-)

I use this basis to transform between "normal space" (coordinate system
where BRDF calculations are done) and world-space, and I'm not sure I
fully understand the ramifications of having a non-orthogonal basis in
such a case...

Thanks,

-Miles
--
Any man who is a triangle, has thee right, when in Cartesian Space, to
have angles, which when summed, come to know more, nor no less, than
nine score degrees, should he so wish. [TEMPLE OV THEE LEMUR]
Kaba
2007-12-17 18:22:46 UTC
Permalink
Post by Miles Bader
Post by Kaba
If you actually need an orthogonal basis, you can construct it
afterwards from these vectors, like you suggest.
Hmm I'm not entirely sure whether I know what I want... :-)
I use this basis to transform between "normal space" (coordinate system
where BRDF calculations are done) and world-space, and I'm not sure I
fully understand the ramifications of having a non-orthogonal basis in
such a case...
I'm not sure either.
Post by Miles Bader
--
Any man who is a triangle, has thee right, when in Cartesian Space, to
have angles, which when summed, come to know more, nor no less, than
nine score degrees, should he so wish. [TEMPLE OV THEE LEMUR]
That's a good one :P (it's missing a "no"-word though...)
--
Kalle Rutanen
http://kaba.hilvi.org
Hans-Bernhard Bröker
2007-12-16 22:01:55 UTC
Permalink
Post by Miles Bader
When transforming a normal vector (e.g. if you calculate the
intersection normal in object space , and subsequently transform it to
world space), you need to use the tranpose of the inverse of the nominal
N' = N * transpose (invers (M))
[and then re-normalize the normal after transformation]
So, how does one normally transform tangent vectors (which together with
the normal form an orthonormal basis)?
Like the ordinary vectors they are.
Post by Miles Bader
However, what about the _other_ tangent vector (in 3d)? If one uses the
nominal transformation matrix, it also would remain perpendicular to the
normal after transformation, but it looks to me like it might _not_ end
up being perpendicular to the first tangent vector.
You have to make up your mind what you want: the transformed set of
original orthogonal coordinate frame vectors, or a set of orthogonal
coordinate frame vectors in transformed space. Yes, that does imply
those are not the same thing.

The catch is that in situations where it's important that you transform
normals by the inverse-transpose method rather then the usual
transformation matrix, the transformed image of an orthogonal frame is
not an orthogonal frame. If it were, then M^{-T} would be identical to
M. Such transformations preserving orthogonality are called
"orthogonal" themselves. Some of them are also known as "rotations".
Loading...