Questions tagged [coordinate-system]

A coordinate system is a system which uses one or more numbers, or coordinates, to uniquely determine the position of a point or other geometric element. Do not use this tag for questions regarding longitude and latitude. Please use [geospatial] instead.

185 questions
Filter by
Sorted by
Tagged with
27k views

I've implemented a quadtree in C++. Ignore any apparent similarity to the pseudocode on Wikipedia, it's all in your head, I swear. How can I improve it? Algorithm speed/space improvements, any extra ...
1k views

Refining AI movement logic

I have the below class which moves the AI towards the given plant, this works well however it feels really messy. Any input as to a better way to lay out the logic would be really grateful, the logic ...
4k views

Converting from polar coordinates to rectangular coordinates

This is performance critical. I measured and determined that using the sqrt is faster then using the cos method. I am aware ...
253 views

Rubik's cube mode for emacs

Following is a dumb implementation of Rubik's cube for Emacs. I am not well versed in writing (e)lisp, so I ask for a review and corrections. ...
6k views

Vector (physics) implementation

I recently started learning Java, and I decided to implement a basic vector system for another particle system I was building. ...
3k views

N closest points to the reference point

Here is working code to get N closest points to some reference point. Please help to improve it, specifically by commenting on my use of std algorithms and ...
17k views

Comparison to infinity when checking if a point is above a line

I have a function that is being called in a tight loop. I've profiled my code and this is where my largest bottleneck is. The function is fairly simple: it checks if a point in (x,y) form is above a ...
197 views

Tracking the bounding box of a map

Context I have a bunch of data points that look roughly like this: ...
369 views

A* Go application

I've written a generic implementation of the A* algorithm as a first Go program, since I had implemented that both in C and in Python before and Go reminds me a bit of both. I'm looking for general ...
2k views

Algorithm that spans orthogonal vectors: Python

The code consists of three functions: Spans arbitrary vector (takes dimension as an argument) Spans vector orthogonal to the one passed in the argument Finds cross product between two vectors. The ...
3k 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 ...
364 views

Counting paths in an n-dimensional grid that stay within the boundaries

Problem Statement You are situated in an N dimensional grid at position (x1, x2, …, xN). The dimensions of the grid are (D1, D2, …, DN). In one step, you can walk one step ahead or behind in ...
1k views

K-Means in Rust

I have implemented for learning purposes a simple K-Means clustering algorithm in Rust. For those who are not familiar: you are given N points, say in the plane, ...
2k views

Heavily limited premature compiler translates text into excecutable python code

My goal is to write a smaller compiler-like program, which allows me to draw geometric shapes into a 3D Diagram. There is no need for turing-completeness and the program should only be viewed as an ...
1k views

Find the closest unvisited visible home

I'm writing a 2d top down game where I perform a lot of "closest" searches between one point and all the rest of the points. In this example, "me" wants to search for the closest visible house (Home) ...
248 views

Distance between two n-dimensional points (NASM)

I just finished writing a function that computes the distance between two n-dimensional points. The original one was written in C and it's basically a translation of this formula: \\$\text{dist}(x,y)=...
1k views

A 3-D vector class built on top of numpy.array

I wanted a convenient class to easy access the parameters inside. I am using a lot of math in my game; that's why a wanted to access them through x, ...
494 views

Simulating a polygon

This code simulates a polygon (say a triangle) with a person at each vertex, every person is looking at the next adjacent vertex/person. They all start moving towards each other with a constant ...
2k views

C++ math vector template

I wrote a basic template for a vector of arbitrary dimension to be used in a 3D-engine. Most operators make use of C++ template meta programming and instances are implicitly convertible to glm types. ...
254 views

Templated Point class of any dimension

I needed to make a point class for a term project that involved arbitrary dimensional points. I came up with this, and I know that it works fine, but I'm looking to improve it so I can reuse it in ...
508 views

C# vector library

I have been working on a vector library for a little bit now. And at this point the basics are down and I am looking for some tips and advic - this may include: suggestions for things that might be ...
330 views

Shifting the origin of a large list of coordinates

Problem and goal Given a large edge list file (such as 2 million nodes, 30 million edges) containing source and destination coordinates, I want to 'convert' them in such a way so that the coordinates ...
3k views

Particle class for physics simulation

