 |
|
| Computers Forum Index » Computer - Games Programming (Algorithms) » Tangent for 3D vectors |
|
Page 1 of 1 |
|
| Author |
Message |
| Guest |
Posted: Sat Apr 26, 2008 6:42 am |
|
|
|
|
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 |
|
|
| Back to top |
|
|
|
| Andreas Wagner |
Posted: Sat Apr 26, 2008 9:34 am |
|
|
|
Guest
|
Hi there!
kalaiselvam.p@gmail.com schrieb:
Quote: 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?
Quote: 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 |
|
|
| Back to top |
|
|
|
| Erik Max Francis |
Posted: Sun Apr 27, 2008 1:03 am |
|
|
|
Guest
|
kalaiselvam.p@gmail.com wrote:
Quote: 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 && max@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 |
|
|
| Back to top |
|
|
|
| Tom Plunket |
Posted: Fri May 02, 2008 8:09 am |
|
|
|
Guest
|
kalaiselvam.p wrote:
Quote: 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!
-- |
|
|
| Back to top |
|
|
|
|
|
All times are GMT
The time now is Fri Mar 19, 2010 9:07 am
|
|