Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3ed2533

Browse files
committed
Formatting and minor efficiency improvement.
svn path=/trunk/matplotlib/; revision=4986
1 parent bb8a16a commit 3ed2533

1 file changed

Lines changed: 11 additions & 22 deletions

File tree

src/_path.cpp

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ Py::Object _path_module::affine_transform(const Py::Tuple& args)
921921
}
922922

923923
result = (PyArrayObject*)PyArray_SimpleNew
924-
(PyArray_NDIM(vertices), PyArray_DIMS(vertices), PyArray_DOUBLE);
924+
(PyArray_NDIM(vertices), PyArray_DIMS(vertices), PyArray_DOUBLE);
925925
if (PyArray_NDIM(vertices) == 2)
926926
{
927927
size_t n = PyArray_DIM(vertices, 0);
@@ -1017,17 +1017,17 @@ Py::Object _path_module::count_bboxes_overlapping_bbox(const Py::Tuple& args)
10171017
return Py::Int(count);
10181018
}
10191019

1020-
bool segments_intersect(const double& x1, const double &y1,
1021-
const double& x2, const double &y2,
1022-
const double& x3, const double &y3,
1023-
const double& x4, const double &y4)
1020+
bool segments_intersect(const double& x1, const double& y1,
1021+
const double& x2, const double& y2,
1022+
const double& x3, const double& y3,
1023+
const double& x4, const double& y4)
10241024
{
1025-
double den = ((y4-y3) * (x2-x1)) - ((x4-x3)*(y2-y1));
1025+
double den = ((y4-y3)*(x2-x1)) - ((x4-x3)*(y2-y1));
10261026
if (den == 0.0)
10271027
return false;
10281028

1029-
double n1 = ((x4-x3) * (y1-y3)) - ((y4-y3)*(x1-x3));
1030-
double n2 = ((x2-x1) * (y1-y3)) - ((y2-y1)*(x1-x3));
1029+
double n1 = ((x4-x3)*(y1-y3)) - ((y4-y3)*(x1-x3));
1030+
double n2 = ((x2-x1)*(y1-y3)) - ((y2-y1)*(x1-x3));
10311031

10321032
double u1 = n1/den;
10331033
double u2 = n2/den;
@@ -1075,20 +1075,9 @@ Py::Object _path_module::path_intersects_path(const Py::Tuple& args)
10751075
PathIterator p1(args[0]);
10761076
PathIterator p2(args[1]);
10771077

1078-
bool intersects = ::path_intersects_path(p1, p2);
1079-
if (!intersects)
1080-
{
1081-
intersects = ::path_in_path(p1, agg::trans_affine(), p2, agg::trans_affine());
1082-
if (!intersects)
1083-
{
1084-
intersects = ::path_in_path(p2, agg::trans_affine(), p1, agg::trans_affine());
1085-
if (!intersects)
1086-
{
1087-
return Py::Int(0);
1088-
}
1089-
}
1090-
}
1091-
return Py::Int(1);
1078+
return Py::Int(::path_intersects_path(p1, p2)
1079+
|| ::path_in_path(p1, agg::trans_affine(), p2, agg::trans_affine())
1080+
|| ::path_in_path(p2, agg::trans_affine(), p1, agg::trans_affine()));
10921081
}
10931082

10941083
void _add_polygon(Py::List& polygons, const std::vector<double>& polygon) {

0 commit comments

Comments
 (0)