I want to find that minimum circle radius that cover circular arc. here is a api link that i need but i think it is not open source:http://reference.mapinfo.com/common/docs/mapxtend-dev-web-none-eng/miaware/doc/apidoc/com/mapinfo/miAware/geom/CircArc.html
A function should be like that and it will return Circle.
public Circle CircArc(double x, double y, double inRadius, double outRadius, double startAngle, double stopAngle)
after i will be able to get center of circle coordinates and radius like that:
circle.getXCoord();
circle.getYCoord();
circle.getRadius();
Is there any api?If not how can i implement CircArc function?
Compute the locations of the two endpoints of the outer circle. There are two cases:
if the arc aperture is smaller than a half turn: the diameter of the requested circle is the line segment between these endpoints,
otherwise: the circle is just the circle of support of the arc.
Anyway, there remains a difficult configuration with arcs of a small aperture such that the inner arc might pass the circle defined above.
Related
I'm using Firebase for one of my projects and was wondering if the following would be possible to achieve using Geofire.
I have a list of points with radiuses in which they are available (lat, lng, radius). In the image attached, the blue circle is created by the point and its radius.
I want to find all of the circles that reach user's location (red circle - just a point). The final effect I want to achieve is similar to seeing all the wifi networks around you - some of which might have a stronger signal.
Can it be done using Geofire? If yes, how should I approach the query?
Firebase can't handle a query like this, as you can't have logic in an orderBy. I'm not sure geofire can get around that limitation (from the docs I've browsed it cannot) so then we must come up with another way of doing it. If you know the max size one of the circles can be we might be able to figure out roughly which circles to select.
(Side note, I'm going to assume you only want things in the top hemisphere, there's a bit more math if you want to handle both but I won't go into details here)
I'm going to describe roughly how to do it, latitude/longitude are tricky as you move closer to poles and radius does not always translate 1 - 1 with a circle near the equator as it does farther north. For the most part this idea will work but the math for determining the min/max will change as well as the final step where you loop.
Based on the red point and max circle radius create the following variables
minLatitude: (red circle latitude) - (max circle radius)
maxLatitude: (red circle latitude) + (max circle radius)
minLongitutde: (red circle longitude) - (max circle radius)
maxLongitutde: (red circle longitude) + (max circle radius)
you'll have to update your databse to have an index that is searchable for each of the blue circles that contains both latitude and longitude with a certain decimal precision.
Something like LATITUDE_LONGITUDE.
Do a query like: ... orderByChild('_latitude_longitude').startAt(minLatitude + '_' + minLatitude).endAt(maxLatitude + '_' + maxLongitutde) (don't forget to make sure these all have the same precision)
This will return to you all circles that will be within a max radius of your red circle
You'll then have to loop through all of the circles returned and see if based on their own radius if the red circle is contained (very simple math formula here, plenty of examples online)
That's the only method I can think of that has no server side processing.
I have an UIBezierPath and want to know the coordinates of some points that lay on that path.
E.g. the rightmost point, or the point thats most to the left and to the bottom.
How could I calculate this in swift?
THX
You can obtain the bounds property from the UIBezierPath instance.
Note the following caveat:
The value in this property represents the smallest rectangle that completely encloses all points in the path, including any control points for Bézier and quadratic curves.
I am trying to find circles in images and warp them back to a canonical view (i.e. as if looking into the center). However, circles in general project to ellipses under perspective transformations. So I am first detecting ellipses, roughly doing the following (in OpenCV):
1. Find contours in the image
2. Estimate area of contour
3. Fitting a bounded box to contour and estimating area by width/2 * height/2 * PI (area of ellipse)
4. checking if area of contour and estimated area of ellipse is < a threhsold
Assuming I have found an ellipse by this method, how can I rectify it back to a circle such that I "undo" the perspective transform (although not in plane rotation as this cannot be done I guess). For example, if it was a rectangle I would just compute the homography from the 4 corners of an uprigh rectangle to the detected projected one.
I have no idea how to do this with an ellipse, any help is much appreciated.
Thanks
A circle is indeed transformed into an ellipse by a perspective transformation, however its axes are not the same as the axes of the initial circle, as shown in this illustration:
(source: brian-curtis.com)
You can refer to this link for a detailled demonstration. As a consequence, the bounding rectangle of the ellipse is not the image of the initial square by the perspective tranformation.
EDIT:
This means that the center and the axes of the ellipse you observe are not the images, by the perspective mapping, of the center and axes of the original circle. I tried to make a clearer illustration:
On this image, I drew in green the axes and center of the original circle, after perspective transformation, and the axes and center of the ellipse in red. On this specific example, the vertical axis is not deformed by the perspective mapping, but it would be deformed in the general case. Hence, deforming a circle by a perspective transformation gives an ellipse, but the axes and center that you see are not the axes and center of the original circle.
As a consequence, you cannot simply use the top, bottom, left and right points on the ellipse (the red points, which can easily be detected from the ellipse) to map these onto the top, bottom, left and right points of the circle because they do not correspond under the perspective mapping (the green points do, but they cannot be detected easily from the ellipse).
In the end, I don't think that it is at all possible to estimate the perspective mapping from a single detected ellipse.
This looks like an indeterminate problem.
The projection of a rectangle supplies 8 equations in 8 unknowns (homography coefficients).
With an ellipse, you can only retrieve the center coordinates (2 DOF), the axis (2 DOF) and the axis orientation (1 DOF).
I'm drawing squares along a circular path for an iOS application. However, at certain points along the circle, the squares start to go out of the circle's circumference. How do I make sure that the squares stay inside?
Here's an illustration I made. The green squares represent the positions I need the squares to actually be in. The red squares are where they actually appear given the following values for each square's upper-left corner:
x = origin.x + radius * cos(DEGREES_TO_RADIANS(angle));
y = origin.y + radius * sin(DEGREES_TO_RADIANS(angle));
Origin refers to the center of the circle. I have a loop that repeats this for every angle from 1 till 360 degrees.
EDIT: I've changed my design to position the centers of the squares along the circular path rather than their upper left corners.
why not just draw the centers of the squares along a smaller circle inside of the bigger one?
You could do the math to figure out exactly what the radius would have to be to ensure an exact fit, but you could probably trial and error your way there quickly too.
Doing it this way ensures that your objects would end up laid out in an actual circle too, which is not the case if you were merely making sure that one and only one corner of each square touched the larger bounding circle (that would create a slightly octagonal shape instead of a circle)
ryan cumley's answer made me realize how dumb I was all along. I just needed to change each square's anchor point to its center & that solved it. Now every calculated value for x & y would position every square's center exactly on the circular path.
Option 1) You could always find the diameter of the circle and then using Pythagorean Theorem, you could create a square that would fit perfectly within the circle. You could then loop through the square that was just made in the circle to create smaller squares, but I doubt this is what you are aiming for.
Option2) Find out what half of the length of one of the diagonals of the squares should be, and create a ring within the first ring. Then lay down squares at key points (like ever 30 degrees or 15 degrees, etc) along the inner path. Ex: http://i.imgur.com/1XYhoQ0.png
As you can see, the smaller (inner) circle is in the center of each green square, and that ensures that the corners of each square just touches the larger (outer) circle. Obviously my cheaply made picture in paint is not perfect, but mathematically it will work.
I would like to use UIBezierPath to create a polygon shape with rounded corners. I believe this will be possible using addCurveToPoint:controlPoint1:controlPoint2: and similar code to that found in http://www.codeproject.com/Articles/31859/Draw-a-Smooth-Curve-through-a-Set-of-2D-Points-wit, but I was wondering if there's any existing (or better) way to achieve this?
I should point out that this will need to be for any convex polygon (such as found in a voronoi diagram) and not just a rectangular shape.
You don't want addCurveToPoint. If you're using UIBezierPath, you want addArcWithCenter:radius:startAngle:endAngle:clockwise:
Here's what you do. Draw your rectangle. Figure out the corner radius you want. Draw circles in each corner, inset from each side by your corner radius. (the center of each corner circle will be inset from each corner by the corner radius in both x and y.) Then map out a sequence of 4 lines, connecting the points where your rectangle touches the circles in each corner.
Each arc will cover 90 degrees (pi/2, in radians.) The top right corner's are will range from 0 to pi/2. The top left corner's angle will start at pi/2 and go to pi. the bottom left corner's arc will range from pi to 3/2 pi. The bottom right arc's angle will range from 3/2 pi to 2pi.
You'll use a sequence of:
moveToPoint addLineToPoint -- first side
addArcWithCenter:radius:startAngle:endAngle:clockwise -- first
rounded corner
lineToPoint --second side, to beginning of next rounded corner
addArcWithCenter:radius:startAngle:endAngle:clockwise -- second
rounded corner
lineToPoint --third side, to beginning of next rounded corner
addArcWithCenter:radius:startAngle:endAngle:clockwise -- third
rounded corner
lineToPoint --forth side, to beginning of last
rounded corner
addArcWithCenter:radius:startAngle:endAngle:clockwise-- forth rounded
corner, connecting back to first side.
closePath
You can use PaintCodeApp so you don't have to write any of the drawing code. There's a demo download available: http://www.paintcodeapp.com/
You can refer below link to create a polygon shape with rounded corners.
http://www.scriptscoop.net/t/ec0f886dcfea/create-hexagon-imageview-shape-in-ios.html