LikeTK's picture

Vector3 Cross Operation for CLI/C++

Vector3^ v1= gcnew Vector3(0, 2.0f, 1.0f);        
Vector3^ v2 = gcnew Vector3(0, 1.0f, 0.0f);          
Vector3^ v3 = Vector3::Cross(v2, v1);

error C2665: 'OpenTK::Vector3::Cross' : none of the 2 overloads could convert all the argument types

Any feedback

Vector3 v1= gcnew Vector3(0, 2.0f, 1.0f);        
Vector3 v2 = gcnew Vector3(0, 1.0f, 0.0f);          
Vector3^ v3 = Vector3::Cross(v2, v1);   //This is OK

But

Vector3 v1= gcnew Vector3(0, 2.0f, 1.0f);        
Vector3 v2 = gcnew Vector3(0, 1.0f, 0.0f);

error C2440: 'initializing' : cannot convert from 'OpenTK::Vector3 ^' to 'OpenTK::Vector3'


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
LikeTK's picture

Is there something I can do to Re-Compile the source code to make the Cross method to take

Vector3 Cross( Vector3^ v1, Vector3^ v2)
the Fiddler's picture

There are two overloads:

Vector3 Cross(Vector3 v1, Vector3 v2)
void Cross(ref Vector3 v1, ref Vector3 v2, out Vector3 result)

You are trying to use this:

Vector3 Cross(ref Vector3 v1, ref Vector3 v2)

but there is no such signature, because the CLS prohibits overloads on reference specifiers. Use the overload with the out parameter instead.

LikeTK's picture

Thanks, I figure out the problem through your feedbacks.