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
2
votes
2answers
265 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. ...
2
votes
0answers
20 views

Codewars: Remote Control Virtual Keyboard

This is my solution to the Codewars problem TV Remote (symbols). Description In short, you are given a virtual keyboard with 3 modes between which can be switched by pressing the ...
1
vote
1answer
42 views

Dynamic field access in Haskell

I have to transform a response into the internal Coordinate record, some of the fields are lists and I need to handle empty lists case. Records: ...
6
votes
3answers
178 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]. ...
3
votes
0answers
73 views

Driver program using custom 3D game engine [closed]

I am working on a custom game engine and have been fleshing out the various submodules (meshes, physics, shading, etc.) Here is a sandbox program that exercises the newly finished camera system. ...
4
votes
1answer
90 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 ...
9
votes
2answers
393 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 ...
12
votes
5answers
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 ...
6
votes
3answers
613 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 ...
1
vote
2answers
83 views

Reposition vertices at the origin of a coordinate system

This method repositions vertices of an object in such a way that the center of the object is at the origin of the coordinate system. The task is the commented part. While my code does the job I feel ...
2
votes
1answer
36 views

Find intersection of rectangle with itself rotated

Given \$w, h, \alpha\$ for a rectangle centered at origin with width \$w\$, height \$h\$ and itself rotated by \$\alpha\$ around origin clockwise, I wrote a code to find the intersection area. ...
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
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
2answers
287 views

Parser for STL stereolithography data files [closed]

I'm parsing STL files to load the coordinates. My code is: ...
3
votes
1answer
57 views

State machine translates text into executable python code [v2]

A few days ago I started writing my own compiler-like program which has the goal to compile plain text into executable python code. After I let my first version review here, I made huge changes to the ...
10
votes
3answers
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 ...
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, ...
-2
votes
1answer
47 views

3D vectors in Objective C

I am trying to learn Objective C and want to make sure I am following the proper practices/convention. I would very much appreciate advice on what to change/improve I also have some questions: when ...
7
votes
1answer
189 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 ...
2
votes
1answer
114 views

X, Y Coordinates class in Lazarus (Delphi-like)

After I've now officially announced, that I'm discontinuing my color picker for Windows, I'm about to embark on a journey through Linux development. I was quite strong in Delphi on Windows, and see ...
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 \$\...
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 ...
1
vote
1answer
68 views

Comparison functions for 2D points [closed]

I have the following class for 2D points: ...
5
votes
1answer
660 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
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 ...
3
votes
2answers
111 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). ...
17
votes
6answers
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. ...
16
votes
0answers
219 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
46 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
118 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 ...
1
vote
1answer
81 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 ...
3
votes
2answers
1k 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
185 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: <...
10
votes
1answer
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. ...
0
votes
1answer
2k 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
109 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
969 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
47 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
4k 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 ...
8
votes
2answers
317 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
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 ...
8
votes
1answer
84 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 ...
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 ...
1
vote
3answers
3k 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
2k 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. ...
3
votes
0answers
80 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 ...
1
vote
1answer
121 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 (...
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: ...
3
votes
0answers
246 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 ...
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 ...