Wednesday, September 19, 2012

Short memo for angle calculation using atan2


Angle and arc-tangent function (in C/C++)




θ = atan2(x,y)
θ' = -(360 - θ)

#1: Bearing and an arc-tangent function

b = atan2(E, N)
Angle between 'N' axis and a vector.
CW is positive.




#2: Rotation angle about an axis and an arc-tangent function

ω = -atan2(x, y)
Angle between 'Y' axis and a vector.
CCW is positive.



Monday, September 3, 2012

Visual Studio 2010 C++ tips: for loop initializer

In Visual Studio 2010, for a loop's initialization variable is not available out of for loop scope, unlike Visual C++ 6.0. Whenever we compile old codes (generated in VC++ 6.0) using newest version, it annoys us. Then, take easy, and change project option to release your blood pressure.

Go to "Project property pages - C/C++ - Language - Force Conformance in For Loop Scope", and select "No (/Zc:forScope-)".

For more information, "http://msdn.microsoft.com/en-us/library/84wcsx8x.aspx".



Visual Studio 2010 C++ tips: Deprecated functions

strcpy, sscanf, fscanf.... etc. There functions are not available anymore in recent Visual Studio .Net C++. Instead of these function, it is recommend to use new functions such as strcpy_s, sscanf_s, fscanf_s ... etc. If you are not pleased to change your old style functions with new ones, you can avoid this problem easily by using this define statement, "#define _CRT_SECURE_NO_DEPRECATE".

For more information about deprecated functions, refer to "http://msdn.microsoft.com/en-us/library/ms235384(v=vs.80).aspx"