computational-geometry

Greiner-Hormann clipping with degeneracies

折月煮酒 提交于 2019-12-22 01:19:38
问题 I'm trying to understand the paper "Clipping of Arbitrary Polygons with Degeneracies" by E. L Foster and J. R. Overfelt [1], which claims to extend the classic Greiner-Hormann polygon clipping algorithm by handling of degeneracies. However, I ran into some difficulties with the procedure they describe. Consider the situation depicted on Figure 6(c) and suppose the polygons are oriented in the same way. Start the labeling phase from the I5 (as opposed from I1, as they do): for both subject

Finding the most frequent number from a set of ranges -

删除回忆录丶 提交于 2019-12-21 20:48:00
问题 The question is as follows:- You are given the life time of N different elephants, represented as a pair of integers. ex. [5,10] [6,15] [2,7] means, one elephant lived from Year 5 to Year 10. The second lived from Year 6 to Year 15 and so on.. You may assume that an elephant can only live a maximum of M years. (Not a part of the question, but we may need it to represent algorithmic complexity.) Given this data, find the year in which the maximum number of elephants lived . Resolve ties

Point within circle

做~自己de王妃 提交于 2019-12-21 20:25:10
问题 Given the center point and radius of a circle, how do I know if a certain point (x,y) is in the circle? Anyone knows it? Thanks. 回答1: Originally you asked for Objective-C. CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) { CGFloat dx = point2.x - point1.x; CGFloat dy = point2.y - point1.y; return sqrt(dx*dx + dy*dy ); }; -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { CGPoint point = [[touches anyObject] locationInView:self]; CGFloat distance =

Better “centerpoint” than centroid

最后都变了- 提交于 2019-12-21 09:10:12
问题 I'm using the centroid of polygons to attach a marker in a map application. This works definitely fine for convex polygons and quite good for many concave polygons. However, some polygons (banana, donut) obviously don't produce the desired result: The centroid is in these cases outside the polygons area. Does anybody know a better approach to find a suitable point within any polygons area (which may contain holes!) to attach a marker? 回答1: One approach would be to generate and refine a

Smallest enclosing circle in Python, error in the code

一笑奈何 提交于 2019-12-21 07:13:58
问题 I have a set of points that represent the vertices (x, y) of a polygon. points= [(421640.3639270504, 4596366.353552659), (421635.79361391126, 4596369.054192241), (421632.6774913164, 4596371.131607305), (421629.14588570886, 4596374.870954419), (421625.6142801013, 4596377.779335507), (421624.99105558236, 4596382.14190714), (421630.1845932406, 4596388.062540068), (421633.3007158355, 4596388.270281575), (421637.87102897465, 4596391.8018871825), (421642.4413421138, 4596394.918009778), (421646

Insert a circle into geometry data type

折月煮酒 提交于 2019-12-21 06:34:50
问题 I'm about to start using geometry or geography data types for the first time now that we have a development baseline of 2008R2 (!) I'm struggling to find how to store the representation for a circle. We currently have the lat and long of the centre of the circle along with the radius, something like :- [Lat] [float] NOT NULL, [Long] [float] NOT NULL, [Radius] [decimal](9, 4) NOT NULL, Does anyone know the equivalent way to store this using the STGeomFromText method, ie which Well-Known Text

Insert a circle into geometry data type

你离开我真会死。 提交于 2019-12-21 06:30:18
问题 I'm about to start using geometry or geography data types for the first time now that we have a development baseline of 2008R2 (!) I'm struggling to find how to store the representation for a circle. We currently have the lat and long of the centre of the circle along with the radius, something like :- [Lat] [float] NOT NULL, [Long] [float] NOT NULL, [Radius] [decimal](9, 4) NOT NULL, Does anyone know the equivalent way to store this using the STGeomFromText method, ie which Well-Known Text

area of intersection of two triangles, or a set of halfplanes, or area of a convex point set

柔情痞子 提交于 2019-12-21 05:41:41
问题 I need to compute the area of the region of overlap between two triangles in the 2D plane. Oddly, I have written up code for the triangle-circle problem, and that works quite well and robustly, but I have trouble with the triangle-triangle problem. I already first check to see if one entirely contains the other, or if the other contains the first, as well as obtain all the edge-wise intersection points. These intersection points (up to 6, as in the star of David), combined with the triangle

area of intersection of two triangles, or a set of halfplanes, or area of a convex point set

一曲冷凌霜 提交于 2019-12-21 05:41:06
问题 I need to compute the area of the region of overlap between two triangles in the 2D plane. Oddly, I have written up code for the triangle-circle problem, and that works quite well and robustly, but I have trouble with the triangle-triangle problem. I already first check to see if one entirely contains the other, or if the other contains the first, as well as obtain all the edge-wise intersection points. These intersection points (up to 6, as in the star of David), combined with the triangle

Computing face normals and winding

放肆的年华 提交于 2019-12-21 05:14:08
问题 Given a convex polyhedron with defined vertices (x, y, z) that specifies the faces of the polyhedron. How can I go about calculating the surface normal of each face of the polyhedron? I need the surface normal in order to compute the vertex normal to perform Gouraud shading. The only clue I could find about how to do this is Newell's method, but how do I make sure the normals are outward normals and not inward? Thanks for any help. 回答1: Compute the face normal You have to compute the cross