Computer geometry is a branch of computer science devoted to the study of algorithms which can be stated in terms of geometry.
7
votes
1answer
173 views
Line segment to circle collision algorithm
I've written a function (in Python 3) which computes if a line segment (constraint) and a circle (body) collide, and returns the point of intersection (closest point to the centre of the circle):
...
2
votes
2answers
89 views
Find non duplicate Triangle Triplets from a list of given numbers- version 3
It is a continuation of my previous question:
Find non duplicateTriangle Triplets from a list of given numbers
After I realized triplet structure using less space than ...
4
votes
1answer
52 views
Distance between angles as points
This code calculates the distance between angles, particularly for n-tuples of angles. One example where this situation occurs is as follows:
I'm using a 2 arms, one 6 degree of freedom and the other ...
2
votes
1answer
90 views
Find non duplicateTriangle Triplets from a list of given numbers
I implemented an O(N^2) algorithmic solution but not sure it is better than my previous implementation Find Triangle Triplets from a list of given numbers
in case of performance. I adapted almost ...
4
votes
1answer
110 views
Find Triangle Triplets from a list of given numbers
If a triplet of segments A, B and C are triangle triplets if and only
if
A + B > C
A + C > B
B + C > A
Is there a better implementation for this problem?
...
1
vote
0answers
51 views
fftshift implementation for OpenCV
I'm trying to implement fftshift from matlab for OpenCV. Can you please review the correctness of my algorithm? Have I missed something? Also, is there a better and faster way to do it?
...
1
vote
2answers
40 views
Lazy properties for the angle and length of a line segment
The code below shows the pattern I use to manage properties in my classes when I have the following requirements:
Some properties are slow to calculate and are rarely used, so I want them to be lazy
...
3
votes
1answer
44 views
Scale object based on distance between 2 vertices
I made this script so that I can scale objects for 3D printing from Maya.
I had fun making it and I'm sure it could be cleaned up or improved. If it can be cleaned up please let me know.
...
2
votes
2answers
72 views
Comparing triangles using Java 8 streams
I'm trying to get more familiar with Java 8 streams as they seem to be very powerful (and shorter), so I rewrote a method to use streams. However I'm not very satisfied with it and would like some ...
6
votes
2answers
84 views
Speeding up 2D shadow algorithm
I wrote a class to represent a set of lights in a 2D game that raycast in order to find shadows. The draw method does a lot of calculations and takes a lot of time. Mainly, the adding of areas and ...
4
votes
2answers
86 views
Implementation of Graham Scan algorithm in Haskell
Here is an implementation of Graham Scan algorithm for computing the convex hull of a finite set of points:
...
5
votes
3answers
84 views
Line passing the most number of points
Given points on a two dimensional graph, find a line that passes the most number of points.
Any comments please?
...
4
votes
1answer
63 views
Use of static factory methods for vectors and matrices library
I've been working on a Java-based mathematics library focusing on vectors and matrices. I plan to use it for an important upcoming project, so the classes are analogous to data types available in GLSL ...
4
votes
1answer
61 views
Tested cartesian plane utility
I am starting to explore automated testing of code, so I decided to write some trivial code about the cartesian plane and test it. I am particularly interested in automated testing conventions and ...
4
votes
2answers
59 views
Cubic “bezier” curve of grade n
This is code I wrote for calculating bezier curves as quickly and RAM efficiently as possible.
I would like to know if there are faster ways to optimize anything, because I am very new to C++ and ...
3
votes
0answers
76 views
Graphical editor with geometric intersection
If it is possible I would like some comments on the overall style of the program. It feels like I am writing the whole program as one big script and I'm not sure how to break it down into several ...
3
votes
1answer
67 views
Ray→plane and ray→quad intersection
This checks the intersection between a Ray and a Plane and between a Ray and a ...
2
votes
2answers
57 views
Haversine formula in SQL
This is an implementation of the Haversine formula in Microsoft Transact SQL.
How can I simplify the function?
...
6
votes
2answers
107 views
Quaternion rotations and preparing matrices for a shader
I am implementing an OpenGL ES 2.0 renderer in c. I want to use quaternions for rotations. Please take a look at the way I am implementing the rotation math. Everything looks as expected when the ...
6
votes
1answer
45 views
'Tis the season for gift-wrapping
When reviewing a Graham scan convex hull algorithm implementation, I wrote the following function in an answer:
...
7
votes
3answers
89 views
Checking for intersection points
The aim of the program is to find those points which comes under the intersection of at least 2 circles.(space is a 1000x1000 matrix)
...
8
votes
1answer
567 views
Jarvis's March Convex Hull
I'm more concerned about the coding best practices and how it's written here than the actual algorithm and math. I'm concerned about stack constraints, passing arguments,..etc. If there is anything ...
4
votes
1answer
119 views
Generate sample coordinates inside a Polygon
I have a Polygon named as poly. I attempted to randomly select 5 coordinate points that lies inside the polygon.
...
7
votes
1answer
88 views
2D Convex hull exercise
I'm reading Real World Haskell, and this is my first try with the language.
This is the result of the exercises of chapter 3:
Consider three two-dimensional points a, b, and c. If we look at ...
1
vote
0answers
104 views
Optimize QuadTree to find K Nearest Neighbors
I'm looking a way to make my k nearest neighbors search more efficient. The context of the question is that I'm given a list of topics that have a unique ID (integer) and a (x,y) coordinate (floats) ...
3
votes
1answer
91 views
Calculating the distance squared between all vertex-pairs of a number of 2D polygons
I have implemented my code using Cython. It is the current bottleneck in my computations.
There are two non-numpy functions involved:
calculate_2D_dist_squared ...
11
votes
2answers
340 views
CodeEval's SkyScrapers challenge
This is a solution to CodeEval's SkyScrapers challenge.
You are given a list of triples \$(l, h, r)\$. Each triple represents an axis-aligned rectangle, with top-left corner at \$(l, h)\$ and ...
14
votes
7answers
783 views
Custom mathematical vector class
My first bigger C++ project: a vector class for personal use and statistical computation.
...
-1
votes
1answer
214 views
Custom 2D/3D Graphics Vector Classes vs SFML's
I don't really like SFML's Vector Classes so I tried making my own. Any criticism is welcome.
...
8
votes
6answers
2k views
C++ 3D Vector Implementation
I have been learning C++ now for 2 months and this week I started reading a book on 3D graphics. I like coding whatever mathematical stuff I learn so I can understand it better, so when I learnt about ...
6
votes
1answer
125 views
3D matrix rotation in homogeneous coordinate space
Assuming that the framework is in place to handle the difference between row and column major matrices, I am curious to know if in a header based library such implementation is semantically and ...
2
votes
1answer
125 views
Neighbours from point connections
I am working with a mesh of triangles (in 3D, although I doubt it makes a difference). The mesh is given as list of lists, each list containing the indices of the three vertices of a triangle in said ...
13
votes
2answers
475 views
Detecting two intersecting circles with editable x, y, and radius in JavaFX
I was actually pretty proud of this programming project that I came across in this book I'm working through. I only really had problems figuring out the formula for detecting whether or not the two ...
8
votes
1answer
199 views
Finding largest subset of line segments that don't intersect
I completed a challenge of codeeval called BayBridges. It can be found here. I have uploaded my code on GitHub here.
In summary, the challenge is to take a list of line segments, each specified by ...
7
votes
2answers
143 views
Performance Issues: Finding Nearest Polygon
Finding the nearest polygon out of a list of polygons seems to be quite a challenge on performance, due to lack of optimization. Consider the following image:
I'll give the concept behind this. The ...
3
votes
1answer
540 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:
...
11
votes
5answers
544 views
Checking if a list of coordinates defines a closed, exact rectangle
I have to determine if an N sized list of coordinates defines a closed, exact rectangle.
I start with the question "How do I check if a list of coordinates is in the shape of a rectangle?"
The ...
3
votes
2answers
301 views
Calculating if a point is within a polygon, or outside of it
Here is the function (along with its support functions):
...
5
votes
1answer
466 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 ...
14
votes
2answers
558 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. ...
4
votes
1answer
598 views
Quick Hull Algorithm implementation for higher dimensions
I tried to implement the Quick Hull Algorithm for computing the convex hull of a finite set of D-dimensional points. Here is the repository. Algorithm itself:
...
3
votes
1answer
148 views
Point in a polygon algorithm
I am implementing a Point in polygon algorithm.
Inputs:
M, N: size of the matrix
poly: a ...
7
votes
1answer
190 views
3D vector CUDA kernel
I designed this CUDA kernel to compute a function on a 3D domain:
p and Ap are 3D vectors that are actually implemented as a ...
1
vote
1answer
61 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 ...
5
votes
2answers
784 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 ...
5
votes
2answers
1k 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 ...
5
votes
0answers
184 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 (...
4
votes
1answer
566 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
1k views
Algorithm to get an arbitrary perpendicular vector
Is there a more efficient/direct way to find an arbitrary perpendicular vector of another vector?
...
11
votes
1answer
939 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 ...