Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
ambigious call to overloaded function. Cant fix it and i dont know how abs's work, just trying to fix a code and use it to make a cheat for a video game haha.
Any help would be appreciated if you can rewrite that line for me i'd appreciate it alot.

What I have tried:

C++
float GetWavRoll(Vector dir)
{
	Vector forward(1, -dir.x, dir.y);

	Vector up(0, -dir.x, abs(dir.y + (1 / dir.y) + (1 / dir.y)));

	if (dir.x > 0 && dir.y < 0)
		up.y = abs(up.y);
	else if (dir.x < 0 && dir.y < 0)
		up.y = -abs(up.y);

	Vector left = up.Cross(forward);

	float roll = deg(atan2f(left.z, (left.y * forward.x) - (left.x * forward.y)));
}
Posted
Updated 25-Oct-17 23:40pm
v2
Comments
Richard MacCutchan 26-Oct-17 5:04am    
What is up and what type is member y?

 
Share this answer
 
Comments
CPallini 26-Oct-17 8:45am    
5.
abs expects an integer parameter while you are using floating point variables (I guess). Use fabs[^] instead.

[update]
As Richard correctly remarked, there are overloaded implementation of abs for C++.
[/update]
 
Share this answer
 
v2
Comments
Richard MacCutchan 26-Oct-17 6:29am    
See my link above.
CPallini 26-Oct-17 6:37am    
Well, all those functions apply to integer parameters as well. Am I missing something?
Richard MacCutchan 26-Oct-17 8:17am    
double abs(
double n
); // C++ only

Still called abs
CPallini 26-Oct-17 8:44am    
Well, it looks I was really missing something. Thank you for pointing that out, Richard.
Richard MacCutchan 26-Oct-17 9:25am    
If I had a pound (or euro) for every time I missed something ... :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900