in

.NET Opensource

Community for opensource projects by Christoph Rüegg

Bug: The crossproduct has wrong indexs.

Last post 04-26-2008 14:38 by Christoph Rüegg. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 04-16-2008 16:04

    • marX
    • Top 50 Contributor
      Male
    • Joined on 04-16-2008
    • Posts 2

    Bug: The crossproduct has wrong indexs.

     Hi!

     Me again with a bug (at least I think so).

             /// <summary>
            /// Cross product of two 3-dimensional vectors.
            /// </summary>
            /// <returns>
            /// Vector ret = (u[2]v[3] - u[3]v[2], u[3]v[1] - u[1]v[3], u[1]v[2] - u[2]v[1]).
            /// </returns>
            /// <seealso cref="CrossMultiply"/>
            public static
            Vector
            CrossProduct(
                IVector u,
                IVector v
                )
            {
                CheckMatchingVectorDimensions(u, v);
                if(3 != u.Length)
                {
                    throw new ArgumentOutOfRangeException("u", Resources.ArgumentVectorThreeDimensional);
                }

                //Wrong, because it is zerobased at not one-based.

                //Vector product = new Vector(new double[ {
                //    u[2]*v[3] - u[3]*v[2],
                //    u[3]*v[1] - u[1]*v[3],
                //    u[1]*v[2] - u[2]*v[1]
                //    });

                Vector product = new Vector(new double[ {
                    u[1]*v[2] - u[2]*v[1],
                    u[2]*v[0] - u[0]*v[2],
                    u[0]*v[1] - u[1]*v[0]
                    });

                return product;
            }

     

    I hope it was helpfully. 

  • 04-26-2008 14:38 In reply to

    Re: Bug: The crossproduct has wrong indexs.

    Answer

    Thanks for reporting. This issue IRID-128 has been fixed in revision 428.

Page 1 of 1 (2 items)
Powered by Community Server (Non-Commercial Edition), by Telligent Systems