This is a very lengthy class called Particle, it relies on two other headers, one of them is a simple struct which contains an x and y (...
2k views

Checking if a point is on screen

I'm working on a tile-based game, and am looking to improve the efficiency of my code to slightly improve framerate. I call this method on every tile, every frame, so it is very performance critical. ...
2k views

Check if one shape is in another shape

I have a code to check if one shape (circle or square) envelops another. I have used this code. It gives true if the this object envelops the passed shape. Can anyone suggest me an improvement or ...
321 views

Validating user-provided control points for a Bézier curve

I have made some code which will validate user input for getting 4 control points for a bezier curve. It works fine however I was just wondering If I could make this code any more compact or efficient?...
175 views

Type-safe cartesian co-ordinates

I've recently been fiddling around with a type safe implementation of cartesian co-ordinates (and a few operations on those co-ordinates). Often it's easy to get units mixed up: is something in metres,...
266 views

Shorten up Mesh Generator Class

I'm currently writing a mesh generator class, and I'm making a method that generates vertices, normals and texcoords for a cube. But, as you can see, it's incredibly complicated and hard to follow. Is ...
90 views

Mutable 2d Vector classs

I create a 2dVector class to use a position coordinates in a pygame application and maybe in the future as part of a physics engine. Does this implementation has any huge downsides? Is the type ...
2k views

Determining which octant has a specific point

I am interested in octants in plane geometry, which basically involves dividing a plane into 8 equal parts according to a certain point. Octants are particularly useful while implementing the ...
723 views

Breaking a chess coordinate string into 2D coordinates

Given a chess coordinate as a string (e.g. "a1") I'd like to transform it into a 2-D array (so, for "a1" I'd like to get [1,1]). Here's what I came up with: ...
399 views

3-D Space Vector

I wrote the following implementation of a Vector in Java. I was wondering what you folks thought of it. ...
132 views

Unit test for Unique Position Point

Here is one of my msTest Unit Tests and possibly one of the worst "looking" tests. ...
2k views

Using homogeneous coordinates to rotate an image

Currently, I have this code snippet, but it's a little bit slow: ...
209 views

Mouse coordinates to grid coordinates within an isometric map

I wrote an algorithm to transform mouse screen coordinates within an isometric map to corresponding coordinates of an underlying 2D-square grid. The algorithm works and I tested it successfully. I ...
3k views

Get all points on a uniform discrete grid inside a circle's radius

I have a 2-dimensional grid defined by a known point gridCenter and distance between points gridStep and need to find all points ...
616 views

Ordering 2D Border Points

What i am trying to do I have an image of a polygon exemple: what i am tring to do is getting all border points, that do not have at least one neighbour with the same color, and ordering them in a ...
392 views

“Critter Tracking: When does it cross its own path?” Part 2

Basic Info: This question is my second attempt at this question. It is based on a question similar to this Codility question. The input (an int array), the outpout (an integer) and the method ...
201 views

Creating SOLID immutable and mutable Location types

I have a Location type: ...
588 views

Mapping square objects to specific cells in a TableLayoutPanel in WindowsForms game

I have solved this problem but I am looking for a better way to do it, in fewer lines of code. The problem was from this previous question on Stack Overflow. My solution: ...
3k views

Finding the bounding box of a polygon array

I have a Polygon array, and I need to get a Rectangle object which bounds all of the polygons inside the array. Think convex ...
497 views

Enum Constants for Convert Units

I have a few constants in a game that I'm doing for hobby. I need to store constants for the total size of the a Physical World and the size of the Screen. I can position the world's objects to the ...
555 views

Moving a rover and receiving current coordinates

I made a little text-based game where you move a rover and it gives you the current coordinates. You can essentially move around a 1000x1000 grid, and get output into ...
183 views

Calculate next position and velocity after “bounce”

Intro and code I have the following function that calculates an object's "next" position and velocity (in 1 dimension) given a boundary [0, max]. ...
99 views

Recently I found the need to implement a normalization formula in a couple of places in my basketball game, so I created some static methods inside of a class to do so. ...
1k views

High performance triangle - axis aligned bounding box clipping

Implementation of a Robust (i.e. with a finite plane thickness) Sutherland–Hodgman algorithm for clipping polygons against an axis-aligned bounding box. I use the following code only for clipping ...
4k views

Creating 2D vectors

I've made a little mechanism for creating 2-D vectors in Lua. Vectors have two components i and j, and support addition, dot ...
262 views

Type-safe Euclidean vectors in C++

I'm trying to follow the Raytracing in One Weekend book, and I found that he uses the same Vec3 class for everything - colors, coordinates, direction, and more: <...