[Date Index]
[Thread Index]
[Author Index]
Fwd: Generating Two Unit Orthogonal Vectors to a 3D Vector
*To*: mathgroup at smc.vnet.net
*Subject*: [mg36374] Fwd: [mg36352] Generating Two Unit Orthogonal Vectors to a 3D Vector
*From*: Garry Helzer <gah at math.umd.edu>
*Date*: Wed, 4 Sep 2002 02:56:28 -0400 (EDT)
*Sender*: owner-wri-mathgroup at wolfram.com
>
> OrthogonalUnitVectors::usage = "OrthogonalUnitVectors[v:{_,_,_}] will
> return
> two unit vectors orthogonal to each other and to v."
>
> You can assume that v is nonzero.
>
> David Park
> djmp at earthlink.net
> http://home.earthlink.net/~djmp/
Well the Mathematica routine cannot be more elegant than the
mathematics. There are an infinite number of solutions and so an
arbitrary choice must be made.
I will omit the unit condition because orthogonal sets of integral
vectors are useful in examples and exercises --and I prefer to do
graphics in a projective context where "orthogonal" is well defined but
"unit" is not. For unit vectors just map the output with something like
#/Sqrt[#.#]&.
The vector v=(a1,a2,a3) is nonzero if and only if at most one of the
vectors (a2,-a1,0), (a3,0,-a1), or (0,a3,-a2) is zero. These vectors
are all orthogonal to v. But which one to choose? For numerical
stability we should probably take the vector largest in some norm. The
1-norm, Plus@@Abs[#]&, is easy to compute. Having picked the second
vector find the third with a cross product. This assures a right-handed
system.
OrthogonalVectors[v : {a1_, a2_, a3_}] :=
With[{w =
First[Sort[{{a2, -a1, 0}, {a3, 0, -a1}, {0, a3, -a2}},
OrderedQ[{Plus @@ Abs[#2], Plus @@ Abs[#1]}] &]]},
{w, Cross[v, w]}
]
Garry Helzer
Department of Mathematics
University of Maryland
1303 Math Bldg
College Park, MD 20742-4015
Prev by Date:
**Re: Generating Two Unit Orthogonal Vectors to a 3D Vector**
Next by Date:
**Re: Generating Two Unit Orthogonal Vectors to a 3D Vector**
Previous by thread:
**Re:Generating Two Unit Orthogonal Vectors to a 3D Vector**
Next by thread:
**Re: Generating Two Unit Orthogonal Vectors to a 3D Vector**
| |