OSDN Git Service

ちょっと整理。
authorMandhelingFreak <mandheling30-freak@yahoo.co.jp>
Fri, 31 Jan 2014 17:01:38 +0000 (02:01 +0900)
committerMandhelingFreak <mandheling30-freak@yahoo.co.jp>
Fri, 31 Jan 2014 17:01:38 +0000 (02:01 +0900)
GVONavish/GVONavish/GVONavish.h
GVONavish/GVONavish/GVOShip.cpp
GVONavish/GVONavish/GVOShip.h

index 9117948..9b1d0bb 100644 (file)
@@ -25,3 +25,13 @@ inline std::wstring g_makeFullPath(const std::wstring& fileName)
        }
        return filePath;
 }
+
+inline double g_degreeFromRadian( const double radian )
+{
+       return radian * (180.0 / M_PI);
+}
+
+inline double g_radianFromDegree( const double degree )
+{
+       return degree * (M_PI / 180.0);
+}
index 9d35312..f78566a 100644 (file)
@@ -5,6 +5,7 @@
 
 
 
+
 void GVOShip::updateWithSurveyCoord( const POINT& surveyCoord)
 {
        const GVOVector v( m_surveyCoord, surveyCoord );
@@ -14,12 +15,18 @@ void GVOShip::updateWithSurveyCoord( const POINT& 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;
@@ -56,5 +63,24 @@ void GVOShip::updateVector()
                        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;
 }
index 72fb748..5031080 100644 (file)
@@ -2,6 +2,7 @@
 #include <Windows.h>
 #include <vector>
 #include <list>
+#include "GVONavish.h"
 
 
 // \8aÈ\88Õ\93ñ\8e\9f\8c³\83x\83N\83g\83\8b
@@ -67,19 +68,7 @@ public:
        }
        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 );
        }
 };