Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Should RotationMatrix work with symbolic vectors?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg86114] Re: Should RotationMatrix work with symbolic vectors?
  • From: m.r at inbox.ru
  • Date: Sun, 2 Mar 2008 13:56:12 -0500 (EST)
  • References: <fq5qdj$kol$1@smc.vnet.net>

On Feb 28, 2:12=A0am, Steve Gray <stev... at roadrunner.com> wrote:
> It works fine when the "source" and "destination" vectors are =A0numeric
> (it gives a matrix, say rm2, such that rm2.a2 is parallel to b2):
>
> a2 = {1, 2, 3};
> b2 = {3, 5, 7};
> rm2 = N[RotationMatrix[{a2, b2}]]
>
> {{0.997846, =A00.028474, 0.059102},
> {-0.0301974, 0.999138, 0.028474},
> {-0.0582406,-0.0301974,0.997846}}
>
> and
>
> Normalize[rm2.a2] =A0 =A0 =A0 =A0 =A0 =A0 =A0(* rm2.Normalize[a2] also wor=
ks *)
> {0.329293, 0.548821, 0.76835}
>
> which is a unit vector parallel to b2. So far, great. But unless a2
> and b2 have numeric values, RotationMatrix does nothing.
>
> avec = {a2x, a2y};
> bvec = {b2x, b2y};
> RotationMatrix[{avec, bvec}] =A0 (* gives *)
>
> RotationMatrix[{{a2x, a2y}, {b2x, b2y}}]
>
> Can't it handle symbolics like most functions?
>
> While I'm asking about vectors, consider this example:
>
> av = {avx, avy, avz};
> bv = {bvx, bvy, bvz};
> Normalize[av\[Cross]bv] =A0(* which gives *)
>
> {(-avz bvy + avy bvz)/Sqrt[Abs[-avy bvx + avx bvy]^2 +
> =A0 Abs[avz bvx -avx bvz]^2 + Abs[-avz bvy + avy bvz]^2],
>
> =A0(avz bvx - avx bvz)/Sqrt[Abs[-avy bvx + avx bvy]^2 +
> =A0 Abs[avz bvx - avx bvz]^2 + Abs[-avz bvy + avy bvz]^2],
>
> =A0(-avy bvx + avx bvy)/Sqrt[ Abs[-avy bvx + avx bvy]^2 +
> Abs[avz bvx - avx bvz]^2 + Abs[-avz bvy + avy bvz]^2]}
>
> All three vector components have the same denominator. What's a good
> way to automatically show that for clarity and speed?
>
> =A0I'd appreciate any information.
>
> Steve Gray

This functionality will probably be added in a future version, but
it's not absolutely straightforward. As a no warranty hack, you can do

In[1]:= avec = {a2x, a2y};
 bvec = {b2x, b2y};
 Block[{NumericQ = True&},
  RotationMatrix[{avec, bvec}]] //
   Assuming[
    Element[{a2x, a2y, b2x, b2y},Reals] &&
     a2x^2 + a2y^2 > 0 && b2x^2 + b2y^2 > 0,
    # /. p : _Power | _Conjugate :> Simplify[p] // Simplify]&

Out[3]= {{(a2x b2x + a2y b2y)/Sqrt[(a2x^2 + a2y^2) (b2x^2 + b2y^2)],
(a2y b2x - a2x b2y)/Sqrt[(a2x^2 + a2y^2) (b2x^2 + b2y^2)]}, {(-a2y b2x
+ a2x b2y)/Sqrt[(a2x^2 + a2y^2) (b2x^2 + b2y^2)], (a2x b2x + a2y b2y)/
Sqrt[(a2x^2 + a2y^2) (b2x^2 + b2y^2)]}}

Maxim Rytin
m.r at inbox.ru


  • Prev by Date: Re: Mathematica 6 obtains imaginary eigenvalues for a Hermitian
  • Next by Date: Re: Re: Troubles with HarmonicNumber, empty sums, and Zeta
  • Previous by thread: Re: Should RotationMatrix work with symbolic vectors?
  • Next by thread: Re: Text does not scale with size of graphic