//поиск всех ближайших соседей
void search(MTreeNode* root, int s, double radius, vector<int> &Table){
	bool t = false;
	if(root != NULL){
		if ((diffLetters(root->center, s) - radius) <= root->radius){
			if (root->left != NULL){
				search(root->left, s, radius, Table);
			}
			else
				if(root->right == NULL)
					t = true;
		}
		if ((diffLetters(root->center, s) + radius) >= root->radius){
			if (root->right != NULL){
				search(root->right, s, radius, Table);
			}
			else
				if(root->left == NULL)
					t = true;
		}
		if(t)
			LinearSearch(root, s, radius, Table);
		else
			if(diffLetters(root->center, s) <= radius)
					FindP1[s] += 1;
	}
	return;
}
Beispiel #2
0
main()
{
	int i, n, item, arr[MAX], index;
	printf("Enter the number of elements : ");
	scanf("%d",&n);
	printf("Enter the elements : \n");
	for(i=0; i<n; i++)
		scanf("%d", &arr[i] );

	printf("Enter the item to be searched : ");
	scanf("%d", &item);
	
	index = LinearSearch(arr, n, item);
	
	if(index == -1)
		printf("%d not found in array\n", item);
	else
		printf("%d found at position %d\n", item, index);
}
void CAnimationProcessor::Interpolator(TAnimation* pAnim, float fCurrDuration, D3DXMATRIX* pCurrFrame)
{
	unsigned int LastFrame = 0, nextFrame = 0;

	for(unsigned int currBone = 0; currBone < pAnim->m_nNumMeshes; ++currBone)
	{
		LastFrame = LinearSearch(pAnim->m_pBones + currBone, fCurrDuration);
		if(LastFrame != pAnim->m_pBones[currBone].m_nNumFrames-1)
			nextFrame = LastFrame + 1;

		// Find Lambda value
		float tween = 0;
		float fromlast = fCurrDuration - pAnim->m_pBones[currBone].m_pKeyFrames[LastFrame].m_fDuration;
		if(nextFrame == 0)
			tween = pAnim->m_fDuration - pAnim->m_pBones[currBone].m_pKeyFrames[LastFrame].m_fDuration;
		else
			tween = pAnim->m_pBones[currBone].m_pKeyFrames[nextFrame].m_fDuration - pAnim->m_pBones[currBone].m_pKeyFrames[LastFrame].m_fDuration;
		float lambda = fromlast / tween;
		
		pCurrFrame[currBone] = Interpolate(pAnim->m_pBones[currBone].m_pKeyFrames[LastFrame].m_d3dTransform, pAnim->m_pBones[currBone].m_pKeyFrames[nextFrame].m_d3dTransform, lambda);
	}
}