Questions tagged [2d]

2D computer graphics is the computer-based generation of digital images—mostly from two-dimensional models.

Flat perspective, having no three-dimensional geometry. Including two-dimensional space and 2D geometric models, or two-dimensional images having only height, and width with no depth.

7489 questions
8
votes
7 answers

Intersection between two lines in coordinates

I can detect the intersection point of two lines, but if my line don't has the length of my screen, it detects the point, where it shouldn't be. Here a preview: So, it shouldn't detect this intersection because the horizontal line isn't that…
Christian 'fuzi' Orgler
  • 1,682
  • 8
  • 27
  • 51
8
votes
3 answers

HTML5 Canvas transformation issue using 2D rendering context

I'm trying to make a sort of a camera in HTML5 Canvas using 2D rendering context. As you see in the picture I've drawn below, here's what I'm trying to achieve: Say that the black one is the eye of the camera, I want it to be able to move around …
user905864
8
votes
7 answers

Want to learn to write 2d games

Hey stackoverflow Community! I learned the basics of C# (i can write some Form-Applications) and now I want to learn how to write 2d games. I don't know where to start. Is there a engine that's good for 2d games? After learning the basics of 2d I'll…
CSharpBeginner
  • 89
  • 1
  • 1
  • 3
8
votes
2 answers

Passing 2d array char into function

I'm trying to pass a 2D array with strings in it into a function. I keep getting the expected expression before ] token. The point of this code is to read in a wordsearch puzzle, then find the words in that puzzle. I'm going to be writing a function…
hatfieldac
  • 113
  • 1
  • 1
  • 5
8
votes
10 answers

Algorithm for spread-out 2D point distribution

In a 2D pixel array, I need an efficient algorithm that will select p% of pixels that are the most spread out. This can be done adaptively by selecting points, then repeatedly adjusting the positions of points that are too close together. But this…
user20493
  • 5,704
  • 7
  • 34
  • 31
8
votes
2 answers

2D Physics Engine collision response rotation of objects

I'm writing my own basic physic engine and now I come to a problem I can't solve. Probably because I don't how to google this problem. So here is my problem. I hope this image can explain it: Collision response I have two objects. The gray one is…
tryzor
  • 800
  • 2
  • 10
  • 18
8
votes
2 answers

Calculating distance between 2 points on a circular map

I'm currently trying to create a video game where characters are AI and are in a circular map with ressources on it. I'm currently trying to calculate the shortest distance betwing 2 points on this map but my problem is that the map is circular :…
Loadex
  • 1,502
  • 1
  • 12
  • 25
7
votes
3 answers

Java: Finding the Outermost Vertices of a Convex Polygon

Original post: I'm trying to find the outermost vertices of a convex polygon (with relation to a point P outside the polygon). For now, I'm only concerned with rectangles (however, I'd like an algorithm that works with any convex polygon). My plan…
Peter
  • 4,021
  • 5
  • 37
  • 58
7
votes
4 answers

javascript library to process complex 2D geometry

Is there a good javascript library for complex geometry like: convex hull, polygon intersection (polygons with holes), polygon decomposition and polygon merging ? I heavily need polygon geometry, but it would be nice if there are more…
philipp
  • 15,947
  • 15
  • 61
  • 106
7
votes
2 answers

Boolean Operations on Cairo Paths?

Is there any way to build paths in Cairo by combining two paths together through Boolean operations such as Union, Difference, and Intersection? I'm working on a vector graphics application that uses Cairo to do its rendering and would like to give…
Adrian Lopez
  • 1,695
  • 1
  • 16
  • 22
7
votes
4 answers

OpenGL texture atlas bleeding

I'm trying to draw a basic 2d ground mesh made up of smaller tiles from a texture atlas (note the 1 pixel transparent border): I render the tiles as texture quads using the following code: glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,…
user408952
  • 882
  • 9
  • 23
7
votes
4 answers

Calculating the contours of a 3D heightmap?

I am looking for a function or example to produce a list of lines representing contours at a specific height within a heightmap. Eg, Lines[] = GetContours(Heights[512,512], HeightValue) Where Heights is a 512x512 array of floating point values,…
Adam Frisby
  • 358
  • 5
  • 20
7
votes
1 answer

Best solution for 2D occlusion culling

In my 2D game, I have static and dynamic objects. There can be multiple cameras. My problem: Determine objects that intersect with the current camera's view rectangle. Currently, I simply iterate over all existing objects (not caring wheter dynamic…
Hamilton
  • 79
  • 1
  • 2
7
votes
2 answers

Scala - Easiest 2D graphics for simply writing a 2D array to the screen?

What do you recommend for writing a 2D array of pixels to the screen? My first thought is some SWT binding, but are there any others? Processing perhaps?
Dominic Bou-Samra
  • 14,799
  • 26
  • 100
  • 156
7
votes
2 answers

2D nearest neighbour search for moving points

I want do do some flocking simulation, as described here. For this I need to search for the nearest neighbours of each of my 2D points. However, I cannot use a static data structure like a k-d tree because the points are always moving... What's a…
Jan Rüegg
  • 9,587
  • 8
  • 63
  • 105