Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tangent for 3D vectors

2 views
Skip to first unread message

kalais...@gmail.com

unread,
Apr 26, 2008, 2:42:30 AM4/26/08
to
Dear All,

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.

Thanks in advance.

Regards,
Kalai

Andreas Wagner

unread,
Apr 26, 2008, 5:13:09 AM4/26/08
to
Hi there!

kalais...@gmail.com schrieb:

> 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.

The sample shows how to rotate a vector 90°[1]. AFAIK a vector has no
tangents[2]. I guess you mixed something up!

I suggest reading about linear algebra, since it's used a lot in
3D-stuff.

About your question: Do you want to compute the acceleration by gravity
(e.g. when driving downhill)? Or something else?

> Thanks in advance.
>
> Regards,
> Kalai

HTH
Andreas

[1] http://en.wikipedia.org/wiki/Rotation_%28mathematics%29
[2] http://en.wikipedia.org/wiki/Tangent
--
new here

Erik Max Francis

unread,
Apr 26, 2008, 4:03:17 PM4/26/08
to
kalais...@gmail.com wrote:

> 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.

What you're describing is a vector perpendicular to the first vector,
not a tangent of any kind.

In two dimensions, there are an infinite number of vectors orthogonal to
a particular vector, and they're all scalar multiples of each other.
Such a vector is indeed given by your example of k (-y, x).

In three dimensions, there are also an infinite number of vectors
orthogonal to a particular vector, but they're not scalar multiples of
each other. In fact there are an infinite number of directions in which
such a vector can point, so you're going to have to be specific about
which one you want.

--
Erik Max Francis && m...@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
The multitude of books is making us ignorant.
-- Voltaire

Tom Plunket

unread,
May 2, 2008, 3:08:39 AM5/2/08
to
kalaiselvam.p wrote:

> To calculate the Ground Velocity, I need the formula to calculate
> tangent for 3D vector.

The only way I know to get velocity out of a vector is to take that
vector's magnitude. What are you working with, and what do you intend
to get?

"Tangent" to a vector means nothing unless "tangent" could define a
parallel vector (I don't know, but it seems like it'd make sense to me).
In any case, it looks like you're trying to compute a vector at a 90
degree angle to the input vector, but the "thing" that's 90 degrees to a
vector is a plane, so you'll need more information if you want a
specific vector.

When building matrices, one can use the cross product to generate them
from minimal information, when certain assumptions can be made. However,
we've no idea what the data you have or the data you expect to get are.

Any orthogonal vector (that is, one at 90 degrees to your input vector)
can be solved for via the below equation. You'll find that plugging
your values in for the 2D case gives you the same result.

X0, Y0, Z0 are your original vector's components, and X1, Y1, Z1 are the
perpendicular vector's components. All perpendicular vectors satisfy
this equation:

(X0 * X1) + (Y0 * Y1) + (Z0 * Z1) = 0
(this sum of products is also known as the dot product)

In short, pick any X and a Y, then solve for Z and you'll get your
vector, and I'll leave the corner cases to the reader.

-tom!

--

Erik Max Francis

unread,
May 2, 2008, 4:44:16 AM5/2/08
to
Hi Tom, haven't seen you in a while.

Tom Plunket wrote:

> "Tangent" to a vector means nothing unless "tangent" could define a
> parallel vector (I don't know, but it seems like it'd make sense to me).
> In any case, it looks like you're trying to compute a vector at a 90
> degree angle to the input vector, but the "thing" that's 90 degrees to a
> vector is a plane, so you'll need more information if you want a
> specific vector.

Right. A tangent vector is a vector relative to some composite object,
not just some other vector. He's talking about normals.

> When building matrices, one can use the cross product to generate them
> from minimal information, when certain assumptions can be made. However,
> we've no idea what the data you have or the data you expect to get are.

What do you mean by "matrices" there? Do you mean curvilinear
coordinate systems, or something else? I don't see a meaning of matrix
that makes sense in this context.

If it's curvilinear coordinate systems, then it's a set of orthonormal
basis vectors that follow a parameterized curve through space. The
mathematics are actually not that complicated:

If r(t) is a vector function that represents the parameterized curve,
then T = dr/dt/|dr/dt| is the unit tangent vector (when defined). N =
dT/dt/|dT/dt| is the unit normal vector (also when defined, of course),
and indicates the direction in which the curve is changing. Being
orthogonal unit vectors, the binormal vector B = T cross N is also a
unit vector, and completes a set of orthonormal unit basis vectors given
by the triple (T, N, B). That gives you a system of coordinates (when
defined) which are relative to the curve, not the independent space.

For his purposes, either N or B would do. Or indeed any other vector in
the plane defined by N and B.

> Any orthogonal vector (that is, one at 90 degrees to your input vector)
> can be solved for via the below equation.

To fully nitpick, you mean perpendicular. The zero vector is orthogonal
to any vector, but doesn't make a 90 degree angle with any of them.

0 new messages