Bounding box for multiple SVG paths - svg

I have some SVG paths which represent equations. There will be multiple on the canvas. I would like to pass all of these paths and get back grouped paths where each group represents a single equation.
Assumptions there is no overlap between the equations bounding boxes
After processing I should then be able to apply a bounding box to check the success the end result should be;
I already know how to apply a bounding box to a set of points. I am specifically struggling with how to determine which set of points or paths should go into a single group.
For example I would not want it to give me a bounding box for the "y", "=", "m" e.t.c separately that would be of little use.

Related

VBA to check if object is inside or outside of freeform area

I need help with this : I have Freeform area and shapes in form of circles named from A to G. Some of this points are inside of Freeform area and some of them no. I need macro which will check each of this points - if this point is inside/ outside of freeform area. How can i get result in form of table where in Column A are Names of shapes (circles-points) and in column B result (if point is inside/outside of freeform).
Thanks
Victor
Picture of what I need is here:
There are several ways to do that. Either over calculation of the Angles or by creating a ray trough the point and find the intersections To the polygons. If the count are even, it's inside; if it's odd it's outside. Those algorithms are not that trivial and numerical a challenge. Here are some links (They have vb6/vba source):
Paul Bourke Point inside Polygon
VB-Helper Point inside Polygon
If it has not that exact you may draw the points in a picturebox and determine the background color.
To find more search the web for "points inside polygon".

Rectangular connected component extraction in python

There are multiple rectangular areas in the 2d-numpy array. All the rectangular areas have value 1, other areas are zero. I want to extract a minimum number of rectangular connected components from the numpy array. These connected components can touch each other in any direction.
I tried extracting connected components using label function from scipy.ndimage.measurements but it assigns the same label to rectangles which touch each other.
I also tried, morphological opening but I do not want to lose the original shape of the rectangle.
The image shows the expected output for a better understanding of the problem.
Is there a better way to extract a minimum number of perfectly rectangular regions?

SVG Paths detect overlapping or enclosed shapes

I have brown filled svg paths and i want to detect and alert my user if there is any shape behind or above another shape. I know intersection list gets if they intersect at the edges but what happens if i want to detect a shape that is behind another shape but doesnt intersect at the edges?
The encoluseList method seems to be dealing with bounding boxes and not this.
Any ideas?
To detect if a path/shape overlaps another
1. Calculating the area covered by the final shape achieved
2. Calculating the sum of areas of all the shapes independently(since this is SVG and the details of each path element is known, this can be done)
3. Comparing the 2 areas.If the 2 areas are the same, then there is no overlapping otherwise at least 2 shapes overlap.
The tricky step is step 1 which can be approximately calculated using pixel painting algorithm(my preference). For other methods, you can go through the following stackoverflow question concerning area of overlapping circles

In Geocouch, how can I get all objects by lon/lat coordinates?

I.e. all objects that contain this coordinates (for polygons) or cross them (for lines)?
You can collapse the bounding box you query with to a point.

Finding a point clicked in a grid

Given this grid ( http://i.stack.imgur.com/Nz39I.jpg is a trapezium/trapezoid, not a square), how do you find the point clicked by the user? I.e. When the user clicks a point in the grid, it should return the coordinates like A1 or D5.
I am trying to write pseudo code for this and I am stuck. Can anyone help me? Thanks!
EDIT: I am still stuck... Does anyone know of any way to find the height of the grid?
If it is a true perspective projection, you can run the click-point through the inverse projection to find it's X,Z coordinates in the 3D world. That grid has regular spacing and you can use simple math to get the A1,D5,etc.
If it's just something you drew, then you'll have to compare the Y coordinates to the positions of the horizontal lines to figure out which row. Then you'll need to check its position (left/right) relative to the angled lines to get the column - for that, you'll need either coordinates of the end-points, or equations for the lines.
Yet another option is to store an identical image where each "square" is flood-filled with a different color. You then check the color of the pixel where the user clicked but in this alternate image. This method assumes that it's a fixed image and is the least flexible.
If you have the coordinates of end points of the grid lines then
Try using the inside-outside test for each grid line and find the position
Since this grid is just a 3D view of a 2D grid plane, there is a projective transform that transforms the coordinates on the grid into coordinates on the 2D plane. To find this transform, it is sufficient to mark 4 different points on the plane (say, the edges), assign them coordinates on the 2D plane and solve the resulting linear equation system.

Resources