Splitting of shapes

Hello All,

I am stuck to an problem, in which i have to clip or split an polygon one the basis of divider line.

It may be an easy math for an expert. But i am not good in that

These are my polygon point

  1. 0: Vector3 {x: 0.42379530531678655, y: 0.001, z: 0.3513340397769077}
  2. 1: Vector3 {x: -0.29115869753800094, y: 0.001, z: 0.34800867212540565}
  3. 2: Vector3 {x: -0.3676420596677825, y: 0.001, z: 0.8069092762673487}
  4. 3: Vector3 {x: 0.5268815283072485, y: 0.001, z: 0.8069092762673488}

They are responsible for creating an rectangle like this

So what i need is , a function what can split my polygon into two part and polygon can be any shape.

To split i can draw a line that i know how to do and i have end points of the line but here i only need a Math that help to split my shape for example a rectangle into two rectangle.

Please provide help
Thanks

This has been solved before by Sutherland–Hodgman.

2 Likes

Complex math for me. Do you have a code pen. Please share

No I don’t. Being interested in the result provides an excellent opportunity for you to expand your math skills. How do you think people on this forum acquired theirs?

1 Like

For people, who seeking solution for this problem: