rebootcode / svg-edit

Automatically exported from code.google.com/p/svg-edit
MIT License
0 stars 0 forks source link

Better calculations of bounding boxes for rotated shapes #101

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Currently the axis-aligned bounding boxes for rotated shapes only works out
nicely for rectangles and lines, due to their rectangular shape.

For ellipses, circles, polys and freehands the bounding box grows farther
away from the shape the closer you get to 45 degrees due to our simple math.

We should customize the getBBox() code for each type of shape when it is
rotated:

a) for polys and freehands:  iterate through each point, rotate it into the
coordinate system of the shape, track MAX/MIN of X/Y

b) for ellipses:  well, it seems like this is not a new problem [1][2][3]
:)  The best answer seems [3] below, so we need to understand that math and
then do it in getBBox() for ellipses and circles.

[1] http://www.mail-archive.com/svg-developers@yahoogroups.com/msg05735.html
[2] http://board.flashkit.com/board/archive/index.php/t-639265.html
[3]
http://stackoverflow.com/questions/87734/how-do-you-calculate-the-axis-aligned-b
ounding-box-of-an-ellipse

Original issue reported on code.google.com by codedr...@gmail.com on 19 Aug 2009 at 4:19

GoogleCodeExporter commented 9 years ago
Ok, I handled rotated ellipse bbox calculation in r414.

Original comment by codedr...@gmail.com on 19 Aug 2009 at 4:50

GoogleCodeExporter commented 9 years ago
Note that for paths I don't think we need to worry about ensuring all of the 
points
on the curve segments are within the bbox, just look at the x,y of each path 
segment

Original comment by codedr...@gmail.com on 19 Aug 2009 at 5:04

GoogleCodeExporter commented 9 years ago

Original comment by codedr...@gmail.com on 19 Aug 2009 at 2:30

GoogleCodeExporter commented 9 years ago
Note that I'm beginning to think that maybe the selector boxes should just 
rotate
with the object, which obviates the need for this bug.  I think this would 
simplify
our code and align with what other editors do.

Original comment by codedr...@gmail.com on 19 Aug 2009 at 6:10

GoogleCodeExporter commented 9 years ago
Fixed in r416.  I think we may want to revisit the way selector boxes, 
rotations, etc
are handled for rotated elements.  I think we might want to rotate the selector
itself which obsoletes much of the code added for this issue.

Original comment by codedr...@gmail.com on 20 Aug 2009 at 5:34