+
void GVOShip::updateWithSurveyCoord( const POINT& surveyCoord)
{
const GVOVector v( m_surveyCoord, surveyCoord );
if ( velocity == 0.0 ) {
return;
}
+#ifndef NDEBUG
+ char buf[4096];
+ sprintf( buf, "velocity:%f\n", v.length() );
+ OutputDebugStringA( buf );
+#endif
// 90\93x\82ð\92´\82¦\82½\82ç\8eQ\8dl\82É\82È\82ç\82È\82¢\97\9a\97ð\82ð\83N\83\8a\83A\82·\82é\81B
const double angle = m_vector.angleTo( v );
if ( M_PI_2 < ::fabs( angle ) ) {
m_vectorHistory.clear();
}
+
VectorHistoryItem item;
item.m_surveyCoord = surveyCoord;
item.m_vector = v;
break;
}
}
+
+ // \90^\93\8c\82©\82ç\82Ì\8ap\93x\82ð\8eæ\93¾
+ double sita = GVOVector( 1, 0 ).angleTo( v );
+
+ // 2\93x\82¸\82Â\82Ì360\93x\95ª\89ð\94\\82É\8aÛ\82ß\82é
+ sita = (sita * 180.0) / M_PI;
+ sita = ::floor( ::round( sita ) * 0.5 ) * 2.0;
+
+#ifndef NDEBUG
+ char buf[4096];
+ sprintf( buf, "%f v:%f\n", sita, v.length() );
+ OutputDebugStringA( buf );
+#endif
+
+ // \8cÊ\93x\82É\96ß\82·
+ //sita = (sita * M_PI) / 180.0;
+ sita = g_radianFromDegree( sita );
+ // \90¢\8aE\8dÀ\95W\8cn\82Í\8fã\82ª0\82È\82Ì\82ÅY\8e²\82ð\94½\93]\82³\82¹\82é
+ v = GVOVector( ::cos( sita ), -::sin( sita ) );
m_vector = v;
}
#include <Windows.h>
#include <vector>
#include <list>
+#include "GVONavish.h"
// \8aÈ\88Õ\93ñ\8e\9f\8c³\83x\83N\83g\83\8b
}
inline double angleTo(const GVOVector& other)const
{
- // Math.atan2(x1 * y0 - x0 * y1, x0 * x1 + y0 * y1);
return ::atan2( other.m_x * m_y - m_x * other.m_y, m_x * other.m_x + m_y * other.m_y );
- if ( length() == 0.0 && other.length() == 0.0 ) {
- return NAN;
- }
- const double cosSita = dotProduct( other ) / (length() * other.length());
- return ::acos( cosSita );
- }
-private:
- // \83x\83N\83g\83\8b\92·
- inline double calcLength() const
- {
- return ::pow( m_x * m_x + m_y * m_y, 0.5 );
}
};