How to clip polyline

Hello All,

I have curve line that help me to create polygon like structures in my tool and my polylines are similar as autocad polylines.

Now i am looking into a way that help me to split the polyline.

Let say if the polyline is forming an square and i draw an another polyline and try to split the square into two triangles so how i can do that with three js.

Thanks

hello, this question do you solved?

threejs does not do this. there is an excellent library called Clipper that does.

https://sourceforge.net/p/jsclipper/wiki/Home%206/

there are npm packages as well

Hello @n1ka, what you’re looking for are “Boolean Clipping Operations”, like union, intersection, difference and xor.

As @s0a mentioned, many libraries can perform these operations.

Here is an example I setup of how it works / rendering with canvas.

You’ll see the source polygon, followed by the polygon that will be clipped from the source, followed by the result.

Chris

this library use two polygon. do you have use two point clip polygon of library
绘制幼儿园用地红线-翼排

the clipper library does not provide a method to clip a polygon using two points. it only does polygon <> polygon booleans. you will have to use the technique I described in the other post to achieve your result. I do this in my application extensively.

Can you give me a url. I don’t search it what you say

I posted the algorithm I use here: How to Intercept the boundary between two points of a polygon - #5 by s0a