Suppose we have a polygon with coordinates ((x1, y1,z1), (x2,y2,z2), (x3,y3, z3), ...) and a point with coordinates (x0, y0,z0)
Is there any numerical method to calculate solid angle of polygon about the point? Are there any modules in python to calculate it?
I saw this question: How to calculate a solid angle defined by a point and a polygon? but it seems to be about a polygon of 4 points.
Related
I need an algorithm to quickly determine wether given 2D polygon arbitrarily translated intersects given rounded rectangle.
We're given a polygon with N vertices and dimensions of the rounded rectangle (lenghts of sides and radius of corners).
We would like to answer many question of type does the polygon with translation (dx,dy) intersect the rounded rectangle.
We're allowed to do arbitrary precomputation on the polygon.
When radius of the corners rectangle is 0, there is trivial constant time algorithm - it's enough to compute an AABB of the polygon, and then in few comparisons check if, after translation, it intersects the rectangle.
When the radius is >0 the problem seems much harder. The fact that there seems to be potentially an infinite number of "bounding rounded rectangles" suggests that there is no constant-time algorithm that can check for the intersection.
But maybe I'm missing something.
Do you know by any change any sublinear algorithm for checking if a polygon intersects a rounded rectangle?
If preprocessing of the polygon is allowed, an efficient solution is possible:
build the Minkowski sum of the polygon and rounded rectangle; this is a curvilinear polygon;
every translation of the polygon wrt the rectangle corresponds to a point wrt the Minkowski sum;
decompose the curvilinear polygon in slabs;
you can perform location of an arbitrary point in that decomposition in time O(log(N)), and this is optimal.
Below, the sum of two polygons and of a concave polygon with a disk (the loop must be excluded). This generalizes to a rounded rectangle.
To locate a point, you identify the containing slab by dichotomic search. Then inside a slab, you can identify the containing curvilinear trapezoid (delimited by line segments or circular arcs) by a second dichotomic search.
If you have few polygons, with a simple shape, you can do the preprocessing by hand. Otherwise, the Minkowski sum and slab decomposition are a little painful.
Let x1, x2, y1, y2 be the coordinates of the AABB of the rounded rectangle, with x1 < x2 and y1 < y2, and let R be the radius (of the quarter-circles).
Here is how I would handle the collision detection. Optionally, you can of course check for collision with the AABBs of both objects first, to reject early. Then, for each line in the polygon:
check for intersection with the rectangle made from the following points:
(x1, y1+R), (x1, y2-R), (x2, y1+R), (x2, y2-R)
check for intersection with the rectangle made from the following points:
(x1+R, y1), (x1+R, y2), (x2-R, y1), (x2-R, y2)
check for intersection with each of the circles in the corners, that is the circles or radius R and centers:
(x1+R, y1+R), (x1+R, y2-R), (x2-R, y1+R), (x2-R, y2-R)
If any of these three checks gives an intersection, then the polygon intersects the rounded rectangle or is completely inside. Of course, you can check whether a point of the polygon is outside the rounded rectangle using the same method (you can easily do it at the same time as the intersection checks). Because a rounded rectangle is a convex shape, this is sufficient to say that the polygon is not completely inside.
That's O(N) where N is the number of sides of your polygon. If that's the complexity you are thinking of when you say "constant-time", then I don't believe there is any kind of preprocessing that can help go below O(N) in the general case.
I have a polygon that contains latitude and longitude as:
polygon= [[latitude1, longitude1], [[latitude2, longitude2]]....[latitudeN, longitudeN]]
The result of the shape is a circle, I want to calculate the distance from a point to the polygon.
I know how to find the distance from one point to another, so I can iterate over all points in the polygon and find distance against my point to find minimum distance but is there another way?
Edit-1: I have some satellites footprints over a map, those footprints are presented as a polygons. I have some other points (locations) and I want to see which satellite is closer to each point and calculate the distance to that satellite
In the case that the polygon indeed describes a circle, you could save the polygon as a center location (x,y) coordinate and the radius of the circle. The distane of a point to the polygon can be computed as the distance from the center of the circle to the wanted point, and then reduce the raidus size. As a bonus, if the resulted distance is negative, your point is inside the circle.
I have a convex polygon in Oxy plane (defined by some vertices and edges). I would like to create a 3D polyhedron from extruding this polygon in z axis for some distance h. How can I do this in bullet physics?
Thank you for your time.
The extrusion is simple to do by hand. For each vertex in the polygon you duplicate it, and set the Z value to the distance h. Then you can create a btConvexHullShape from the points in the set. Since it's a convex hull and not a triangle mesh you don't need to worry about the face information. If you look at the btConvexHullShape constructor you'll notice it only takes a list of points as the parameter.
Some fast algorithms for working with polygons require the vertices of the polygon to have a specific order (clockwise or counter clockwise with respect to the polygon's plane normal).
To use those algorithms in 3D planar polygons (where all the points lie in a particular plane) one can perform a change of basis to a basis spanned by two orthogonal vectors that lie in the plane and a plane normal vector.
Is there a way to always find a basis in which the polygon vertices are always in counter clockwise (or clockwise) order?
Perhaps the best method is to compute the signed area of the polygon, and if it is negative, you know your vertices are clockwise; so reverse. If it is positive, your vertices are counterclockwise.
Search for "signed area of polygon." Here is one Mathematica link:
I am trying to transform quadrilateral to rectangular plane And need to extract coordinate of 1 specific point (in quadrilateral plane), to that in respect to rectangular plane..
I'm using EmguCV for image processing purpose in my .NET project
What I've tried is:
1) Calculate Homography matrix between quadrilateral and rectangular plane (specifying points in clockwise order from left top corner for both planes)
2) Multiply above Homography matrix by 3 x 1 matrix [x,y,1] to get final coordinates.
However, the resultant coordinate (x', y') does not seem in concordance with given point (x,y).
As Micka suggested, after having resultant matrix (3x1), all that is needed to solve this problem was this: p' = (x'/z', y'/z')
Steps as below:
Calculate Homography matrix between quadrilateral and rectangular plane
Multiply this homography mat. with candidate point [x,y,1]T and get [x',y',z']T
Now, Dehomogenize above [x',y',z']T i.e. [(x'/z'), (y'/z'), 1]T
thus, the required final coordinate of rectangular plane.