#define ToDegree(x) ((x) * (180.0f / PI))
float Angle(Vector v1, Vector v2)
{
return ToDegree(atanf((v2.y-v1.y)/(v2.x-v1.x)));
}
help with my function
First of all get rid of that #define rubbish.
Secondly try using atan2(v2.y - v1.y, v2.x - v1.x) * 180.0 / PI.
Thirdly what are the types of the x and y members of Vector?
Secondly try using atan2(v2.y - v1.y, v2.x - v1.x) * 180.0 / PI.
Thirdly what are the types of the x and y members of Vector?
It might just be giving you a reference angle instead of the true angle.
i am grateful for yuor help kind suirs
however i am compeled to point out that define is not rubish! it is very acuiesent in reusing code sizeas
however i am compeled to point out that define is not rubish! it is very acuiesent in reusing code sizeas
I think his point was more that you shouldn''t be working within your program in degrees and should get used to radians. If you have to display degrees then that isn''t really a choice, but the define does no type checking. You shouldn''t really use defines for substitution anymore. Constants, inlined functions and templates should be your first choices. Simply because there is more error checking and less chance of introducing subtile errors due to how the generated code is interpretted. It was just an uncharacteristically sharp way for Squid to say that. I really doubt he intended to be offensive, but rather meant it as constructive critism.
It is not an industry known for putting things delicately and you need only look at a fan forum for a newly released game to fully appreciate that fact. That is commercial software developed by highly skilled programmers being called a complete piece of crap that wasn''t worth the whole $50 someone spent on it. Five years with a staff of 40 and a budget in the millions and it wasn''t worth $50. So you ignore that, look for what their actual complaint is and try to figure out how to resolve the problem. It may just be a design decision you made and it simply a differance of opinion. Using defines is a prime example. If that is your preferance then go right ahead, but be aware there are alternatives with advantages over it. You may still prefer defines, but if you are aware then at least that is a decision you made.
It is not an industry known for putting things delicately and you need only look at a fan forum for a newly released game to fully appreciate that fact. That is commercial software developed by highly skilled programmers being called a complete piece of crap that wasn''t worth the whole $50 someone spent on it. Five years with a staff of 40 and a budget in the millions and it wasn''t worth $50. So you ignore that, look for what their actual complaint is and try to figure out how to resolve the problem. It may just be a design decision you made and it simply a differance of opinion. Using defines is a prime example. If that is your preferance then go right ahead, but be aware there are alternatives with advantages over it. You may still prefer defines, but if you are aware then at least that is a decision you made.
Keys to success: Ability, ambition and opportunity.
well hes just a dumass cos defines are beter than inline functions dumass
they are easier to write and even give yuo erroors when yuo get it wrong!~
so yuo shoud not talk about things not understood poppet
thank yuo
they are easier to write and even give yuo erroors when yuo get it wrong!~
so yuo shoud not talk about things not understood poppet
thank yuo
As far as I know, the usual way to get an angle from two vector isn''t with atan but with acos.
First, normalize your vectors, then compute their dot product. Finally, compute the inverse cosinus of the dot product.
Although it''s not related directly to your problem, you should set the parameters of your function as references to avoid nasty copies and make the function inline.
First, normalize your vectors, then compute their dot product. Finally, compute the inverse cosinus of the dot product.
Although it''s not related directly to your problem, you should set the parameters of your function as references to avoid nasty copies and make the function inline.
Well, correct that last comment I made. You certainly seem inclined to give a person a reason to be insulting.
Keys to success: Ability, ambition and opportunity.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement