Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

5
votes
1answer
60 views

Passing uint64_t from C++ to R: Hilbert Mapping - xy2d function

I have been working with Rcpp to perform a forward and backward Hilbert Mapping. Below is an implementation based on this code. My application is in genomics and I may be dealing with enormous ...
1
vote
1answer
60 views

Comparison functions for 2D points [closed]

I have the following class for 2D points: ...
3
votes
2answers
109 views

Determine whether a vector intersects the up or down unit vector

I wrote an if statement that checks if an iteratively altered vector "crosses" the up vector (0,1,0) or the down vector (0,-1,0). ...
6
votes
1answer
129 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 ...
1
vote
0answers
28 views

Error handling for an Erlang 2D point class

I am working on a math library for an online game. I want to prevent as many errors as possible and I want to catch all errors as early as possible to simplify debugging in the long run. However, I ...
1
vote
1answer
60 views

Vector addition and Pythagorean Theorem code

I would like to share my code that is meant to help me add 2 vectors together. It is very simple and I would like to kindly ask you whether you could review my code. Also, I decided to keep separate ...
3
votes
2answers
208 views

Class to store and manipulate Cartesian coordinates and vectors

I have made a C++ class to manipulate 3D vectors in Cartesian coordinates. However, the performance of my class is much slower (about 2.5x) than simply using something like ...
6
votes
1answer
86 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: <...
6
votes
1answer
236 views

Extracting an adjaceny matrix containing haversine distance from points on map

I am extracting 10 lat/long points from Google Maps and placing these into a text file. The program should be able to read in the text file, calculate the haversine distance between each point, and ...
10
votes
1answer
969 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. ...
0
votes
1answer
259 views

Find minimum and maximum coordinates for a set of points [closed]

I wrote the Python3 code below. This is actually a stripped down version of a bigger project, but in essence it boils down to this code. There are two classes: Point...
3
votes
2answers
87 views

C++ Vector with templates

I am learning about templates in C++ so I decided to implement an N-dimensional vector. The code seems to work fine, but there are a few things that I am unsure about. To stop ...
3
votes
1answer
396 views

Transforming from spherical coordinates to Cartesian coordinates using Eigen

I need to transform the coordinates from spherical to Cartesian space using the Eigen C++ Library. The following code serves the purpose: ...
1
vote
1answer
42 views

Path Following Algorithm for Entity

