当前位置: 首页>>代码示例>>C++>>正文


C++ GetDistance函数代码示例

本文整理汇总了C++中GetDistance函数的典型用法代码示例。如果您正苦于以下问题:C++ GetDistance函数的具体用法?C++ GetDistance怎么用?C++ GetDistance使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetDistance函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: D3DXMatrixInverse

route_node* CRouter::InitCurDest(const D3DXMATRIX *mat)
{
	route_node *pDest = NULL;
	route_node *temp = m_pRouteList->GetRouteList();
	if (temp == NULL)
		return NULL;

	D3DXVECTOR3 vCur, vPrev;
	D3DXMATRIX mInverse;
	D3DXMatrixInverse(&mInverse, NULL, mat);
	float	fDistance = 1e10;
	do 
	{
		D3DXVec3TransformCoord(&vCur, temp->pPos, &mInverse);
		D3DXVec3TransformCoord(&vPrev, temp->pPrev->pPos, &mInverse);
		if ((vCur.z > 0) && (vPrev.z < 0))
		{
			vCur.y = vPrev.y = 0.0f;//消除俯仰偏角
			//避免存在平行街道,如果存在,取最近的一条
			if (fDistance > GetDistance(&vCur, &vPrev))
			{
				fDistance = GetDistance(&vCur, &vPrev);
				pDest = temp;
			}
		}
		temp = temp->pNext;

	}	while (temp != m_pRouteList->GetRouteList());

	return pDest;
}
开发者ID:flair2005,项目名称:vr-bike,代码行数:31,代码来源:Router.cpp

示例2: GetDistance

void InterpolatorDistance2::GetInterpolationWeight(NNCandidate candidates[3], 
	int* indices, float* weights, Vertex v) 
{
	int K=3;
	float dist_v_c1 = GetDistance(v.pos, candidates[0].vertex.pos);
	float dist_v_c2 = GetDistance(v.pos, candidates[1].vertex.pos);
	float dist_v_c3 = GetDistance(v.pos, candidates[2].vertex.pos);
	
	float normalize = dist_v_c1 * dist_v_c2 + 
										dist_v_c1 * dist_v_c3 + 
										dist_v_c2 * dist_v_c3;

	if(normalize == 0.0f){
		for(int i=0; i<K; ++i){
			weights[i] = 1.0f/3.0f;
		}
	}
	else{
		weights[0] = dist_v_c2 * dist_v_c3 / normalize;
		weights[1] = dist_v_c1 * dist_v_c3 / normalize;
		weights[2] = dist_v_c1 * dist_v_c2 / normalize;
	}

	for(int i=0; i<K; ++i){
		indices[i] = candidates[i].index;
	}
}
开发者ID:flosmn,项目名称:MeshPRT,代码行数:27,代码来源:InterpolatorDistance2.cpp

示例3: while

/**
*  @brief
*    Sets the node position
*/
void GraphNode::SetPos(float fX, float fY, float fZ)
{
	// Set new position
	m_vPos.SetXYZ(fX, fY, fZ);

	{ // Calculate all node distances
		Iterator<Neighbour*> cIterator = m_lstNeighbours.GetIterator();
		while (cIterator.HasNext()) {
			Neighbour *pNeighbour = cIterator.Next();
			pNeighbour->fDistance = GetDistance(*pNeighbour->pNode);
		}
	}

	{ // Update all neighbour node distances
		Iterator<GraphNode*> cIterator = m_lstIsNeighbourFrom.GetIterator();
		while (cIterator.HasNext()) {
			// Find this node within the neighbour
			Iterator<Neighbour*> cNeighbourIterator = cIterator.Next()->m_lstNeighbours.GetIterator();
			while (cNeighbourIterator.HasNext()) {
				Neighbour *pNeighbour = cNeighbourIterator.Next();
				if (pNeighbour->pNode == this) {
					pNeighbour->fDistance = GetDistance(*pNeighbour->pNode);
					break;
				}
			}
		}
	}
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:32,代码来源:GraphNode.cpp

示例4: CheckNewPoint

void CheckNewPoint(void) {
    // 检查是不是有没有处理的新点
    if (chkedPntsN < spcPntsN && spcPnts[spcPntsN].dist + 4 < GetDistance() ) {
        if (lastAllWhiteDist == 0 || lastAllWhiteDist + 70 < GetDistance()) {
            if (spcPnts[spcPntsN].allWhite > 0) {
                // 进入坡道
                //PORTB = ~(1);
                lastAllWhiteDist = GetDistance();

                ProcRamp();

            }

            if (spcPnts[spcPntsN].allBlack > 0 || spcPnts[spcPntsN].likeStart > 0) {
                // 此处 乘3 因为allBlack 往往比 likeStart 大很多
                if (spcPnts[spcPntsN].allBlack > spcPnts[spcPntsN].likeStart * 3) {
                    // 交叉点
                    //PORTB = ~PORTB;
                    ProcCrossLine();

                } else {
                    // 出发线
                    //PORTB = 0x9;
                    ProcStartLine();


                }
            }
        }
        chkedPntsN++;
    }
}
开发者ID:xfguo,项目名称:freescalesmartcar,代码行数:32,代码来源:cCoreControl.c

示例5:

GameObject* S013010C_Aaron_Smith_Steering::GetClosestObject(Vector2D ahead1, Vector2D ahead2)
{
	GameObject* closestObj = nullptr;

	obstacles = ObstacleManager::Instance()->GetObstacles();
	for (GameObject* obj : obstacles)
	{
		//bool collision = CheckLineInstersect(ahead1, ahead2, obj);
		
		bool collision = Collisions::Instance()->PointInBox(ahead2, obj->GetAdjustedBoundingBox());

		if (collision)
		{
		
			if (closestObj == NULL)
				closestObj = obj;
			else
			{
				if (GetDistance(mTank->GetCentrePosition(), obj->GetCentralPosition()) < GetDistance(mTank->GetCentrePosition(), closestObj->GetCentralPosition()))
					closestObj = obj;
			}
		}
		
	}

	return closestObj;

}
开发者ID:CrohnsAndMe,项目名称:Test,代码行数:28,代码来源:S013010C_Aaron_Smith_Steering.cpp

示例6: GetMinDistance

f32 Toolkit :: GetMinDistance(position2df p, Node2DInfo* pNode2DInfo)
{
	core::line2df l[4];
	f32 minDis = 0.f;
	l[0].start = pNode2DInfo->corner[0];
	l[0].end = pNode2DInfo->corner[1];

	l[1].start = pNode2DInfo->corner[1];
	l[1].end = pNode2DInfo->corner[2];

	l[2].start = pNode2DInfo->corner[2];
	l[2].end = pNode2DInfo->corner[3];

	l[3].start = pNode2DInfo->corner[3];
	l[3].end = pNode2DInfo->corner[0];
	minDis = GetDistance(l[0].getClosestPoint(p), p);
	for (int i = 0; i < 4; i++)
	{
		f32 t = GetDistance(l[i].getClosestPoint(p), p);
		if ( minDis > t )
		{
			minDis = t;
		}
	}
	
	return minDis;
}
开发者ID:HermanYang,项目名称:Scar,代码行数:27,代码来源:Toolkit.cpp

示例7: FindWaypoint

bool NPC::DoWaypointNav (void)
{
	if (m_currentWaypointIndex < 0 || m_currentWaypointIndex >= g_numWaypoints)
		FindWaypoint();

	float waypointDistance = GetDistance(pev->origin, m_waypointOrigin);
	float desiredDistance = g_waypoint->g_waypointPointRadius[m_currentWaypointIndex];

	if (desiredDistance < 16.0f && waypointDistance < 30.0f)
	{
		Vector nextFrameOrigin = pev->origin + (pev->velocity * m_frameInterval);

		if (GetDistance(nextFrameOrigin, m_waypointOrigin) >= waypointDistance)
			desiredDistance = waypointDistance + 1.0f;
	}
	
	if (waypointDistance < desiredDistance)
	{
		if (m_goalWaypoint == m_currentWaypointIndex)
			return true;
		else if (m_navNode == null)
			return false;

		HeadTowardWaypoint();
		return false;
	}

	if (GetDistance(m_waypointOrigin, pev->origin) <= 2.0f)
		HeadTowardWaypoint();

	return false;
}
开发者ID:CCNHsK-Dev,项目名称:SyPB,代码行数:32,代码来源:npc_ai.cpp

示例8: hgeCreate

void Hero::Dash()
{
	HGE *hge = hgeCreate(HGE_VERSION);
	GameObject *temp = GameObject::MakePosObject(TargetX2, TargetY2);
	if (locked == false)
	{

		SowrdCharge -= GetDistance(temp);
		if ((int)SowrdCharge > 0) 
		{
			locked = true;
			adddmg = GetDistance(temp) / 20;
			TargetX = TargetX2;
			TargetY = TargetY2;
		}
		else
		{
			SowrdCharge += GetDistance(temp);
			return;
		}
	}
	if (locked)
	{	
		SetSpeed(SPEED + (GetDistance(temp) * 8));
	}
}
开发者ID:Hiseen,项目名称:HGE1,代码行数:26,代码来源:Hero.cpp

示例9: ClickDoor

void MQ2NavigationPlugin::AttemptClick()
{
	if (!m_isActive && !m_bSpamClick)
		return;

	// don't execute if we've got an item on the cursor.
	if (GetCharInfo2()->pInventoryArray && GetCharInfo2()->pInventoryArray->Inventory.Cursor)
		return;

	clock::time_point now = clock::now();

	// only execute every 500 milliseconds
	if (now < m_lastClick + std::chrono::milliseconds(500))
		return;
	m_lastClick = now;

	if (m_pEndingDoor && GetDistance(m_pEndingDoor->X, m_pEndingDoor->Y) < 25)
	{
		ClickDoor(m_pEndingDoor);
	}
	else if (m_pEndingItem && GetDistance(m_pEndingItem->X, m_pEndingItem->Y) < 25)
	{
		ClickGroundItem(m_pEndingItem);
	}
}
开发者ID:dannuic,项目名称:MQ2Nav,代码行数:25,代码来源:MQ2Navigation.cpp

示例10: ProcStartLine

void ProcStartLine(void) {
    nowLoop++;
    switch (nowLoop) {
    case 1:
        PORTB = ~0x22;

        StartLineDist[0] = GetDistance();
        break;
    case 2:
        StartLineDist[1] = GetDistance();

        PORTB = 0xA5;

        // 跑完第二圈后停下
        DistLimit = ( GetDistance() + (StartLineDist[1] - StartLineDist[0]) ) / 25 + 4;
        /** 在这里触发路径播放 **/
        StartPathPlay();

        //maxSpeed = 110;
        //minSpeed = 75;


        break;
    case 3:
        // 到第三圈后停下
        StartLineDist[2] = GetDistance();

        PORTB = 0x81;
        //DistLimit = GetDistance() / 25 + 2;
        break;
    default:
        break;
    }
}
开发者ID:xfguo,项目名称:freescalesmartcar,代码行数:34,代码来源:cCoreControl.c

示例11: sort

void PreRanker::Filter(bool viewportSearch)
{
  using TSet = set<impl::PreResult1, LessFeatureID>;
  TSet theSet;

  sort(m_results.begin(), m_results.end(), ComparePreResult1());
  m_results.erase(unique(m_results.begin(), m_results.end(), EqualFeatureID()), m_results.end());

  sort(m_results.begin(), m_results.end(), &impl::PreResult1::LessDistance);

  if (m_limit != 0 && m_results.size() > m_limit)
  {
    // Priority is some kind of distance from the viewport or
    // position, therefore if we have a bunch of results with the same
    // priority, we have no idea here which results are relevant.  To
    // prevent bias from previous search routines (like sorting by
    // feature id) this code randomly selects tail of the
    // sorted-by-priority list of pre-results.

    double const last = m_results[m_limit - 1].GetDistance();

    auto b = m_results.begin() + m_limit - 1;
    for (; b != m_results.begin() && b->GetDistance() == last; --b)
      ;
    if (b->GetDistance() != last)
      ++b;

    auto e = m_results.begin() + m_limit;
    for (; e != m_results.end() && e->GetDistance() == last; ++e)
      ;

    // The main reason of shuffling here is to select a random subset
    // from the low-priority results. We're using a linear
    // congruential method with default seed because it is fast,
    // simple and doesn't need an external entropy source.
    //
    // TODO (@y, @m, @vng): consider to take some kind of hash from
    // features and then select a subset with smallest values of this
    // hash.  In this case this subset of results will be persistent
    // to small changes in the original set.
    minstd_rand engine;
    shuffle(b, e, engine);
  }
  theSet.insert(m_results.begin(), m_results.begin() + min(m_results.size(), m_limit));

  if (!viewportSearch)
  {
    size_t n = min(m_results.size(), m_limit);
    nth_element(m_results.begin(), m_results.begin() + n, m_results.end(),
                &impl::PreResult1::LessRank);
    theSet.insert(m_results.begin(), m_results.begin() + n);
  }

  m_results.reserve(theSet.size());
  m_results.clear();
  copy(theSet.begin(), theSet.end(), back_inserter(m_results));
}
开发者ID:igortomko,项目名称:omim,代码行数:57,代码来源:pre_ranker.cpp

示例12: NodeFromWorldPoint

vector<PositionNode*> AstarPathfind::FindPath(Vector2 startPos, Vector2 targetPos)
{
	PositionNode* startNode = NodeFromWorldPoint(startPos);
	PositionNode* targetNode = NodeFromWorldPoint(targetPos);

	vector<PositionNode*> openSet;
	vector<PositionNode*> closeSet;

	openSet.push_back(startNode);

	while(openSet.size() > 0)
	{
		PositionNode* currentNode = openSet[0];
		
		for(int i = 1; i < openSet.size(); ++i)
		{
			if(openSet[i]->GetfCost() < currentNode->GetfCost() || (openSet[i]->GetfCost() == currentNode->GetfCost() && openSet[i]->GethCost() < currentNode->GethCost()))
			{
				currentNode = openSet[i];
			}
		}

		openSet.erase(std::remove(openSet.begin(), openSet.end(), currentNode), openSet.end());
		closeSet.push_back(currentNode);

		if(currentNode == targetNode)
		{
			openSet.clear();
			closeSet.clear();
			return RetracePath(startNode, targetNode);
		}

		vector<PositionNode*> neighbours = GetNeighbours(currentNode);

		for(int i = 0; i < neighbours.size(); ++i)
		{
			if(!neighbours[i]->GetWalkable() || (std::find(closeSet.begin(), closeSet.end(), neighbours[i]) != closeSet.end()))
			{
				continue;
			}

			int newMovementCostToNeighbour = currentNode->GetgCost() + GetDistance(currentNode, neighbours[i]);

			if(newMovementCostToNeighbour < neighbours[i]->GetgCost() || !(std::find(openSet.begin(), openSet.end(), neighbours[i]) != openSet.end()))
			{
				neighbours[i]->SetgCost(newMovementCostToNeighbour);
				neighbours[i]->SethCost(GetDistance(neighbours[i], targetNode));
				neighbours[i]->SetParentNode(currentNode);

				if(!(std::find(openSet.begin(), openSet.end(), neighbours[i]) != openSet.end()))
				{
					openSet.push_back(neighbours[i]);
				}
			}
		}
	}
}
开发者ID:blazetrinity,项目名称:SP3,代码行数:57,代码来源:AstarPathfind.cpp

示例13: ln

double F::DISTANCE::GetLineSegmentPointDistance(const CLineSegment &_ls, const CVector &_p )
{
	CLine ln(_ls);
	double dist = GetLinePointDistance(ln,_p);

	if(F::INTERSECTION::PointProjectionOnLineSegment(_p, _ls))
		return dist;

	return F::MISC::Min(GetDistance(_ls.a,_p), GetDistance(_ls.b,_p));
}
开发者ID:vladamakaric,项目名称:softBodyDynamics,代码行数:10,代码来源:f_distance.cpp

示例14: NewSpecialPoint

// 检测是不是同一个点, 不是则新开一个
void NewSpecialPoint(void) {
    if (GetDistance() - spcPnts[spcPntsN].dist > 8) {
        if (spcPntsN > 28) return;
        spcPntsN++;
        spcPnts[spcPntsN].allWhite = 0;
        spcPnts[spcPntsN].allBlack = 0;
        spcPnts[spcPntsN].likeStart = 0;
        spcPnts[spcPntsN].dist = GetDistance();
    }
}
开发者ID:xfguo,项目名称:freescalesmartcar,代码行数:11,代码来源:cCoreControl.c

示例15: IsInside

	Side Plane::IsInside(const BoxBounds& aabb) const
	{
		if (GetDistance(aabb.GetVertexP(mNormal)) < 0) {
			return Side::Out;
		}
		if (GetDistance(aabb.GetVertexN(mNormal)) > 0)
		{
			return Side::In;
		}
		return Side::Cross;
	}
开发者ID:luxuia,项目名称:JustEngine,代码行数:11,代码来源:Plane.cpp


注:本文中的GetDistance函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。