convex-hull

Orthogonal hull algorithm

会有一股神秘感。 提交于 2019-12-04 20:57:54
I am trying to find a way to determine the rectilinear polygon from a set of integer points (indicated by the red dots in the pictures below). The image below shows what I would like to achieve: 1. I need only the minimal set of points that define the boundary of the rectilinear polygon. Most hull algorithms I can find do not satisfy the orthogonal nature of this problem, such as the gift-wrapping algorithm , which produce the following result (which is not what I want)... 2. How can I get the set of points that defines the boundary shown in image 1. ? Updated: Figure 1. is no longer refereed

Plot convex hull given by quickhull algorithm in R (convhulln function)

馋奶兔 提交于 2019-12-04 19:09:32
I need to plot the convex hull given by quickhull algorithm in R. Here is an example. library(geometry) x1 <- rnorm(100, 0.8, 0.3) y1 <- rnorm(100, 0.8, 0.3) ConVexHull<-convhulln(cbind(x1,y1),"FA") ConVexHull$hull gives a m-by-dimension index matrix of which each row defines a dim-dimensional “triangle”. I know how to plot using chull function but I am not sure if chull gives the same hull as given by convhulln Plot_ConvexHull<-function(xcoord, ycoord, lcolor){ hpts <- chull(x = xcoord, y = ycoord) hpts <- c(hpts, hpts[1]) lines(xcoord[hpts], ycoord[hpts], col = lcolor) } xrange <- range(c(x1

cvConvexityDefects in OpenCV 2.X / C++?

我的未来我决定 提交于 2019-12-04 18:36:46
I'm using OpenCV 2.2 and I need to determine convexity defects of a convex hull. I can't find anything on convexity defects in the documentation which makes me wonder if it is still supported in OpenCV 2.X or if it was renamed? Anyways, I tried using the C function CvSeq* cvConvexityDefects(const CvArr* contour, const CvArr* convexhull, CvMemStorage* storage=NULL ) However, I'm not able to convert my std::vector<Point> hull into CvArr . The CvArr parameters to cvConvexityDefects should be 1-dimensional and continuous array of int's, which I had no success in creating (tried casting, manual

Picture Convex hull in 3D Scatter Plot

筅森魡賤 提交于 2019-12-04 18:13:32
I followed the tutorial about 3D visualization using the package "rgl" here So I was able to draw a 3D Scatter Plot with "iris" data and create an ellipsoid surrounding 95 % of the data points: library("rgl") data(iris) x <- sep.l <- iris$Sepal.Length y <- pet.l <- iris$Petal.Length z <- sep.w <- iris$Sepal.Width plot3d(x, y, z, col="blue", box = FALSE, type ="s", radius = 0.15) ellips <- ellipse3d(cov(cbind(x,y,z)), centre=c(mean(x), mean(y), mean(z)), level = 0.95) plot3d(ellips, col = "blue", alpha = 0.2, add = TRUE, box = FALSE) I know that the first 50 data points belong to a different

How to calculate the convex hull with boost from arrays instead of setting each point separately?

醉酒当歌 提交于 2019-12-04 16:50:21
I am new to boost and "heavy" templating. I have played since days now and tried to pass arrays to the amazing boost::geometry::convex_hull function. Without luck. I prepared the following example: #include <boost/geometry.hpp> #include <boost/geometry/geometries/polygon.hpp> #include <boost/geometry/geometries/adapted/boost_tuple.hpp> #include <boost/geometry/geometries/register/point.hpp> #include <iostream> using namespace std; namespace bg = boost::geometry; BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) int main() { typedef boost::tuple<float, float> point; typedef bg::model:

Triangulate a set of points with a concave domain

半腔热情 提交于 2019-12-04 06:15:44
Setup Given some set of nodes within a convex hull, assume the domain contains one or more concave areas: where blue dots are points, and the black line illustrates the domain. Assume the points are held as a 2D array points of length n , where n is the number of point-pairs. Let us then triangulate the points, using something like the Delaunay method from scipy.spatial: As you can see, one may experience the creation of triangles crossing through the domain. Question What is a good algorithmic approach to removing any triangles that span outside of the domain? Ideally but not necessarily,

D3 drawing a hull around group of circles

冷暖自知 提交于 2019-12-04 04:30:41
I want to draw a hull around a grouped force directed graph build with d3. I have build the graph with the circles. But I now want to join the intersections of the circles with a path(hull). If not joining the intersections, Drawing a hull surrounding the group of circles is enough. I tried the Force-Directed Layout with Convex Hull example. But I have the text and circles covering the text and links connecting the texts. var vertices = new Array(); var width = 960, height = 500; var color = d3.scale.category10(); var r = 6; var force = d3.layout.force().size([width, height]); var svg = d3

how can I check that a point is in a triangle?

混江龙づ霸主 提交于 2019-12-04 02:38:50
问题 Hi also consider that I have 4 points and I will have 4 triangles how can I check these four triangles for each point that is the point within the triangles or not. thanks 回答1: Polygon implements the Shape interface, which provides several contains() methods. Here's a simple example. 回答2: You need to find the equation for the line created by each side of the triangle, and then for each side, check whether the point in question is on the same side of this line as the third point in the

Finding the convex hull of an object in opencv?

懵懂的女人 提交于 2019-12-03 21:48:01
I've written this based on the tutorial here but I'm unable to obtain the convex hull of the image (I'm using a similar hand image as shown in the tutorial). I get the source and edges output fine but the "Drawings" output which should draw the contour and convex hull lines don't show anything drawn and instead is completely black. Any ideas as to why this could be? #include <opencv/cv.h> #include <opencv/highgui.h> #include <opencv/cxcore.h> int main(int argc,char **argv) { cvNamedWindow( "Source", 1 ); cvNamedWindow( "edges window", 1 ); cvNamedWindow( "Drawings", 1 ); IplImage* src =

plot a circle/convex hull arround a given percentage of points

与世无争的帅哥 提交于 2019-12-03 21:27:29
I have x=rnorm(100) y=rnorm(100) plot(x,y) abline(h=0); abline(v=0) From point (0,0) and going outwards I would like to draw a contour/circle/ellipse/freehand convex hull that encloses any given percentage of points. Is there any function or package that can automate this? I have tried the following so far but I can only get a circle with some extrapolation and approximation. I have tried this so far: #calculate radius r<- sqrt(x^2+y^2) df<-data.frame(radius=seq(0,3,0.1), percentage=NA) #get the percentage of points that have a smaller radius than i k<-1 for (i in seq(0,3,0.1)){ df$percentage