Returns the parameterized value of the line p2--p3 where it intersects with p0--p1 */
| 128 | |
| 129 | /** Returns the parameterized value of the line p2--p3 where it intersects with p0--p1 */ |
| 130 | static float getLineCrossing(math::Vec p0, math::Vec p1, math::Vec p2, math::Vec p3) { |
| 131 | math::Vec b = p2.minus(p0); |
| 132 | math::Vec d = p1.minus(p0); |
| 133 | math::Vec e = p3.minus(p2); |
| 134 | float m = d.x * e.y - d.y * e.x; |
| 135 | // Check if lines are parallel, or if either pair of points are equal |
| 136 | if (std::abs(m) < 1e-6) |
| 137 | return NAN; |
| 138 | return -(d.x * b.y - d.y * b.x) / m; |
| 139 | } |
| 140 | |
| 141 | void svgDraw(NVGcontext* vg, NSVGimage* svg) { |
| 142 | DEBUG_ONLY(printf("new image: %g x %g px\n", svg->width, svg->height);) |