possible accuracy problem with the new clip sop?

   787   7   0
User Avatar
Member
74 posts
Joined:
Offline
Hello there,
I decided to test out the new clip sop to see if, now that we can use attributes to clip, it will be a good new way to bool curves. I've attached a hip file with my test. In it I use the distancefromgeo node to generate a distance attribute and I use that attribute in the clip node. Everything appears to work, but if you zoom in on the result you can see that it is not accurate enough, meaning the clipping does most of the time not happen exactly at the intersection of the geo used to generate the distance attribute. For comparison the setup also contains an intersection analysis sop and with this I am able to generate points exactly at the intersection. All of this is easier shown than explained in words, so please check out the attached file.

Ultimately what I am wondering about is what is causing the lack of accuracy? Is it the clip sop?
Or, it is the distance attribute that is causing the issue?
If it is the attribute, what would be a better way of generating an attribute for the clip sop?
Or, am I on the wrong path here all together? If so, what would a better method to do what I'm doing in the example be? Provided that this solution would be fast and reasonably simple...

Btw, I do love the fact that we can now use attributes to run the clip sop with. I just wish I could get it to clip at exactly the right spot.

Thanks,
Dag

Attachments:
bool_w_clip_accuracy_issue.hip (180.8 KB)

User Avatar
Member
491 posts
Joined: July 2005
Offline
Hi,
there is nothing wrong with the clip sop but with the "dist" attribute. You probably want the distance to the point projected along the z-axis and not the distance to the point projected to the closest point.

Attachments:
bool_w_clip_accuracy_issue_mod.hipnc (177.9 KB)

User Avatar
Member
7981 posts
Joined: Sept. 2011
Offline
Dougie0047
Ultimately what I am wondering about is what is causing the lack of accuracy? Is it the clip sop?
Or, it is the distance attribute that is causing the issue?
If it is the attribute, what would be a better way of generating an attribute for the clip sop?

Is it accurate at the vertices? I imagine the discrepancy lies on the nature of attribute interpolation. The distance is calculated at each point, but the clip is across the entire polygon. The point of clipping is calculated by interpolating the attribute from each vertex to the face--the true distance won't necessarily follow the same shape as the vertices. you can see this if you visualize the distance attribute with a color ramp, it will show where the clip will actually be.
User Avatar
Member
74 posts
Joined:
Offline
@Aizatulin - thanks for your reply, and for your modified example file. Actually a distance to the point projected along some specific axis is not what I want. In my own example file it is just set up like this for convenience sake and to be quick. In a more relevant example the curves would have arbitrary directions and would also not be just a bunch of straight lines. Most probably they would also not have to be flat on the xz plane.
Is your code easily adjustable for such a more realistic case?

EDIT: your original axis was the z-axis as you said. I've now added a mountain sop to deform the curves, and predictably the method fails to compute the distance correctly. Then I added an orient along curve sop, set to next edge to see if this fixes things, as in now I have a directional vector per point istead of a global one. This actually improves the result, but not enough. So I am still stuck with this interpolation issue or whatever it is. Any ideas?

Thanks,
Dag
Edited by Dougie0047 - July 19, 2024 16:15:07
User Avatar
Member
74 posts
Joined:
Offline
@jsmack - thank your for your reply. Yes, I believe you are right. As the attached image shows, when visualizing the dist attribute I have the color match to the the point of clipping, and this is not at the same spot as the bool geo.
But then my question would be: what is then the best/most efficient way to overcome this?

Thanks,
Dag

Attachments:
Screenshot 2024-07-19 215059.png (1.5 MB)

User Avatar
Member
8723 posts
Joined: July 2007
Offline
as Aizatulin pointed out your computed distance is not distance from the intersection point so it will not result in precise alignment as if it was, it has nothing to do with Clip SOP especially on polycurves where interpolation of distance attribute can be precise since it is exactly linear between 2 neighbouring points

you can compute precise distance by checking for intersection from each point to neighbouring point and recording the distance on both in case of intersection
you can get the sign from dot product between ray and hit normal
then extrapolate distances from hit point pairs

however you seem to be trying to do boolean on curves with solid shapes so this approach will still have some issues like:
- multiple cutters per line segment will be missed
- overlapping cutters may create confusing distance values
- curves without any intersection will not natively know whether to be deleted or not so additional check if fully inside will be needed, e.g. by winding number

Overall for boolean effect on curves you may have much easier time with Intersection Analysis/Stitch/Delete Inside
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
491 posts
Joined: July 2005
Offline
@Dougie0047 - if you take the idea of Tomas, you can replace the Z-direction by the direction to the neighbour points, which give you a more generic solution.

Attachments:
bool_w_clip_accuracy_issue_modA.hipnc (266.7 KB)

User Avatar
Member
74 posts
Joined:
Offline
@tamte and @Aizatulin,

thanks for your replies! Much appreciated! I will look into your suggestions as soon as I can.

Dag
  • Quick Links