# back face deleting from other object

## Recommended Posts

I'm making practice with vex code .I wrote short script but Its working very slow .Did i make mistake ? or Is this normal speed ? Also i did same thing wtih delete sop but I think Its not correct .

Edited by murathan altunsoy
##### Share on other sites

Well you are looping a lot, so yes it will be slow with that approach. Here's a simplified version I did quick:

##### Share on other sites

You don't need last cycle. It's repeating same thing N times. Delete it and everything will work fast.

For the minor improvements, there is no need to expand all points into 0..@numpt range array simply to iterate over it. Use regular for loop. uzak doesn't need to be array to find minimum from it. Override existing minimum inside loop.

```float uzak = 1;

for (int i = 0; i < npoints(1); i++)
{
vector pos = point(1, "P", i);
float query = dot(@N, normalize(@P - pos));
uzak = min(uzak, query);
}

if (uzak > 0)
removepoint(0, @ptnum);```

Edited by f1480187
##### Share on other sites

30 minutes ago, Skybar said:

Well you are looping a lot, so yes it will be slow with that approach. Here's a simplified version I did quick:

thank you David .Your solution is differnt approach

##### Share on other sites

18 minutes ago, f1480187 said:

You don't need last cycle. It's repeating same thing N times. Delete it and everything will work fast.

For the minor improvements, there is no need to expand all points into 0..@numpt range array simply to iterate over it. Use regular for loop. uzak doesn't need to be array to find minimum from it. Override existing minimum inside loop.

```
float uzak = 1;

for (int i = 0; i < npoints(1); i++)
{
vector pos = point(1, "P", i);
float query = dot(@N, normalize(@P - pos));
uzak = min(uzak, query);
}

if (uzak > 0)
removepoint(0, @ptnum);```

Thank you F1. This is  really good answer.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×