Menu

quaternion = quaternion problem

Help
2011-05-07
2013-04-22
  • afraidofdark

    afraidofdark - 2011-05-07

    hello, I use visual studio 2008. In one of my project, I create two quaternion lets say Quaternion a, b;
    than a = b; this line gives error

    \..\Amazing3d\AmzMain\source\amzEntity.cpp(11) : error C2243: 'type cast' : conversion from 'amz::Quaternion *' to 'const vmml::vector<M,T> &' exists, but is inaccessible
    1>        with
    1>        [
    1>            M=4,
    1>            T=float
    1>        ]

    Quaternion is a typedef  "typedef vmml::quaternion<float> Quaternion;"

    I looked at quaternion.hpp file and found this

    template < typename T >
    class quaternion : [b]private[/b] vector< 4, T >
    {
    public:
        typedef vector< 4, T >  super;
        using super::operator();
        using super::operator=;
    

    = operator comes from vector<4,T> but it inherited as private, I believe this is the source of error. I change it to public and my code worked fine, before going any further with this change, I just wanted to ask you about this.

     
  • afraidofdark

    afraidofdark - 2011-05-07

    I figured this out, changing from private to public is such a bad idea ( cause it seems that this change will allow quaternion to access all vector's public functionality ) however I still don't know why I get this error ?

    it says quaternion* however left hand side is not even a pointer

    Quaternion a,b;
    a=b; this line generates the same error. Even in "quaternion_test.cpp" same error happens.

     
  • afraidofdark

    afraidofdark - 2011-05-07

    this is my most innocent attempt to solve problem

        //using super::operator=;
        quaternion& operator= (const quaternion& other) {
             memcpy( array, other.array, 4 * sizeof( T ) );
            return *this;
        }
    

    it works for me.

    I also add these two line to vmmlib_config.hpp

    #undef max
    #undef min

    because of these warnings

    2>D:\amz\Amazing3d\Dependencies\vmmlib/matrix.hpp(2496) : warning C4003: not enough actual parameters for macro 'max'
    2>D:\amz\Amazing3d\Dependencies\vmmlib/matrix.hpp(2497) : warning C4003: not enough actual parameters for macro 'min'

     
  • Jonas Boesch

    Jonas Boesch - 2011-11-04

    Thanks, I added some explicit quat and vec4 operator= and operator== and operator!=.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.