computational-geometry

Pixels between 2 intersecting lines

老子叫甜甜 提交于 2019-12-23 15:29:47
问题 I need to find pixel values that are between the intersection of 2 lines. The following image shows the points that I want namely the brown region. These 4 co-ordinates can change and are not necessarily the corner points. What is the fastest way to get the pixel values ? Is there any function that can give me the necessary mask. 回答1: You should calculate for each point, whether it is above the line or below. If the line is given in its equation form Ax+By+C , then it is as simple as

Quaternion and three axes

旧城冷巷雨未停 提交于 2019-12-23 13:08:35
问题 Given a quaternion q, and three 3D vectors (vx, vy, vz) which form coordinate axes, which can be oriented in arbitrary direction, but are all perpendicular to each other, thus forming a 3d space. How can I check if the quaternion q is rotated to the same direction (or opposite direction) as some of the 3D vectors (vx, vy, vz)? 回答1: If q = (w,x,y,z), where w is the "scalar part", and qv=(x,y,z) is the "vector part", then you can calculate the angle between qv and each of the basis vectors vx,

Complexity of the QuickHull Algorithm?

心已入冬 提交于 2019-12-23 08:27:00
问题 I know the complexity is O(nlog(n)). But why? How do you come to this answer? Any help would be much appreciated, I'm very interested to know! 回答1: Its average case complexity is considered to be O(n log(n)) , whereas in the worst case it takes O(n^2) (quadratic). Consider the following pseudo-code: QuickHull (S, l, r) if S={ } then return () else if S={l, r} then return (l, r) // a single convex hull edge else z = index of a point that is furthest (max distance) from xy. Let A be the set

Determine whether a point lies in a convex hull in O(log n) time [duplicate]

喜你入骨 提交于 2019-12-23 07:05:22
问题 This question already has answers here : Test point for its position relative to the convex hull in log(n) (6 answers) Closed 4 years ago . I've researched several algorithms for determining whether a point lies in a convex hull, but I can't seem to find any algorithm which can do the trick in O(logn) time, nor can I come up with one myself.Let a[] be an array containing the vertices of the convex hull, can I pre-process this array in anyway, to make it possible to check if a new point lies

Implementing Bowyer-Watson algorithm for delaunay triangulation

耗尽温柔 提交于 2019-12-23 04:39:29
问题 I am trying to implement the following Bowyer-Watson algorithm to implement Delaunay Triangulation. function BowyerWatson (pointList) // pointList is a set of coordinates defining the points to be triangulated triangulation := empty triangle mesh data structure add super-triangle to triangulation // must be large enough to completely contain all the points in pointList for each point in pointList do // add all the points one at a time to the triangulation badTriangles := empty set for each

Calculate the minimum distance between two given circular arcs

时光怂恿深爱的人放手 提交于 2019-12-23 02:46:33
问题 I'm trying to find a way to calculate the minimum distance between two given circular arcs. I found a solution in this link. It seems true but I don't know why that is correct!Can anyone prove it right? 回答1: The solution you refer to works because it is based on the properties of arks: An arc is a part of the circle Minimum distance is always reached either at the endpoints or at the perpendicular because it minimizes the distance (objective function). Think of two circles - minimal is always

Set up linear programming code in Matlab to obtain vertices in 4D or higher dimensions

戏子无情 提交于 2019-12-22 18:07:04
问题 Suppose I have a point cloud given in 4D space, which can be set up arbitrarily dense. These points will lie on the surface of a polytope, which is an unknown object at this point. (Just to provide some unhelpful visualization, here is a rather arbitrary projection of the point cloud which I have given - i.e. plotting the first 3 columns of the 100000x4 array): My goal is to obtain the vertices of this polytope, and one of my numerous attempts to get those was computing the convex hull of the

Python how calculate a polygon perimeter using an osgeo.ogr.Geometry object

狂风中的少年 提交于 2019-12-22 10:58:53
问题 First of all, I apologize to post this easy question. I need to compute a certain number of gemotrical attributes (area, perimeters, Roundess, major and minor axis, etc). I am using GDAL/OGR to read a shapefile format of my polygon. What i wish to ask is: is there a method to compute the perimeter using osgeo.ogr.Geometry? is there a module build to compute metrics on polygon? thanks in advance import osgeo.gdal, ogr poly="C:\\\myshape.shp" shp = osgeo.ogr.Open(poly) layer = shp.GetLayer() #

Least distance from a point to an area

为君一笑 提交于 2019-12-22 09:38:59
问题 I am trying to find a point (P2) in a closed area that has the minimum distance to a point (P1). The area is built of homogenous pixels, it is not shaped perfectly and it is not necessarily convex. This is basically a problem of reaching an area from the shortest path. The whole space is a stored in the form of a bitmap in the memory. What is the best method to find P2? Should I go with random search (optimization) methods? Optimization methods do not give the exact minimum but they are

Find coordinates inside a rectangular area constructed by lat/long GPS pairs

跟風遠走 提交于 2019-12-22 01:48:18
问题 I've never deal much with location-based data, so very much new to the whole GPS coding related questions. I have a problem that I don't seem to find a very efficient way in solving it or maybe there's an algorithm that I'm not too sure. Let said you have given 4 lat/long coordinates which construct some kind of a rectangular area: (X0, Y0), (X1, Y0), (X0, Y1), (X1, Y1) ----------------------------------- | b | | a | | | d | | | c | ----------------------------------- e Is there a way to find