Within my game there are many entities, where each entity has a path (Array<Vector2>) assigned to it. No path to follow (indicating that the entity should ...
1
vote
1answer
45 views

Calculations to position a text box next to another object

I am implementing a program to draw a box of text next to some other drawn object (that can have any position and dimensions) and the text box should always be visible, even if the drawn object's ...
4
votes
2answers
1k views

Convert geodetic coordinates to geocentric (cartesian)

I'd like to retain as much float precision as possible without having to resort to specialized libraries so I need this code to work with only standard modules. I'm doing this in QGIS where ...
1
vote
1answer
78 views

Reusable vector module with tests

I'm learning rust with mostly a background in managed languages. I have a little C background. As a learning project I am re-implementing a linear-transformations library I've been working on in ...
8
votes
2answers
313 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?...
5
votes
1answer
38 views

Mutable 2d Rect class

So I wrote a 2d rectangle class for use in a 2d pygame based game engine. It uses the vector class from this question, so if you want to test, you need that code too. I want to ask: Does this ...
8
votes
1answer
69 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 ...
2
votes
2answers
95 views

Calculate next position and velocity after “bounce”

Intro and code I have the following function that calculates an objects "next" position and velocity (in 1 dimension) given a boundary [0, max]. ...
0
votes
3answers
2k views

Cartesian/polar coordinates program

Can I get my program checked for efficiency? As in, see if there are better ways of writing my code, for example, making more efficient use of memory and/or security options like where to use ...
2
votes
1answer
891 views

Calculating Euclidean distance

Code: I have a list of ~15,000 Euclidean points which represent a connected graph. I'm trying to solve/approximate the traveling salesman problem with this graph. Problem: Finding neighbors, i.e. ...
1
vote
1answer
91 views

Angle reflection function

I've developed a function to calculate the exit angle of a projectile after it collides with a boundary/edge inside a rectangular space, based on the entry angle and the axis it is colliding with. ...
1
vote
1answer
113 views

Finding angle and direction between line segments

I'm putting together a short demo on two things: Finding the angle between two line segments and direction (right or left) as you travel counterclockwise around a shape Using newer ecmascript syntax (...
3
votes
0answers
147 views

Define a class for latitude and longitude in C++ using boost::units and spheroidal coordinates

I am trying to write a class that defines latitude and longitude in C++ using boost::units and normalized spheroidal coordinates. I want to throw an exception if ...
14
votes
0answers
145 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. ...
1
vote
1answer
866 views

constexpr math Vector class

I am currently playing a bit around. While the current compiler starts to finally release the c++17 standard implementations, I am trying to create a mathematical ...
3
votes
0answers
79 views

Best path using some intermediate points, where cost is either x-axis or y-axis distance

We are given N Cartesian points \$(x, y)\$. Anytime we move from \$i\$-th point to the \$j\$-th, the move costs \$\min\left(\left|x_i - x_j\right|, \left|y_i - y_j\right|\right)\$. The problem is to ...
2
votes
0answers
98 views

3D wrapper for turtle

I am a Python enthusiast, but I'm never sure if what I'm doing is Pythonic. I have made my own graphics wrapper for Python's turtle. I don't entirely know if I did this right, so I have come here for ...
5
votes
1answer
206 views

C++ Calculate euclidean distance between tuples, for specified indices

I wrote a small utility function that will take two tuples and returns the Euclidean distance for the given indices only: ...
1
vote
0answers
80 views

Data structure for a list of radial coordinates

I have a loop that's updating a dictionary's values a large amount of time (by adding the new value to the old. Each value for each dictionary key is actually a list of 3 number, and so for each ...
2
votes
2answers
208 views

Calculate average spacing per direction

I am interested in finding the average spacing between objects on a directional basis. I did my best to minimally implement this in Python and to conform to PEP8. I try to explain what I'm doing in ...
4
votes
1answer
309 views

C++ mathematical n-dimensional vector template using fold expressions

I'm writing a template to unify a few mathematical vector types I was using. The goal is low overhead, constexpr where possible and generic utility functions built-...
4
votes
1answer
68 views

Convertible templated math vector

I've made a templated math vector struct with a templated type and templated dimension count. I want my vectors to be convertible so I can easily make, for example, a ...
3
votes
1answer
268 views

Transform byte array into upside down array of floating point pixels

I need to do the following in Python 3.x: Interpret an array of bytes as an array of single-precision floats. Then group each four consecutive floats into subarrays, i.e. transform ...
4
votes
2answers
7k views

Find an intersection point of 2 line segments

I want to find an intersection point of two line segments, if one exists. Each line segment is represented by two endpoints. Each endpoint is represented as an ordered pair of numbers. There are no ...
2
votes
1answer
280 views

WGS84-coordinate encoded as Integers

I want to store WGS84-coordinates in two integers for latitude and longitude instead of floats to get a higher precision than with floats. Here's my code: ...
9
votes
4answers
316 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 ...
3
votes
2answers
68 views

Fundamental Polygon in Python

I am writing a python class to implement a object moving along a Fundamental Polygon. It takes in a size of the square and config option with three booleans ...
3
votes
2answers
111 views

De-linearize a 2d linearized grid and calculate distance between 2 points

In a simulation of mine, for which performance is paramount, I have the following bottleneck. I have a huge 2D grid of dimensions width and ...
5
votes
4answers
199 views

Calculates best angle on path and approximates cardinal direction

This program uses the C language. What's used are two points, and the usage of the inverse tan function finds the angle of the line between the two points. Afterward, it finds the cardinal direction ...
3
votes
1answer
42 views

Getting position of coordinates and checking if they match

I have to compare variables to obtain coordinates. l upleft l upright -----------l-------------- downleft l downright l Here ...
3
votes
0answers
331 views

Building a k-d tree in Python

To learn Python, I have implemented a function that creates a k-d tree from a list of 2-d Points. I would like to refer to this question where i asked about the k-d tree in C. However, the Python code ...
3
votes
1answer
89 views

Splitting the coordinates of the world into equal blocks

It's a function to split the coordinates to some small blocks. For example, some country has a coordinates of north-east and south-west, two diagonals. If I set the interval to 0.05, it will returns ...
1
vote
1answer
740 views

Simple vector calculator [closed]

I am fairly new to Python and programming. I created this simple calculator inspired by my physics class. However, I feel this code could have been done more efficiently. Is there any advice for ...
5
votes
3answers
131 views

Haversine Formula in Clojure

I implemented the Haversine formula to calculate the distance between two (latitude, longitude) coordinates. I was wondering if it looks natural to Clojure programmers. What could be improved? <...
1
vote
2answers
109 views

Generate new latitude and longitude in decimal

I have created simple algorithm to generate the new Location from given latitude and longitude. ...
5
votes
3answers
399 views

Find the area of the bounding box of a robot's moves on a grid

Given a string of directions (example: "LLRUDDULRDRU") find the area of the rectangle defined by the lowest-left point ...
3
votes
1answer
63 views

Merging vertical lines that coincide

I have a list of lines and I need to merge those who are similar (for example my machine vision script will return 3 small vertical line instead of one long vertical line). I came up with this. I'm ...