Results 1 to 4 of 4

Thread: Vec3.cross Bug

  1. #1
    Lesser Knight
    Join Date
    Jan 2011
    Location
    Vienna, Austria
    Posts
    30

    Default Vec3.cross Bug

    Hello,

    after a few hours of banging my head against the table, questioning my math skills and being close to throwing my computer out of the window, I discovered a Bug in Sources/Core/Math/vec3.cpp, line 83f.

    Code:
    template<typename Type>
    CL_Vec3<Type> CL_Vec3<Type>::cross(const CL_Vec3<Type>& v1, const CL_Vec3<Type>& v2)
    {
    	CL_Vec3<Type> tmp = CL_Vec3<Type>(v1.y * v2.z - v1.z * v2.y,
    				  v1.z * v2.x - v1.x * v2.z,
    				  v1.x * v2.y - v1.y * v2.x);
    	return tmp;
    }
    
    template<typename Type>
    CL_Vec3<Type> &CL_Vec3<Type>::cross(const CL_Vec3<Type>& v)
    {
    	cross(*this, v);
    	return *this;
    }
    As you can see, the cross(const CL_Vec3<Type>&) function does not really do anything - it calculates the cross product, discards it, and returns the unchanged vector.

    As I don't know what the author's intention was (modify *this or just return the new vector), I have not created a patch. I also don't know if other classes are affected by similar errors.

    Cheers,
    spin

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    Seth's guess is correct. The intention was that it would modify this and return itself.

  3. #3
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    lmao at the silly error.

    I am very surprised that it was not caught by "Tests/Core/Math"

    It would be great, if someone posted a patch to Tests/Core/Math, and added a new test

    Note: "CL_Vec4<Type>::cross3()" was correct
    Last edited by rombust; 01-16-2011 at 07:19 PM.

  4. #4
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,345

    Default

    Weird, my earlier reply got deleted... I might have done it yesterday accidentally when I was cleaning some spam.

    Anyway, just a note to say I looked at the 1.x branch vector code just in case and it was ok, it's a 2.x only issue.
    Seth A. Robinson
    Robinson Technologies

Similar Threads

  1. CL_CommandLine with Cross-platform application main
    By russ_allegro in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 05-05-2010, 10:59 PM
  2. Errors while trying to Cross-Compile
    By juicebox360 in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 01-29-2009, 04:36 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •