Skip to content

Conversation

@chz65757
Copy link
Collaborator

No description provided.

@chz65757 chz65757 requested a review from PninaShlomovitz July 31, 2024 12:45
{
//If the point I want to add already exists
if (quadTree->quadNode->imagePoints.TL.x == node->imagePoints.TL.x && quadTree->quadNode->imagePoints.TL.y == node->imagePoints.TL.y) {
removeIfExist(quadTree->quadNode->LinkedList_ptr);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enter to this function(remove if exsit) all the logic

//If the point I want to add already exists
if (quadTree->quadNode->imagePoints.TL.x == node->imagePoints.TL.x && quadTree->quadNode->imagePoints.TL.y == node->imagePoints.TL.y) {
removeIfExist(quadTree->quadNode->LinkedList_ptr);
QuadNode_t* saveToRemove = quadTree->quadNode;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allocate all var at the begining

// Checks whether to enter the TL
if (existingNode->imagePoints.TL.x <= midX && existingNode->imagePoints.TL.y <= midY)
{
if (quadTree->topLeftTree == NULL)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove and assert

{
if (quadTree->topLeftTree == NULL)
{
quadTree->topLeftTree = createQuadTree(quadTree->TL, CreatePoint(midX, midY));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add function that do switch from where

QuadNode_t* existingNode = quadTree->quadNode;
quadTree->quadNode = NULL;
// Checks whether to enter the TL
if (existingNode->imagePoints.TL.x <= midX && existingNode->imagePoints.TL.y <= midY)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add the if to new func for checking from where the point came.

free(saveToRemove);
return;
}
else
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the else

if (existingNode->imagePoints.TL.x <= midX && existingNode->imagePoints.TL.y > midY)
{
if (quadTree->botLeftTree == NULL)
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add new func that create quadTree and init all parms used at all the if's

return;
}
//The place I want to enter is taken
if (quadTree->quadNode != NULL)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to export to inline function and the name's func will explain what the if check

int midX = (quadTree->TL.x + quadTree->BR.x) / 2;
int midY = (quadTree->TL.y + quadTree->BR.y) / 2;
//The recursion breakpoint when the node found his correct place and everything is NULL
if (quadTree->quadNode == NULL && quadTree->topLeftTree == NULL &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export to inline function

free(saveToRemove);
return;
}
else
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else if ()*4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants