3
votes
2answers
83 views
4
votes
2answers
140 views

Python implementation of the Ramer-Douglas-Peucker Algorithm

I recently implemented the RDP polygon approximation algorithm in Python and I'm skeptical of whether or not I implemented it correctly of with the greatest efficiency. The algorithm runs in around ...
3
votes
1answer
63 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: ...
5
votes
1answer
66 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 ...
3
votes
1answer
74 views

Point in a polygon algorithm

I am implementing a Point in polygon algorithm. Inputs: M, N: size of the matrix poly: a ...
4
votes
0answers
93 views

Ways of speeding up this python implementation of SAT (Separating axis theorem)

A project I was working on required the usage of the Separating Axis Theorem to detect collisions between two convex polygons in real time. So I implemented a basic class (...
5
votes
2answers
129 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 ...
4
votes
1answer
84 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 ...
3
votes
3answers
341 views

Algorithm to get an arbitrary perpendicular vector

Is there a more efficient/direct way to find an arbitrary perpendicular vector of another vector? ...
14
votes
3answers
2k views

Overlapping rectangles

I received the following question in a technical interview today (for a devops/SRE position): Write a function which returns true if the two rectangles passed to it as arguments would overlap if ...
6
votes
1answer
282 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 ...
13
votes
2answers
663 views

Speed up solution to Project Euler problem 75

I've been programming for a few months now, and have used Stack Overflow a great deal, but this is my first post. Anyway, I wrote this code for Project Euler problem 75, which asks how many integers ≤ ...
2
votes
1answer
191 views

recursive algorithm to obtain grid points inside a n-cube volume or surface

I did wrote in python two functions to return points in the n-dimensional cube of half size K (meaning that the coordinates along each axis go from -K,.. 0.. K). The n-dimensional cube volume should ...