Prabhath
Prabhath

Reputation: 73

Divide Voronoi cell using azimuth in R

I have generated a Voronoi tessellation for N number of points in 2D space using the deldir R package.

Voronoi Tesselation

Now I want to divide each Voronoi cell into three Voronoi cells according to given azimuth described as below:

Voronoi Azimuth

Azimuth is given as an input. E.g.: azimuth = 0 means an area should be separated by 2 lines at angle = 0 to angle = 120. Next area by angle = 120 to angle = 240 and last area is the remainder.

Azimuth is the starting angle from north for this separation and always it spans 120 degrees. In more detail, from each point Voronoi is generated exactly three lines are drawn dividing previous Voronoi cell into three Voronoi cells.

Can this be achieved using the deldir package? if not can anyone suggest a extension for this?

Upvotes: 2

Views: 533

Answers (1)

McGlear
McGlear

Reputation: 78

I don't know any easy/implemented way of doing this. However, you could try creating those lines manually.

I would try something along the lines of:

  1. Access the coordinates of the edges of a voronoi polygon using deldir()
  2. Convert the coordinates into line objects using the sp package
  3. Create line objects that reach from the "center"-point to the border of the plot (calculating the end points based on your azimuth)
  4. Find intersections of the lines created in 3 with the lines created in 2 (check How to get the intersection point of two vector?)
  5. Create new (shorter) lines starting from your original point and ending at the intersection point retrieved from step 4.
  6. Plot the lines created in 5.
  7. Loop for every polygon

This may well be a very clumsy solution, but it is the only workaround I could come up with ;)

Upvotes: 2

Related Questions