Sign in to follow this  
Funkyjive

Non-pointer parameter becoming void

Recommended Posts

Ok this problem is killing me. I have never seen it before. The problem is when I pass a variable as a parameter to a function. The debugger shows the parameter as void. The weird part is that the function gives correct results in the many places I have used it except for one. Before I go any further let me mention I am writing in C++. Here are more details of the problem...

The function in question to get the radians between two vectors.
float be_Vector::Dot(be_Vector right_operand)
{
Normalize();
right_operand.Normalize();
return acos(x * right_operand.x) + (y * right_operand.y) + (z * right_operand.z);
}




The debugger always shows "right_operand = void" (Even when the function returns correct results!)

The only thing I can think of is a problem when copying the vector from where I call the function into the parameter. The vector class is fairly simple so I didn't think I needed to overload the "=" function.
Here is the class...

class be_Vector
{
public:
float x;
float y;
float z;

be_Vector();
be_Vector(float x, float y, float z);

...Ommited overloaded *, *=, etc... for space

float Magnitude();
float Magnitude_Squared();
void Normalize();
float Dot(be_Vector right_operand);
be_Vector Cross(be_Vector &right_operand);
};





Here is the location I am calling the function from code that is generating errors...

be_Vector end_cross = end->Get_Cross();
be_Vector start_cross = start->Get_Cross();
float delta_roll = end_cross.Dot(start_cross);




I made sure in the debugger that end_cross and start_cross are getting valid data and they are both getting their values set correctly. end_cross and start_cross both have values of x=0, y=0, z=1 which means Dot should return 0 but it is returning 2.570796

Sorry for so much information but I really don't know where this problem is coming from.

Thanks in advance!


EDIT: SOLVED
Well I made a stupid mistake in the vector function. I was only doing acos on the two x's multiplied instead of the sum of all dimensions. So the program is at least working right now but the debugger is still saying the right operand is void. Any ideas?

Share this post


Link to post
Share on other sites
Quote:

float be_Vector::Dot(be_Vector right_operand)
{
Normalize();
right_operand.Normalize();
return acos(x * right_operand.x) + (y * right_operand.y) + (z * right_operand.z);
}


This has nothing to do with your original problem, but I don't think you want to normalize a vector anytime you call its Dot operator. I would certainly not think that is expected behavior (dot should be a const method).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this