MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / bisectrix

Function bisectrix

dep/agg/src/agg_line_aa_basics.cpp:51–80  ·  view source on GitHub ↗

-------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

49
50 //-------------------------------------------------------------------------
51 void bisectrix(const line_parameters& l1,
52 const line_parameters& l2,
53 int* x, int* y)
54 {
55 double k = double(l2.len) / double(l1.len);
56 double tx = l2.x2 - (l2.x1 - l1.x1) * k;
57 double ty = l2.y2 - (l2.y1 - l1.y1) * k;
58
59 //All bisectrices must be on the right of the line
60 //If the next point is on the left (l1 => l2.2)
61 //then the bisectix should be rotated by 180 degrees.
62 if(double(l2.x2 - l2.x1) * double(l2.y1 - l1.y1) <
63 double(l2.y2 - l2.y1) * double(l2.x1 - l1.x1) + 100.0)
64 {
65 tx -= (tx - l2.x1) * 2.0;
66 ty -= (ty - l2.y1) * 2.0;
67 }
68
69 // Check if the bisectrix is too short
70 double dx = tx - l2.x1;
71 double dy = ty - l2.y1;
72 if((int)std::sqrt(dx * dx + dy * dy) < line_subpixel_scale)
73 {
74 *x = (l2.x1 + l2.x1 + (l2.y1 - l1.y1) + (l2.y2 - l2.y1)) >> 1;
75 *y = (l2.y1 + l2.y1 - (l2.x1 - l1.x1) - (l2.x2 - l2.x1)) >> 1;
76 return;
77 }
78 *x = iround(tx);
79 *y = iround(ty);
80 }
81
82}

Callers 2

drawMethod · 0.85
renderMethod · 0.85

Calls 1

iroundFunction · 0.85

Tested by

no test coverage detected