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.

Filter by
Sorted by
Tagged with
5
votes
4answers
4k views

Octree code performance

I'm using a simple octree in my program and wanted to know if my implementation could be faster. It is part of this program. Octree.H: ...
5
votes
3answers
401 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 ...
5
votes
2answers
14k views

Getting the neighbors of a Point in a 2D grid

I am trying to find an algorithm to find all the defined neighbors of a 2D Point (efficiently would be nice, but does not make much of a difference). Here is my ...
5
votes
2answers
5k views

Simple Octree implementation

I've implemented a rather straightforward octree, but I don't feel that good about the coding style or some of the implementation. In particular, I use some nasty ...
5
votes
4answers
221 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 ...
5
votes
2answers
396 views

3-axis coordinate system for a Chinese Checkers board

About a year ago, my brother and I came up with this cool idea for how to solve the problem of determining if any given "cell" on a Chinese Checkers board was adjacent to the cell in question. ...
5
votes
4answers
504 views

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

Added: Version #2 of this question Minor Update/Additonal information: This question is based on a Codility question similar to this one. The input (an int array), the outpout (an integer) and the ...
5
votes
3answers
182 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? <...
5
votes
2answers
975 views

Enums for the four directions

I have walls that I can spawn. They wll move in one of four directions, up, down, right or left. Now I can set, wether the wall is thin, wide, long or short, but the problem is: Nearly everything I ...
5
votes
2answers
143 views

Attempt at templates by creating a class for N-dimensional mathematical vectors

Originally I had tried to implement this topic after having learned about Inheritence and posted it on here, but that forced complexity and the main suggestion was that this was ideal for templates. ...
5
votes
2answers
100 views

Class hierarchy for objects in a 3D engine

I am writing my own 3D engine. I initially made the code quick and dirty but after a while the code became pretty messy and it have a lot of repeating code so I am currently cleaning up some of the ...
5
votes
2answers
194 views

NamedPoint class using unique_ptr for members

After reading this old article from 2001 I have tried to implement the class from it using unique_pointer. An author's claim is that C++ is not appropriate for ...
5
votes
2answers
6k views

Get Rectangle Count from Given List of Co-ordinates

Problem Description Write a program to find the maximum number of rectangles that can be formed both horizontal and vertical with the help of a given n number of coordinate(x,y) points. [x,y ...
5
votes
1answer
89 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 ...
5
votes
1answer
239 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: ...
5
votes
2answers
431 views

Given a linked list of line segments, remove collinear points in the middle

This code removes any middle point find in line. It works only in x and y axis. This problem is a Java implementation of this. ...
5
votes
1answer
2k views

Plotting a vector field in R + ggplot

I've written a small program that draws a vector field in R using ggplot for a given differential equation. There is a topic on the subject here however, the proposed solutions either don't provide ...
5
votes
2answers
79 views

Calculating positions along the edges of a rectangle

I had the following three Tcl procedures, which calculate positions along three edges of a rectangle: ...
5
votes
1answer
197 views

Determining directions for a 2D boad

My original code is: ...
5
votes
1answer
655 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 ...
5
votes
1answer
86 views

Haskell compositor

This is a concept for a compositor. It would help me if you could review how well I expressed my ideas into the functional language. I first divide everything in an areas that each window covers ...
5
votes
1answer
71 views

Gravity problem solver in Factor

After answering a question about Factor, I decided that it looked interesting. To get the hang of the syntax and such, I decided to write some basic physics code to "solve" the three-body problem. ...
5
votes
1answer
39 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 ...
4
votes
3answers
348 views

Calculating the surrounding objects in a two-dimensional coordinate system leaving out the corners

We have a dynamically created map with two dimensional coordinates. There's an object in this map on a random position and I need to validate the four adjacent fields. However, I need to leave out the ...
4
votes
2answers
286 views

Parser for STL stereolithography data files [closed]

I'm parsing STL files to load the coordinates. My code is: ...
4
votes
2answers
3k 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 ...
4
votes
3answers
5k views

Bresenham's line algorithm implementation

May there be any performance and/or code standard improvements on the following LineOfSight code? ...
4
votes
2answers
61 views

Achieving a rotated Vector magnitude

I am trying to convert this velocity into another 2 dimensional vector at some specified angle: ...
4
votes
1answer
78 views

vector3 math module

I'm writing a little math module in C to handle vectors and matrices. This will be column-major style but right now I've only finished the basics of the vector functions and wanted some feedback on ...
4
votes
2answers
82 views

Find 4 points which form a square with the biggest area

I have set of points on the coordinate plane. I need to find the 4 points which form a square with the biggest area. I'm new in JavaScript so I'd like to get any suggestions about code style, ...
4
votes
2answers
11k 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 ...
4
votes
1answer
505 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
1answer
76 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 ...
4
votes
1answer
6k views

2D Vector class

As part of a game engine I am creating, I am in the process of writing a bunch of math classes (vector2/3/4, matrix2/3/4, and quaternions to start with). Vec2 ...
4
votes
1answer
279 views

Plotting discontinous function

I've made a simple web plot with D3 JS version 4. I've drawn a discontinuous function: $$f(x)=\frac{1}{x(x-2)}$$ which has 2 vertical asymptotes and 1 horizontal asymptote. I add a legend with LateX:...
4
votes
2answers
115 views

Vectorizing a polar coordinate conversion loop in a fingerprint-matching process

I am working on a fingerprint matching technique and it takes a lot of computation time to obtain the result. I am trying to implement the matching process given in A Minutia Matching Algorithm in ...
4
votes
1answer
113 views

Movement code for a game that should be able to handle almost infinite coordinates

Now I've grasped the very basics of Pygame, I thought it'd be useful to make a few classes that I could use later on if I try make a simple RPG style game. I've done this to handle the coordinates for ...
4
votes
1answer
81 views

Ensuring data consistency in a PointsAlongCircle object

I'd like to write classes which are Pythonic, readable and easy-usable. A main issue for me is to keep data consistency. Here is an example (version 1): ...
4
votes
1answer
88 views

Idiomatic quadtree implementation in Rust

I am learning Rust, coming from a Java background, and I was hoping to get some critique on my simple QuadTree implementation in Rust. This is as a learning exercise for me. Are there tips on how to ...
4
votes
1answer
43 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 ...
4
votes
1answer
368 views

2016 Advent of Code Day 1, Part 1 and Part 2

I've been reading the Rust versions of this, and just because I'm kinda tired, I thought I'd just throw together something in C. Here's my 15 minute effort to solve the 2016 Advent of Code Day 1, ...
4
votes
2answers
3k views

QuadTree C++ Implementation

I recently created a QuadTree implementation in C++. It varies slightly from most implementations. Instead of storing elements it only organizes elements. This allows programmers to insert elements ...
4
votes
1answer
2k views

Heavily templated mathematical vector class

I started to write a library for linear algebra for personal use, but also for revitilization of my C++. Below is the first class of this library, a templated vector class, which is templated over ...
4
votes
1answer
76 views

Wavefront 3D Obj parser/viewer

For learning Rust I decided to make a 3D .obj viewer. I wrote a simplified OBJ parser without materials that only supports triangles. Considering I'm completely new to Rust and don't really know ...
4
votes
1answer
456 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
77 views

Converting xy coordinates to theta without discontinutities

This one is, or rather, should be, fairly simple. I have a list of tuples of XY positions, and am trying to pull out angles relative to the origin from it. However, unlike ...
4
votes
0answers
421 views

Building Data abstraction and ADT for rectangle using “objects”

For the below given exercise: Exercise 7: Abstracting Rectangles Implement a representation for rectangles in a plane. (Hint: You may want to make use of your procedures from exercise 5). Then,...
3
votes
2answers
5k views

Generate random unit vectors around circle

I'm trying to generate a bunch of uniformly distributed unit vectors around the unit circle. Here's my code, which is working, but unfortunately I have a for-loop. How do I get rid of this for-loop? <...
3
votes
2answers
139 views

Gram-Schmidt process in Java for computing independent bases in linear spaces

Given a set of \$k\$ \$n\$-vectors \$\vec{x_1}, \dots, \vec{x_k}\$, Gram-Schmidt process computes a basis \$\vec{y_1}, \dots, \vec{y_m}\$ (\$m \leq k\$) the vectors of which span the same space as \$\...
3
votes
2answers
324 views

Transforming a list of two-dimensional coordinates into a flat list of relative changes

I have a little function that parse a nested list of coordinates into a flat list of compressed coordinates. By compressed coordinates, I mean that only the delta (distance) between each coordinates ...