Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Questions tagged [computational-geometry]

Computer geometry is a branch of computer science devoted to the study of algorithms which can be stated in terms of geometry.

224 questions
Filter by
Sorted by
Tagged with
4k views

Calculating the distance between one point, and many others

In my program, I have entities that I call "blobs", because they have a blobby shape. Blobs are polygons. If I have two blobs, then their information array would look like: ...
3k views

Calculating “element-wise” the angles between two lists of vectors

Let's say you have two lists of vectors: v1s = [a, b, c] v2s = [d, e, f] I am interested in generating the following result:...
288 views

Is this a good algorithm for 2D collision, or will it allocate too much memory?

I have a Rectangle class, of which I have 5-6 vectors for each instance. The main vectors are the center and color of the object, while the secondary vectors represent more or less the north, south, ...
2k views

Small 3D and 4D vector utilities

I'm a hobby programmer and have started 2 month ago with C++. I had some knowledge of Python, and I learned it all through Internet tutorials. I'm looking for your help, since I don't have a tutor I ...
2k views

Calculate the intersection between two intervals on the same circle

I want to calculate the ratio of intersection between two intervals; the length of the intersection divided by the length of the shorter interval. If two intervals do not intersect, the ratio is 0. ...
934 views

Point in a polygon algorithm

I am implementing a Point in polygon algorithm. Inputs: M, N: size of the matrix poly: a ...
97 views

Find triangles from line

I have some lines that form triangles. I'd like to challenge the fastest way to find all triangles. In particular the code should take an ArrayList of Line2D object and return an ArrayList of ...
6k views

Mathematical Vector2 class implementation

This is my first attempt ever to build a Vector2 class. I scoured the net for anything that might make this class more efficient but know I'm to the point where I'...
7k views

Class Vector with Python 3

Here is a class vector in python 3, for n-dimmensional vectors. Please suggest ways to improve the code as well as fix bugs and errors. The only rule is not using: numpy, sympy, scipy and so on. Only ...
4k views

Optimize vector rotation

I have a trivial function that rotates 2d vectors, and a method in a class representing a polygon that rotates every point in the polygon around an origin. The code is fairly optimized as it is, but I ...
2k views

Graham Scan convex hull algorithm

I'm beginning to learn Haskell. I've implemented the Graham Scan algorithm for detection of convex hull following the Real World Haskell book. I'm looking for general advice regarding the style and ...
748 views

Creating shapes program with multiple classes (different files)

I just started to learn Objective C with Programming in Objective C by Stephen G. Kochanand and I would love to get your feedback to see if I'm getting OOP concept with Objective-C right. ...
403 views

Is this a BSP tree? Am I missing something?

I've been practicing using BSP trees as I hear they are a good start to create procedural spaces such as houses. For ease-of-deployment purposes, I've tested this code in Lua and it seems to work. ...
6k views

Faster computation of barycentric coordinates for many points

I'm just starting to understand the Python syntax and I created a module that does what I wanted, but really slow. Here are the stats of cProfile, top 10 ordered by ...
347 views

Artifact collision in plane module

Here's something I tried putting together as I'm learning. Critiques on anything are welcome. There's also a logic bug in the Plane module I can't identify. The long and the short are that it takes ...
1k views

Calculating angle in isometric view

I have an angle where I need to convert a 'normal' angle to an isometric angle (116 degrees), and I came up with this function. It works, but I was wondering if the math could be optimized/simplified, ...
100 views

How to reduce execution time for this clustering computation?

Is there any way to reduce total execution time for the function getSilhouetteIndex? P.S. I am using weka SimpleKMeans for ...
552 views

Computing tangent space basis vectors for an arbitrary mesh

This is more like a share and a request than a question. I converted Eric Lengyel's code, which calculates tangents of a mesh for the purpose of texturing and normal mapping, to support SIMD. For this ...
483 views

Refactor code to find four co-linear points

I am relatively new to Java, but have been reading up on how to improve the quality of my code. I am writing a system where I take in a series of points from a file with x and y co-ordinates and by ...
695 views

Move Line across Plane

I want move a Vertical line segment across a plane or another way sweep the plane, from Left to right. The figure illustrates how the segment is moving at the X-axis. When x1 >= X beginning and i ...
6k views

Best way to work out angle between points?

I have the following JavaScript code to work out the angle between two points (clockwise). The code I have seems a bit "hacky" to me, as I have a while loop ensuring the number is not negative (to ...
219 views

Complex logic that I'm certain can be simplified

This is code from a grappling hook implementation. This is specifically code that, after a block is detected between two way points, it tries to find a path around. This particular piece of the ...