algorithm,geometry,distribution,computational-geometry,mathematical-optimization

This is a linear program that can be solved by general LP solvers. It can also be modelled more specifically as a min-cost max-flow problem: Put the attractors on the left side of a bipartite graph and the points on the right side. Connect every attractor i on the left...

algorithm,computational-geometry

I guess you could emulate that "rubber band algorithm" using some sort of optimization algorithms, but it will probably be horribly slow. Keep in mind that in a sense, the physical world is a gigantic, immensely complex computer, all the time figuring out complex stuff such as gravity, magnetic force,...

python,rotation,computational-geometry,angle

It's such a simple thing -- you've got the formula wrong for all of your y-values. It should be: ya_new = sin(theta) * (xa - x) + cos(theta) * (ya - y) + y addition instead of subtraction....

oop,math,3d,language-agnostic,computational-geometry

I'd go for what you call algebraic form. A point (x,y,z) is on a plane (a,b,c,d) if a*x+b*y+c*z+d=0. To intersect that plane with a line spanned by (x1,y1,z1) and (x2,y2,z2), compute s1=a*x1+b*y1+c*z1+d and s2=a*x2+b*y2+c*z2+d. Then your point of intersection is defined by x=(s1*x2-s2*x1)/(s1-s2) y=(s1*y2-s2*y1)/(s1-s2) z=(s1*z2-s2*z1)/(s1-s2) To compute the angle between...

algorithm,computational-geometry

If both points should lie on the circumfence of the circle: find midpoint of [p1, p2]: midpoint := ((a1+a2)/2, (b1+b2)/2)) find line perpendicular to [p1, p2] in midpoint find intersection of this line with x axis this intersection is the midpoint of your circle Edit If both points should be...

ios,objective-c,computational-geometry

I just noticed some errors in this solution I'd mentioned in the comments, but it's generally what you need... I recommend getting the angle between your tap point and your circle's frame's center then implementing a getArea function to get the particular area tapped within your circle, ex: -(void)touchesBegan:(NSSet *)touches...

3d,computational-geometry,mesh

You can try an alternative FreeCAD approach. When the problem are the short edges of the glyphs then you can approximate such a multi-edge wire with a single-edge spline. The resulting solid can be filled at will (ok, still dependent on the font and the sizes etc..) Assuming your exampole,...

You might look in the Mathematics forum for such a program. There is always the dumb approximating solution. For that you need only a decision function whether a point is inside an ellipsoid. Keep a Cube dimension (maybe only once outside the class, the outer dimension) filling: with state: empty,...

opengl,graphics,computational-geometry,mesh

Try this (OPENGLWIDTH, OPENGLHEIGHT and OPENGLDEPTH are #defines). This scales to fill 90% of the screen (1.8 factor): double xScale = 1.0, xOffset, yOffset, zOffset; double range = maxX - minX; if(range > 0.1) { xScale = 1.8 * OPENGLWIDTH / range; } double yScale = 1.0; range = maxY...

algorithm,math,geometry,computational-geometry

The answer is to find the point that forms a triangle with sides lengths: Ra+Rb, Ra+Rc, Rb+Rc. That's known as solving by three sides, but you'll get 2 possible answers. The basic formula to use here is the law of cosines: c^2 = a^2 + b^2 - 2ab*cos(gamma) Let define...

algorithm,computational-geometry

Let's first look at summing the volumes of all cuboids while accounting for overlapping areas only once. You can overlay your space with a new grid that is made up of the start and end points of all cuboids. You then effectively slice all cuboids into sub-cuboids according to that...

algorithm,computational-geometry,intersection

I don't think there's much out of the ordinary you can use here. The calculation of the intersection points is fairly straightforward. With the x direction left to right, and y bottom to top, let's say that we the bottom horizontal line is at y1 and the top at y2,...

math,svg,computational-geometry

Generally, what you need to do is this: moveElement(-centerX, -centerY); rotateElement(angle); moveElement(centerX, centerY); ...

javascript,geometry,computational-geometry,famo.us

Just play with 60 deg === PI/3: http://jsfiddle.net/coma/nk0ms9hb/ var circles = document.querySelectorAll('div.circles > div'); Array.prototype.forEach.call(circles, function (circle, index) { var angle = index * Math.PI / 3; circle.style.top = Math.sin(angle) + 'em'; circle.style.left = Math.cos(angle) + 'em'; }); I'm using ems to ease the calculations like 2 * radius ===...

c#,wpf,computational-geometry,convex,concave-hull

I have implemented this algorithm via JavaScript, may be it will help you. There you can see function that transforms convex hull to concave hull. My implementation of the algorithm is not exactly the same as in the Paper, but it based on it. In my implementation I skipped localMaximumDistance...

c++,algorithm,computational-geometry,convex-hull

If I understand the problem correctly, you can use the following scheme. First, make the copies of your original arrays (call them visible_set_for_sorting and horizon_set_for_sorting). Then sort them. Then form the intersection in the following way: std::set<int> intersection; std::set_intersection( visible_set_for_sorting.begin(), visible_set_for_sorting.end(), horizon_set_for_sorting.begin(), horizon_set_for_sorting.end(), std::inserter(intersection, intersection.begin())); Now you can iterate any...

c++,3d,computational-geometry,spline,sequence-points

interp3() is supposed to do interpolation for volumetric data points (Xi, Yi, Zi, Si), i=1~N. It will generate a function S=f(X, Y, Z). This is the reason why it needs the additional input 's' as noted in your post. When you encounter an interpolation problem/algorithm, the first thing you need...

geometry,computational-geometry,approximation

Thanks to Jongware, the answer was quite obvious. Because I'm dealing with Java, all the sin/cos parameters should be in radians. Fix: double newX = Math.sin(Math.toRadians(theta * i)) * RADIUS + I_OFFSET_X; double newY = Math.cos(Math.toRadians(theta * i)) * RADIUS + I_OFFSET_Y; Works like a charm...

algorithm,computational-geometry

The classic 2-approximation algorithm for this problem, with running time O(nd), is to choose an arbitrary point and then return the maximum distance to another point. The diameter is no smaller than this value and no larger than twice this value.

java,math,geometry,computational-geometry

The line through (Xr, Yr) with slope S has equation D(X, Y):= (Y - Yr) - S (X - Xr) = 0. Just check that D(Xa, Ya) and D(Xb, Yb) have opposite signs....

algorithm,geometry,computational-geometry,bin-packing

here something unsophisticated unoptimal but easy as a start point Based on mine comments exploiting common container size 480px Algorithm: rotate all containers (bins) to get 480 height sort bins by width after rotation descending need ceil(1080/480)=3 lines of 480px bins use the widest bins to fill all the lines...

algorithm,3d,geometry,distance,computational-geometry

Find affine transform M that translates this ellipse in axis-oriented one (translation by -p and rotation to align orientation vector r and proper coordinate axis). Then apply this transform to point p and check that p' lies inside axis-oriented ellipsoid, i.e. x^2/a^2+ y^2/b^2+z^2/c^2 <= 1

A simple approach would be to compute first the convex hull of the points using convhull. It will return the points in a cyclic order (counterclockwise). K = convhull([x1, x2, x3, x4], [y1, y2, y3, y4]) It will return something like that: K = 1 3 4 2 1 Meaning...

ios,objective-c,computational-geometry,cgaffinetransform

Not the most performant solution, but very quick and dirty-ish. NSBezierPath *path = [NSBezierPath bezierPathWithRect:r2]; [path transformUsingAffineTransform:t]; if([path containsPoint:NSMinX(r1)] && [path containsPoint:NSMinY(r1)] && [path containsPoint:NSMaxX(r1)] && [path containsPoint:(NSMaxY(r1)] ){ self.validTransform = transform; } ...

sql,database,cluster-analysis,geospatial,computational-geometry

You can try a voronoi diagram. A voronoi diagram is the dual of a delaunay triangulation with some useful properties: https://alastaira.wordpress.com/2011/04/25/nearest-neighbours-voronoi-diagrams-and-finding-your-nearest-sql-server-usergroup.

algorithm,geometry,computational-geometry,mesh,3d-model

If a 3D object is "simple", meaning that it doesn't have holes, it satisfies Euler's Formula for Polyhedra, V - E + F = 2 where V is the number of vertices in the figure, E is the number of edges, and F is the number of faces. If you...

algorithm,opencv,computer-vision,computational-geometry,3d-reconstruction

I'm not sure if this helps, but I quickly converted both images to 1-D functions by finding the index of the maximum value in each line (blue and red). On the same figure I show the derivatives (cyan and green). At least it seems your points could perhaps be found...

geometry,raphael,computational-geometry,geometry-surface

So... the trouble is to tell the inside from the outside. You need the following functions: function sub(a, b) { return { x: a.x - b.x , y: a.y - b.y }; } function neg(a) { return { x: -a.x , y: -a.y }; } function cross_prod(a, b) { //...

c++,computational-geometry,intersection,rectangles

You don't care where the rectangles are vertically. You can project everything onto the x-axis and then solve the corresponding 1-dimensional problem: you have a set of intervals and you want to know which overlap with a given interval. This is exactly what an interval tree is does: https://en.wikipedia.org/wiki/Interval_tree...

c++,algorithm,computational-geometry,mesh

There are two main conditions for an edge collapse: Connectivity On each side of the collapsed edge, only one pair of edges must be merged. This can be checked by counting the joint neighbour vertices of the two merging vertices (there must be exactly two). Consider the following example where...

python,algorithm,runtime-error,circle,computational-geometry

Without understanding anything about your algorithm, I noticed one thing: the ratio between your coordinates and your radius is very large, about 2e5. Maybe, your algorithm is ill conditioned when trying to find a circle around points which are so far away from the origin. Especially in your _make_circumcircle function,...

c++,algorithm,computational-geometry,boundary,point-in-polygon

From the website documentation: "PNPOLY partitions the plane into points inside the polygon and points outside the polygon. Points that are on the boundary are classified as either inside or outside. ..." Please read the documentation available on the site again.It answers your question. In the end, you will probably...

performance,algorithm,computational-geometry,point,convex-hull

Looks like you can. Sort vertices in a[] by polar angle relative to one of vertices (call it A). O(N log N), like convex hull computation. Read point, determine its polar angle. O(1) Find two neighbor vertices, one of them should have polar angle less than point from step 2,...

algorithm,binary-search-tree,computational-geometry,intervals,angle

The circularity of angles is not a major obstacle: to instead an interval like [270, 45) that wraps around, instead insert two intervals [270, 360), [0, 45). To implement insertion without wraparound, we can use a binary search tree. This tree tracks the uncovered intervals by mapping each endpoint of...

c++,computational-geometry,intervals,skip-lists

Suggest using CGAL range trees: Wikipedia says interval trees (1-dimensional range trees) can "efficiently find all intervals that overlap with any given interval or point"....

java,user-interface,graphics,awt,computational-geometry

You can create a Line2D object for your original line. Then you can use AffineTransform#getRotateInstance to obtain an AffineTransform that does the rotation about a certain angle, around a certain point. Using this AffineTransform, you can create a rotated Line2D object to paint. So your painting code could roughly look...

graphics,statistics,computational-geometry

Let's do this for X coordinate only: 1) sort the X coordinates 2) look at deltas between two subsequent X coordinates. These delta will fall into two categories - either they correspond to spaces between two columns, or to spaces between crosses within the same column. Your goal is to...

algorithm,polygon,computational-geometry,spline

It can be done by recursively refining part which is not near segment between part ends. If we have curve (spline) C:[0,1]->R^n. Than first approximation is segment S between curve end points [C(0), C(1)]. Take point C(0.5) and check how far is it from segment S. If it is far...

algorithm,computational-geometry,approximation,g-code

You can obtain curvature radius center for any 2 line segments like this: find the lines midpoints cast perpendicular lines from each (red lines) find the intersection (it is the center of the curvature) in 3D use plane of the object (3 lines not 2) the radius is just...

computational-geometry,line-segment,geometry-class-library

How would you do that with a pencil...? Find the leftmost vertex (minimum x). If there's more than one, choose the lowest of them (minimum y). There is no vertex below the current one, so take the direction 'downwards' as a reference. Find all edges going from the current vertex...

algorithm,computational-geometry

The work you want to do falls into the category of "curve fitting". There are tons of different algorithms for curve fitting but almost all curve fitting algorithms can be divided into two different categories: interpolation and approximation. Interpolation algorithms produce a curve that passes through all the data points...

algorithm,computational-geometry,convex-hull

Here's an O(log h)-time algorithm that, given a convex hull with h vertices in sorted order and a query point, tests whether the query point lies on the hull. From the hull, compute a point in the interior by averaging three of its vertices. Call this point the origin. Partition...

Here is perhaps an easier method. First suppose that your plane is not parallel to the z-axis. Then project the polygon down to the xy-plane simply by removing the 3rd coordinate. Now compute the area A' in the xy-plane by the usual techniques. If your plane makes an angle θ...

algorithm,geometry,computational-geometry

Each run(one run is executing all commands of the given string once) changes two things: the direction which the robot looks to and its position(that is, each run shifts it by some vector(the direction of this vector depends on the its initial direction before the run) and rotates it)....

matlab,geometry,computational-geometry,delaunay,voronoi

Looking at your files, you have a set of points P in R^3 and a (2-manifold) surface triangulation T of your geometry: This can easily be turned into a surface voronoi complex V by noting that the voronoi complex is dual to the underlying triangulation T. This means the following:...

c++,opengl,computational-geometry,glm

I think your main issue is actually the z coordinate. When you consider a point on the screen, this will not just specify a point in object space, but a straight line. When you use a persepctive projection, you can draw a line from the eye position to any object...

matlab,computational-geometry,intersection

Use the parametric equation of the line segment, P = (1-t) A + t B, with 0<=t<=1. Find the intersections between the polygon edges and the line of support of the segment, expressing the position of the intersection in terms of t (momentarily ignore the constraint on t). You will...

c++,graphics,3d,geometry,computational-geometry

You got t=5 and got (0,7,-1) but the correct number for t is 1 and the reason is you have float t = (dotProduct(N, orig) + d) / NdotRayDirection; while the correct code is float t = -((dotProduct(N, orig) - d) / NdotRayDirection); This would solve your problem hopefully.

performance,algorithm,computational-geometry

For one polyhedron (cuboid) to be completely inside or completely outside other polyhedron, there should be no intersections between there faces. Check if any polyhedron face intersect any cuboid face. If there is intersection than cuboid is partially inside. If there is no intersection, check one cuboid corner point is...

javascript,geometry,computational-geometry,bezier,adobe-illustrator

Check, if all the control points of the curve are inside the ellipse. If so, your curve lies completely within the ellipse too.

opengl,3d,geometry,computational-geometry,frustum

Solved it by multiplying the projected coordinates of the frustum corners e.g. (1, 0, -1) with the inverse MVP matrix.

c++,performance,computational-geometry

Memory allocation can be slow - don't do it unless you need to - and do as little of it as possible: Your cubes contain a heap of information that could be computed at run time, and is almost the same from Cube to cube. I'm assuming that there is...

algorithm,geometry,theory,computational-geometry

To be honest, I haven't done too much with dynamic trees myself (mostly static). But I believe the Bkd-tree paper (early 2000s?) is good source to start. I believe it has been referenced many times since then. You can use sources like acm/citeseer to track newer papers that reference it....

matlab,math,geometry,computational-geometry

I will restate the problem with my own notation: Given two points P and Q on the surface of a sphere centered at C with radius r, find a new point T such that the angle of the turn from PQ to QT is A and the length of QT...

If you have the Mapping Toolbox installed, you could use polyxpoly. As this is a rather basic problem, there are quite a few free MATLAB-codes out there on the File Exchange. Here is what I found for the search term 'polygon intersect': 2D Polygon edges intersection by Bruno Luong Find...

algorithm,computational-geometry

The Problem here is NP-complete. What you try to solve is the max-clique problem combined with a set cover problem. Your problem can be represented as a Graph G=(V,E), where the vertices are your coordinates and the edges the connections in distances. This graph can be made in O(n^2) time....

algorithm,computational-geometry

Here is an O(n * log m) solution: Let's check if any two polygons really intersect(not when one is contained within another). In this case, we can use standard algorithm to check if there is pair of intersecting segments in an arbitrary set of segments. There is a well-known O(n...

java,algorithm,data-structures,hashtable,computational-geometry

The line double slope = (A.y-B.y)/(A.x-B.x); is wrong. This does int division, and then converts the result to a double. You want double slope = (A.y-B.y)/(double)(A.x-B.x); ...

polygon,computational-geometry,concave

ARRAY points := {P1, P2, ..., PN}; points.delete(middle vertices of any collinear sequence of three points); REAL p_a := index of vertex with minimum y-coordinate; REAL p_b := index of vertex with maximum y-coordinate; REAL rotated_angle := 0; REAL min_width := INFINITY; VECTOR caliper_a(1,0); // Caliper A points along...

numpy,computational-geometry,sparse-matrix,kdtree,sparse-array

Following up on Yves' suggestion, here's an answer, which uses scipy's KDTree: from scipy.spatial.kdtree import KDTree import numpy as np def locally_extreme_points(coords, data, neighbourhood, lookfor = 'max', p_norm = 2.): ''' Find local maxima of points in a pointcloud. Ties result in both points passing through the filter. Not to...

algorithm,computational-geometry,intersection,intervals

The idea to assign values is correct. You just need to sort intervals by their minumum value(in increasing order). That is, the solution looks like this: Build a segment tree(with -infinity values in all nodes). Process all intervals in sorted order. For each interval, just assign its value(no matter what...

svg,computational-geometry,curve-fitting,catmull-rom-curve

To answer your questions directly: Yes. Catmull-Rom spline is an algorithm to interpolate a series of (x, y, z) points. It will generate a cubic polynomial curve between each two consecutive points. You cannot direcly use Catmull Rom spline for SVG path. You need to convert it to cubic Bezier...

3d,2d,webgl,coordinates,computational-geometry

If i understand your problem correctly, what you need to do is: Convert your points into 3D points: A(2,2,0), B(4,2,0), C(4,6,0), D(2,0,0) Get "duplicate" points with a height: E(2,2,1), F(4,2,1), G(4,6,1), H(2,0,1) Create triangles from those points: (there might be mistakes in this example) Front side: E EF AB B...

java,3d,computational-geometry

Here's how I would do it. I would define a Point3f[][] points = new Point3f[(int)((umax-umin)/du)][(int)((vmax-vmin)/dv)]; Then use loops similar to the ones you have int i = 0; i<points.length; i++, int j = 0; j < points[0].length; j++. Define u = i * du + umin, v = j *...

sql,position,geometry,computational-geometry

Check is polar coordinates (r, phi) of point (x, y) - (position_x, position_y) in ([0,pie_radius], [direction_angle - pie_angle/2, direction_angle + pie_angle/2]). px = x - position_x py = y - position_y r = sqrt( px^2 + py^2 ) phi = atan2(py/px) Point is in if: r <= pie_radius direction_angle -...

algorithm,computational-geometry

If you consider pushing the optimal separating line you will always be able to push it until it hits a point, and then rotate it until it hits another point. The score for this adjusted line will be the same as the original score, so you only need to consider...

math,geometry,computational-geometry

What you have here is a 2d bilinear blended surface. For simplicity, let's change its coordinates to range from zero to one: u = 0.5 * (ξ + 1) v = 0.5 * (η + 1) In that case, the surface evaluator can be expressed as F(u, v) = P1...

algorithm,computational-geometry

The paper "Searching for empty Convex polygons" by Dobkin, David P. / Edelsbrunner, Herbert / Overmars, Mark H. contains an algorithm linear in the number of possible output triangles for solving this problem. A key problem in computational geometry is the identification of subsets of a point set having particular...

In outline: all pairs of points closer than 6000m form a graph in the form of grid squares. Construct that graph, and then find all subgraphs isomorphic to a square (a loop of size 4). The external edges will appear less often than internal edges since they are only part...

c++,algorithm,computational-geometry

It does work correctly(because the points are deleted from the set only when they can be safely deleted). However, it has O(n ^ 2) time complexity, because the points are not always deleted when they should be. This simple generator(written in python3): from sys import argv n = int(argv[1]) dy...

matlab,vector,3d,computational-geometry,angle

It's a simple use of the cross-product and scalar-product: You first find a normal vector N of the plane spanned by those points. This is done via the cross product of B-A and O-A. Then the directional vector AP can be found as the cross product of N and B-A....

c,computational-geometry,tetrahedra

USING TRIGONOMETRY Compute the lengths of the altitudes HA and HD in their respective face from the sides. Compute the angle AHD by the cosine formula. USING ANALYTICAL GEOMETRY Project A orthogonally onto BC to get H: BH = ((AB.BC)/BC²).BC (bold are vectors) Compute the angle from cos AHD =...

python,numpy,vectorization,computational-geometry

What am I doing wrong with the vectorized distance calculation? distances = numpy.linalg.norm(np_cell[1] - srcPos) vs distances = numpy.linalg.norm(np_cell[1] - srcPos, ord=1, axis=1) Firstly, if axis=None, np.linalg.norm will compute either the vector norm (if the input is 1D) or the matrix norm (if the input is multidimensional). Both of...

python,3d,scipy,computational-geometry

You may consider SLERP - spherical linear interpolation P = P0*Sin(Omega*(1-t))/Sin(Omega) + P1*Sin(Omega * t)/Sin(Omega) where Omega is central angle between start and end points (arc of great circle), t is parameter in range [0..1], for i-th point t(i) = i/N...

data-structures,graphics,3d,computational-geometry

Hope you are writing about solid materials ... you need to know the math/physics background behind this. you will need to know the integral and vector math Google for mechanics of materials something like this ... first hit in my language sorry I am not confident to do the search...

java,lwjgl,computational-geometry,slick2d

The answer here is going to wind up being mostly a question of math. I briefly go over the math/physics involved and trust that you should be able to implement the math/physics in code yourself. How projectiles are supposed to bounce off of walls In classical physics, or at least...

algorithm,cluster-analysis,computational-geometry,hamming-distance

One of the previously asked questions has some good discussions, so you can refer to that, Nearest neighbors in high-dimensional data? Other than this, you can also look at, http://web.cs.swarthmore.edu/~adanner/cs97/s08/papers/dahl_wootters.pdf Few papers which analyze different approaches, http://www.jmlr.org/papers/volume11/radovanovic10a/radovanovic10a.pdf https://www.cse.ust.hk/~yike/sigmod09-lsb.pdf...

algorithm,computational-geometry,line-intersection,convex-polygon

Be careful not to neglect the case where Q entirely covers R, or vice versa, as the edge test then would give a false negative. One approach, conceptually: Regard R as the intersection of two axis-aligned infinite bands, a vertical band [x0,x1] and a horizontal band [y0,y1]. Let xmin and...

geometry,computational-geometry

Let's assume you have some geometry primitives, such as vector subtraction and vector lengths. Then, you can compute Q2 as follows (in pseudo-code): r = 3 v = C.minus(B) w = B.minus(A) u = v.scaleBy(length(w)) + w.scaleBy(length(v)) Q2 = B.plus(u.scaleBy(r / length(u)) Here, v.scaleBy(5) returns a vector that has the...

algorithm,d3.js,geometry,computational-geometry,delaunay

Create a graph in which the nodes correspond to Delaunay triangles and in which there is a graph edge between two triangles if and only if they share two vertices. Compute the connected components of the graph. For each connected component, find all of the nodes that have less...

python,computational-geometry,convex-hull,convex-polygon

In this answer, I will assume you have already used PCA to near-losslessly compress the data to 4-dimensional data, where the reduced data lies in a 4-dimensional polytope with conceptually few faces. I will describe an approach to solve for the faces of this polytope, which will in turn give...