@@ -1094,8 +1094,6 @@ static double getDistance(const PointInfo *p,const PointInfo *q,
10941094 /*
10951095 Shortest distance between p to vector v through point q.
10961096 */
1097- if (fabs (v -> x ) < MagickEpsilon )
1098- return (fabs (p -> x - q -> x ));
10991097 gamma = v -> y * PerceptibleReciprocal (v -> x );
11001098 return (fabs (p -> y - (q -> y - gamma * q -> x )- gamma * p -> x )*
11011099 PerceptibleReciprocal (sqrt (gamma * gamma + 1.0 )));
@@ -1105,39 +1103,17 @@ static PointInfo getIntersection(const PointInfo *a,const PointInfo *b,
11051103 const PointInfo * c ,const PointInfo * d )
11061104{
11071105 PointInfo
1108- m = { 0.0 , 0.0 } ,
1109- p = { 0.0 , 0.0 } ,
1110- vertex = { 0.0 , 0.0 } ;
1106+ m ,
1107+ p ,
1108+ vertex ;
11111109
11121110 /*
11131111 Intersection: b passing through a and d passing c.
11141112 */
1115- if ((fabs (b -> x ) < MagickEpsilon ) && (fabs (d -> x ) < MagickEpsilon ))
1116- return (vertex );
1117- if (fabs (b -> x ) >= MagickEpsilon )
1118- {
1119- m .x = b -> y * PerceptibleReciprocal (b -> x );
1120- p .x = a -> y - m .x * a -> x ;
1121- }
1122- if (fabs (d -> x ) >= MagickEpsilon )
1123- {
1124- m .y = d -> y * PerceptibleReciprocal (d -> x );
1125- p .y = c -> y - m .y * c -> x ;
1126- }
1127- if (fabs (b -> x ) < MagickEpsilon )
1128- {
1129- vertex .x = a -> x ;
1130- vertex .y = m .y * a -> x + p .y ;
1131- return (vertex );
1132- }
1133- if (fabs (d -> x ) < MagickEpsilon )
1134- {
1135- vertex .x = c -> x ;
1136- vertex .y = m .x * c -> x + p .x ;
1137- return (vertex );
1138- }
1139- if (fabs (m .x - m .y ) < MagickEpsilon )
1140- return (vertex );
1113+ m .x = b -> y * PerceptibleReciprocal (b -> x );
1114+ p .x = a -> y - m .x * a -> x ;
1115+ m .y = d -> y * PerceptibleReciprocal (d -> x );
1116+ p .y = c -> y - m .y * c -> x ;
11411117 vertex .x = (p .y - p .x )* PerceptibleReciprocal (m .x - m .y );
11421118 vertex .y = m .x * vertex .x + p .x ;
11431119 return (vertex );
@@ -1275,23 +1251,23 @@ MagickExport PointInfo *GetImageMinimumBoundingBox(Image *image,
12751251 caliper [1 ]= rotateVector (& caliper [1 ],min_angle );
12761252 caliper [2 ]= rotateVector (& caliper [2 ],min_angle );
12771253 caliper [3 ]= rotateVector (& caliper [3 ],min_angle );
1278- if (angle [0 ] == min_angle )
1254+ if (fabs ( angle [0 ]- min_angle ) < MagickEpsilon )
12791255 {
12801256 width = getDistance (getVertex (vertices ,corner [1 ],hull_vertices ),
12811257 getVertex (vertices ,corner [0 ],hull_vertices ),& caliper [0 ]);
12821258 height = getDistance (getVertex (vertices ,corner [3 ],hull_vertices ),
12831259 getVertex (vertices ,corner [2 ],hull_vertices ),& caliper [2 ]);
12841260 }
12851261 else
1286- if (angle [1 ] == min_angle )
1262+ if (fabs ( angle [1 ]- min_angle ) < MagickEpsilon )
12871263 {
12881264 width = getDistance (getVertex (vertices ,corner [0 ],hull_vertices ),
12891265 getVertex (vertices ,corner [1 ],hull_vertices ),& caliper [1 ]);
12901266 height = getDistance (getVertex (vertices ,corner [3 ],hull_vertices ),
12911267 getVertex (vertices ,corner [2 ],hull_vertices ),& caliper [2 ]);
12921268 }
12931269 else
1294- if (angle [2 ] == min_angle )
1270+ if (fabs ( angle [2 ]- min_angle ) < MagickEpsilon )
12951271 {
12961272 width = getDistance (getVertex (vertices ,corner [1 ],hull_vertices ),
12971273 getVertex (vertices ,corner [0 ],hull_vertices ),& caliper [0 ]);
@@ -1307,7 +1283,7 @@ MagickExport PointInfo *GetImageMinimumBoundingBox(Image *image,
13071283 }
13081284 radians += min_angle ;
13091285 area = width * height ;
1310- if ((fabs (caliper_area ) < MagickEpsilon ) || (area < caliper_area ))
1286+ if ((fabs (caliper_area ) < MagickEpsilon ) || (area <= caliper_area ))
13111287 {
13121288 support [0 ][0 ]= (* getVertex (vertices ,corner [0 ],hull_vertices ));
13131289 support [0 ][1 ]= caliper [0 ];
0 commit comments