6 //
\83Q
\81[
\83\80\93à
\8ap
\93x
\81i
\82Q
\93x
\90¸
\93x
\81j
\82É
\8aÛ
\82ß
\82é
7 inline double s_roundInGameAngle( const double radian )
9 double degree = g_degreeFromRadian( radian );
10 degree = ::floor( ::round( degree ) * 0.5 ) * 2.0;
11 return g_radianFromDegree( degree );
13 inline GVOVector s_roundInGameVector( const GVOVector& v )
15 //
\90^
\93\8c\82©
\82ç
\82Ì
\8ap
\93x
\82ð
\8eæ
\93¾
16 double sita = GVOVector( 1, 0 ).angleTo( v );
17 // 2
\93x
\82¸
\82Â
\82Ì360
\93x
\95ª
\89ð
\94\
\82É
\8aÛ
\82ß
\82é
18 sita = s_roundInGameAngle( sita );
19 //
\8cÊ
\93x
\82É
\96ß
\82·
20 //
\90¢
\8aE
\8dÀ
\95W
\8cn
\82Í
\8fã
\82ª0
\82È
\82Ì
\82ÅY
\8e²
\82ð
\94½
\93]
\82³
\82¹
\82é
21 return GVOVector( ::cos( sita ), -::sin( sita ) );
24 //
\82»
\82Ì
\83x
\83N
\83g
\83\8b\82Å
\95\
\8c»
\8fo
\97\88\82é
\83Q
\81[
\83\80\93à
\95û
\8ap
\82Ì
\95ª
\89ð
\94\
\82ð
\8eZ
\8fo
25 inline double s_resolutionForVector( const GVOVector& vector )
27 const double length = vector.length();
28 if ( length == 0.0 ) {
31 const double resolution = M_PI_2 / length;
35 inline bool s_isAnotherDirection( const GVOVector& v1, const GVOVector& v2 )
37 const double resolution = s_resolutionForVector( v2 );
38 const double angle = v1.angleTo( v2 );
39 return resolution < ::fabs( angle );
44 void GVOShip::updateWithSurveyCoord( const POINT& surveyCoord, const uint32_t timeStamp )
46 const GVOVector v( m_surveyCoord, surveyCoord );
48 m_velocity = v.length();
49 m_velocityPerSecond.setVelocity( m_velocity, timeStamp - m_timeStamp );
50 m_timeStamp = timeStamp;
52 //
\88Ú
\93®
\82µ
\82Ä
\82È
\82¯
\82ê
\82Î
\96³
\8e\8b\82·
\82é
\81B
53 if ( m_velocity == 0.0 ) {
56 m_surveyCoord = surveyCoord;
58 //
\8c»
\8dÝ
\82Ì
\83x
\83N
\83g
\83\8b\82ª
\90Ý
\92è
\82³
\82ê
\82Ä
\82¢
\82È
\82¯
\82ê
\82Î
\83p
\83\89\83\81\81[
\83^
\81[
\82ð
\82»
\82Ì
\82Ü
\82Ü
\8dÌ
\97p
\82·
\82é
59 if ( m_vector.length() == 0.0 ) {
60 m_vector = s_roundInGameVector( v.normalizedVector() );
64 //
\90V
\82µ
\82¢
\8f\87\82©
\82ç
\88Ù
\82È
\82é
\8ap
\93x
\82Æ
\8c©
\82È
\82¹
\82é
\83x
\83N
\83g
\83\8b\82ð
\92T
\8dõ
\82·
\82é
65 GVOVector headVector = v;
66 for ( VectorArray::const_reverse_iterator it = m_vectorArray.rbegin(); it != m_vectorArray.rend(); ++it ) {
67 headVector.composite( *it );
68 if ( s_isAnotherDirection(m_vector, headVector) ) {
69 //
\82±
\82ê
\88È
\8d~
\82Í
\8eQ
\8dl
\82É
\82È
\82ç
\82È
\82¢
\82Ì
\82Å
\8dí
\8f\9c\82·
\82é
\81B
70 m_vectorArray.erase( m_vectorArray.begin(), std::next( it ).base() );
74 m_vector = s_roundInGameVector( headVector.normalizedVector() );
76 //
\8dÅ
\90V
\82Ì
\83x
\83N
\83g
\83\8b\82ð
\83\8a\83X
\83g
\82É
\89Á
\82¦
\82é
\81B
77 m_vectorArray.push_back( v );
79 //
\8cv
\8eZ
\8fã
\82Í90
\82 \82ê
\82Î
\95ª
\89ð
\94\180
\82Ì
\8ap
\93x
\82ª
\8eZ
\8fo
\82Å
\82«
\82é
\82Í
\82¸
\82¾
\82ª
\8cë
\8d·
\82ð
\93¥
\82Ü
\82¦
\82Ä2
\94{
\82Ì
\8b\97\97£
\82ð
\95Û
\8e\9d\82µ
\82Ä
\82¨
\82
80 if ( 180 < (headVector.length() - m_vectorArray.front().length()) ) {
81 m_vectorArray.pop_front();