c# - Edge intersection control -


im trying implement voronoi diagram generation.

currently working this: when site event happens find intersection point between x = const , parabol. point draw through bisecting line between parabols focus , current site. line consists of 2 rays initally. both start @ intersection point, 1 goes left , other right. additionally bisecting lien have know f , g y = f*x +g.

during circle event(getting vertex joins 2 edges) need find intersection point of 2 edges. following code works fine if midpoint(start of 2 rays) lies between 2 edge intersections. seems me quite happens mid point beyond 1 of intersection points, , intersection not happen.

can find issue code? followed instruction(read c++ code in: http://blog.ivank.net/fortunes-algorithm-and-implementation.html) sweepline moved top bottom , (0,0) top left. sweepline moves top bottom , (0,0) bottom left. math somewhere off.

full code: https://codeshare.io/glwrqb

public vector3 rayintersection(voronoiedge a, voronoiedge b)     {         float x = (b.g - a.g) / (a.f - b.f);         float y = a.f * x + a.g;          if ((x - a.start.x) * a.dx < 0) return vector3.zero;         if ((y - a.start.y) * a.dy < 0) return vector3.zero;         if ((x - b.start.x) * b.dx < 0) return vector3.zero;         if ((y - b.start.y) * b.dy < 0) return vector3.zero;          return new vector3(x,y);     } 

edit:

after trial , error have found problem not intersection check. in cases happens wrong edges compared.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -