computational-geometry

random unit vector in multi-dimensional space

左心房为你撑大大i 提交于 2019-12-28 05:59:27
问题 I'm working on a data mining algorithm where i want to pick a random direction from a particular point in the feature space. If I pick a random number for each of the n dimensions from [-1,1] and then normalize the vector to a length of 1 will I get an even distribution across all possible directions? I'm speaking only theoretically here since computer generated random numbers are not actually random. 回答1: One simple trick is to select each dimension from a gaussian distribution, then

Calculating normals in a triangle mesh

£可爱£侵袭症+ 提交于 2019-12-27 11:00:17
问题 I have drawn a triangle mesh with 10000 vertices(100x100) and it will be a grass ground. I used gldrawelements() for it. I have looked all day and still can't understand how to calculate the normals for this. Does each vertex have its own normals or does each triangle have its own normals? Can someone point me in the right direction on how to edit my code to incorporate normals? struct vertices { GLfloat x; GLfloat y; GLfloat z; }vertices[10000]; GLuint indices[60000]; /* 99..9999 98..9998 ..

Removing outliers from convex hull [closed]

冷暖自知 提交于 2019-12-25 17:05:57
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 months ago . I have a few datasets that I'd like to visualise with convex hull (and derive some statistics from that convex hull). However, each dataset contains some noise. Therefore, convex hull covers not only points in the main data cloud, but also all the outliers making the area of convex hull pretty large and not

Shear transformation which doesn't change the order in x-direction

我与影子孤独终老i 提交于 2019-12-25 10:26:54
问题 Given a set of points with unequal x-coordinates, I want to calculate the value v > 0 such that the shear transformation (x, y) -> (x + v*y, y) doesn't change the order in the x-direction. 回答1: This isn't difficult. Order the points by their x-axis. Because of the continuity of the shear transformation, it's enough for you to find a maximum v that two consecutive points (in x-order) do not change order. Let (x,y) and (x',y') be two consecutive points in your ordering. with v>0, the x

Shear transformation which doesn't change the order in x-direction

偶尔善良 提交于 2019-12-25 10:26:13
问题 Given a set of points with unequal x-coordinates, I want to calculate the value v > 0 such that the shear transformation (x, y) -> (x + v*y, y) doesn't change the order in the x-direction. 回答1: This isn't difficult. Order the points by their x-axis. Because of the continuity of the shear transformation, it's enough for you to find a maximum v that two consecutive points (in x-order) do not change order. Let (x,y) and (x',y') be two consecutive points in your ordering. with v>0, the x

Approximate position on circle for n points

为君一笑 提交于 2019-12-25 05:33:51
问题 I am struggling with the following problem: I am given n points and a radius and I have to place them on a circle as symmetrical as possible. Currently, I used something like this: float theta = 360.0f / n; int i = 0; for (Word w : e.getValue()) { double newX = Math.sin(theta * i) * RADIUS + I_OFFSET_X; double newY = Math.cos(theta * i) * RADIUS + I_OFFSET_Y; mxCell v2 = (mxCell) graph.insertVertex(parent, null, w.getValue(), newX, newY, OW_WIDTH, OW_HEIGHT,"shape=ellipse"); graph.insertEdge

simplify combinatorial map using CGAL

大兔子大兔子 提交于 2019-12-25 03:02:29
问题 I want to simplify or edge collapse a mesh read from .off file as a combinatorial map using CGAL std::ifstream ifile(fileName.toStdString().c_str()); if (ifile) { CGAL::load_off(lcc, ifile); lcc.display_characteristics(std::cout)<<", is_valid="<<CGAL::is_valid(lcc)<<std::endl; } namespace SMS = CGAL::Surface_mesh_simplification ; SMS::Count_stop_predicate<LCC> stop(lcc.number_of_halfedges()/2 - 1); int r = SMS::edge_collapse (lcc ,stop ,CGAL::parameters::halfedge_index_map(get(CGAL::halfedge

Find x and y coordinates where a perpendicular point crosses a straight line [closed]

不打扰是莪最后的温柔 提交于 2019-12-25 01:25:33
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 9 months ago . This is a follow-up question to this question. Taking the following image as an example: What I know: x and y coordinates of points D , E , and P . Therefore, I also know slope and intercept of D-E line What I want to know: x and y coordinates of point Q . (This is the point which crosses the D-E line). 回答1:

Remove self-intersections in Meshlab or vcglib

房东的猫 提交于 2019-12-25 01:24:57
问题 How to remove self-intersection of a mesh with the Meshlab application or vcglib? 回答1: This is out of the scope but there are some functions in CGAL. This is still experimental and not documented but you can use the function remove_self_intersection(). Depending on the type of self-intersections, you can also use the (also experimental) function autorefine_and_remove_self_intersections(). The first function is more likely to be used when you want to remove self-intersection due to loss of

Maintain a list of points around a center point, preserving CCW order

和自甴很熟 提交于 2019-12-24 20:18:53
问题 I have the following class: public class Vertex() { private double xCoord; private double yCoord; private ArrayList<Vertex> neighborList(); } And I want to support adding/removing vertices to the neighborList such that the points are listed in CCW order around this vertex (which point is first in the list doesn't matter). If points are collinear, nearer points to this should be first. I've tried several methods but so far have always been able to find a counter example that doesn't work for