double Robby::getDistance() { float xPrime = cos(getRotation()*0.0174533)*hostWindow.getSize().x*2; float yPrime = sin(getRotation()*0.0174533)*hostWindow.getSize().x*2; sf::Vector2f pPoint(xPrime,yPrime); sf::Vector2f oPoint = getPosition(); sf::Vector2f tlPoint(0,0); sf::Vector2f trPoint(hostWindow.getSize().x,0); sf::Vector2f blPoint(0,hostWindow.getSize().y); sf::Vector2f brPoint(hostWindow.getSize().x,hostWindow.getSize().y); sf::Vector2f topLine = findIntersection(oPoint,pPoint,tlPoint,trPoint); sf::Vector2f botLine = findIntersection(oPoint,pPoint,blPoint,brPoint); sf::Vector2f leftLine = findIntersection(oPoint,pPoint,tlPoint,blPoint); sf::Vector2f rightLine = findIntersection(oPoint,pPoint,trPoint,brPoint); sf::Vector2f intercept; if (topLine.x < -9) { if (botLine.x < -9) { if (leftLine.x < -9) { intercept = rightLine; } else intercept = leftLine; } else intercept = botLine; } else intercept = topLine; double distance = sqrt(pow(intercept.x-getPosition().x,2)+pow(intercept.y-getPosition().y,2)); return distance; }
void npc_escortAI::FillPointMovementListForCreature() { std::vector<ScriptPointMove> const& pPointsEntries = pSystemMgr.GetPointMoveList(m_creature->GetEntry()); if (pPointsEntries.empty()) return; std::vector<ScriptPointMove>::const_iterator itr; for (itr = pPointsEntries.begin(); itr != pPointsEntries.end(); ++itr) { Escort_Waypoint pPoint(itr->uiPointId, itr->fX, itr->fY, itr->fZ, itr->uiWaitTime); WaypointList.push_back(pPoint); } }
void npc_escortAI::FillPointMovementListForCreature() { UNORDERED_MAP<uint32, std::vector<PointMovement> >::iterator pPointsEntries = PointMovementMap.find(m_creature->GetEntry()); if (pPointsEntries != PointMovementMap.end()) { std::vector<PointMovement>::iterator itr; for (itr = pPointsEntries->second.begin(); itr != pPointsEntries->second.end(); ++itr) { Escort_Waypoint pPoint(itr->m_uiPointId,itr->m_fX,itr->m_fY,itr->m_fZ,itr->m_uiWaitTime); WaypointList.push_back(pPoint); } } }
void xmlBranchLoad::DecodePoint( ticpp::Element* pVertex , int i ) { //считать координаты точки int iNum = 0; pVertex->GetAttribute( m_BranchNames.m_sNum , &iNum ); ticpp::Iterator< ticpp::Element > pPoint( m_BranchNames.m_sPoint ); for ( pPoint = pPoint.begin( pVertex ); pPoint != pPoint.end(); pPoint++ ) { //извлечь координаты вершины DecodeVertex( pPoint , &m_pData->m_vBranch[ i ].m_vVertex ); //извлечь координаты нормали DecodeNormal( pPoint , &m_pData->m_vBranch[ i ].m_vNormal ); //извлечь текстурные координаты DecodeTexCoord( pPoint , &m_pData->m_vBranch[ i ].m_vTexCoord ); } }
status_t ConvertFromAMessage(const os::Message & from, Message & to) { to.Clear(); to.what = from.GetCode(); int numNames = from.GetNumNames(); for (int32 i=0; i<numNames; i++) { int type; int count; std::string name = from.GetName(i); if (from.GetNameInfo(name.c_str(), &type, &count) == B_NO_ERROR) { for (int j=0; j<count; j++) { const void * nextItem; size_t itemSize; if (from.FindData(name.c_str(), type, &nextItem, &itemSize, j) != B_NO_ERROR) return B_ERROR; // do any necessary translation from the AtheOS data types to Muscle data types switch(type) { case os::T_POINT: { const os::Point * p = static_cast<const os::Point *>(nextItem); Point pPoint(p->x, p->y); if (to.AddPoint(name.c_str(), pPoint) != B_NO_ERROR) return B_ERROR; } break; case os::T_RECT: { const os::Rect * r = static_cast<const os::Rect *>(nextItem); Rect pRect(r->left, r->top, r->right, r->bottom); if (to.AddRect(name.c_str(), pRect) != B_NO_ERROR) return B_ERROR; } break; case os::T_MESSAGE: { os::Message amsg; if (amsg.Unflatten(static_cast<const uint8 *>(nextItem)) != B_NO_ERROR) return B_ERROR; Message * newMsg = newnothrow Message; if (newMsg) { MessageRef msgRef(newMsg); if (ConvertFromAMessage(amsg, *newMsg) != B_NO_ERROR) return B_ERROR; if (to.AddMessage(name.c_str(), msgRef) != B_NO_ERROR) return B_ERROR; } else {WARN_OUT_OF_MEMORY; return B_ERROR;} } break; default: if (to.AddData(name.c_str(), type, nextItem, itemSize) != B_NO_ERROR) return B_ERROR; break; } } } } return B_NO_ERROR; }
void ActiveTrack::AddPointNow( bool do_add_point ) { wxDateTime now = wxDateTime::Now(); if( m_prev_dist < 0.0005 ) // avoid zero length segs if( !do_add_point ) return; if( m_prev_time.IsValid() ) if( m_prev_time == now ) // avoid zero time segs if( !do_add_point ) return; vector2D gpsPoint( gLon, gLat ); // The dynamic interval algorithm will gather all track points in a queue, // and analyze the cross track errors for each point before actually adding // a point to the track. switch( trackPointState ) { case firstPoint: { TrackPoint *pTrackPoint = AddNewPoint( gpsPoint, now.ToUTC() ); m_lastStoredTP = pTrackPoint; trackPointState = secondPoint; do_add_point = false; break; } case secondPoint: { vector2D pPoint( gLon, gLat ); skipPoints.push_back( pPoint ); skipTimes.push_back( now.ToUTC() ); trackPointState = potentialPoint; break; } case potentialPoint: { if( gpsPoint == skipPoints[skipPoints.size()-1] ) break; unsigned int xteMaxIndex = 0; double xteMax = 0; // Scan points skipped so far and see if anyone has XTE over the threshold. for( unsigned int i=0; i<skipPoints.size(); i++ ) { double xte = GetXTE( m_lastStoredTP->m_lat, m_lastStoredTP->m_lon, gLat, gLon, skipPoints[i].lat, skipPoints[i].lon ); if( xte > xteMax ) { xteMax = xte; xteMaxIndex = i; } } if( xteMax > m_allowedMaxXTE ) { TrackPoint *pTrackPoint = AddNewPoint( skipPoints[xteMaxIndex], skipTimes[xteMaxIndex] ); pSelect->AddSelectableTrackSegment( m_lastStoredTP->m_lat, m_lastStoredTP->m_lon, pTrackPoint->m_lat, pTrackPoint->m_lon, m_lastStoredTP, pTrackPoint, this ); m_prevFixedTP = m_fixedTP; m_fixedTP = m_removeTP; m_removeTP = m_lastStoredTP; m_lastStoredTP = pTrackPoint; for( unsigned int i=0; i<=xteMaxIndex; i++ ) { skipPoints.pop_front(); skipTimes.pop_front(); } // Now back up and see if we just made 3 points in a straight line and the middle one // (the next to last) point can possibly be eliminated. Here we reduce the allowed // XTE as a function of leg length. (Half the XTE for very short legs). if( GetnPoints() > 2 ) { double dist = DistGreatCircle( m_fixedTP->m_lat, m_fixedTP->m_lon, m_lastStoredTP->m_lat, m_lastStoredTP->m_lon ); double xte = GetXTE( m_fixedTP, m_lastStoredTP, m_removeTP ); if( xte < m_allowedMaxXTE / wxMax(1.0, 2.0 - dist*2.0) ) { TrackPoints.pop_back(); TrackPoints.pop_back(); TrackPoints.push_back( m_lastStoredTP ); pSelect->DeletePointSelectableTrackSegments( m_removeTP ); pSelect->AddSelectableTrackSegment( m_fixedTP->m_lat, m_fixedTP->m_lon, m_lastStoredTP->m_lat, m_lastStoredTP->m_lon, m_fixedTP, m_lastStoredTP, this ); delete m_removeTP; m_removeTP = m_fixedTP; m_fixedTP = m_prevFixedTP; } } } skipPoints.push_back( gpsPoint ); skipTimes.push_back( now.ToUTC() ); break; } } // Check if this is the last point of the track. if( do_add_point ) { TrackPoint *pTrackPoint = AddNewPoint( gpsPoint, now.ToUTC() ); pSelect->AddSelectableTrackSegment( m_lastStoredTP->m_lat, m_lastStoredTP->m_lon, pTrackPoint->m_lat, pTrackPoint->m_lon, m_lastStoredTP, pTrackPoint, this ); } m_prev_time = now; }
Pancake::Pancake(int size, int position) : Rectangle(pPoint(size,position),width1(size),20), s(size), p(position){} //construct a pancake