Re: Tangent for 3D vectors



kalaiselvam.p@xxxxxxxxx writes:

I am developing a 3D car game in C++ using openGL. To calculate the
Ground Velocity, I need the formula to calculate tangent for 3D
vector. I got the tangent for 2D vector from some game samples (i.e.,
Tangent for 2D vector (x,y) = (-y,x)). Please help me to find out the
tangent for 3D vector.

From the way you've phrased this, it sounds like you are looking for
the normal to a vector (the 2D equation you have above is for a
normal...tangent vectors only exist for arcs). Like another response
to your post noted, to get the normal of a vector in 3D you have to
actually have two vectors and take the cross product of the two (and
there are actually two normals so you have to know how to set up the
calculation to get the one you want). However, I'm thinking you want
something a little more complex than this

This is how I'm visualizing your problem, you tell me if I'm wrong:
You've got your car and it's unbound to the ground (ie it can fly in
the air). When it contacts the ground, it accellerates the ground
based on the contact normal between the tires and the ground surface
and the direction the car is facing. This acceleration vector is the
projection of your car's direction vector (adjusted for the amount of
throttle) into the tangent PLANE of the ground. Convieniantly tangent
planes are defined by the normal to the surface, and you should
already have this data stored as part of your mesh for the ground for
rendering purposes.

If D is the normalized direction vector, T is your thrust scalar and N
is the normal to the surface, the projection of the thrust vector (T *
D) onto the plane defined by N is:

T * ( N x D x N )

Note: N and D must be normalized for this. The equation is slightly
different if they are not (but it is cheaper to use the other equation
than to normalize each of these vectors and put them into the one
above. Unfortunately I can't remember it off the top of my head).

Keeping efficiency in mind, there are many optimizations of the above
equation to reduce the number of computations. The equation acutally
requires 31 floating point operations which is a little expensive if
you have to calculate this for a bunch of things 60x a second.

I hope that helps.

-Nat
.



Relevant Pages

  • Re: tangent space for normal mapping
    ... I'm confused about the math. ... and bitangent correctly for triangle normal, but now I need to make them ... Can I simply do as I did for normals, ... tangent and bitangent among shared vertices? ...
    (comp.graphics.algorithms)
  • Re: Bump mapping
    ... its important to realize this is a texture-based lighting technique, ... > So when I create my vertices, I should not be putting in my normals, but ... > rather transform each vertex to tangent space and calculate the tangent, ... >>>1) Why is it necessary to convert to tangent space to get another normal ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: Bump mapping
    ... D3DVECTOR position; ... So when I create my vertices, I should not be putting in my normals, but ... rather transform each vertex to tangent space and calculate the tangent, ... Why is it necessary to convert to tangent space to get another normal ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: bump mapping and tangent space
    ... product of tangent and bitangent. ... I have already normals (averaged among ... the surface as a parametric surface, ...
    (comp.graphics.api.opengl)
  • Re: cant insert simple hole on a plane. Is this true?
    ... The only plane type I know of where the ... All planes or surfaces can have two normals. ... >dependent on the order in which it was drawn). ... Tangent to ...
    (comp.cad.solidworks)