Trigonometric functions precision

Hello,

I am working on sort of “self proximity node” I have various curves and I need to detect line vertices when they get too close to the same ID line segment, then add cut to this segment and set its position. I need this usage mainly for detecting the points where the distance is almost 0 or lets say below 1mm

to detect the distance I am using this simple trigon formula:

example simplified blend:
precision.blend (605.0 KB)

as you see in some cases I am getting the value 0.01m = 1cm! where the real distance is 0.008cm
so when I want to detect points below 1mm this one is filtered out.

During the computations all lines medians are set to 0,0,0 so I am staying close to origin as much as possible.

any suggections/advices/workarounds please?

many thanks!

I have done some tests with a node I have got by some useful misunderstanding accident from @Zebrahead here , it uses matrices to get the vectors intersections, so I just set the line direction vector to the point position, rotate it 90 degrees and then subtract the intersection position from the point position, seems to me with the matrices it works ok… just performance wise its a bit slower…

Not sure if i get this right but you could use a double cross product to get the perpendicular vector and then use a dot product to get the distance to your red “length line” (basically the green 0.1m in your image):


The slight error in your solution probably comes from too many conversion steps!

Many Thanks Zebra, its stable and precise in my real project tests so far. Asked on BSE as well, so just for records here is link to another solution

No problem :slight_smile:
You could also use a vector rejection instead :

Good luck!

An aside re: @Zebrahead & “vector rejection”,

One reason I send money to wikipedia every year!

nice, it looks similar to what I did with your intersection node, I should learn the vector nodes in detail first before working on projects, but I do not have time because I am working on projects;)