2d

2 dimensional array, calculating maximum value

Hey everyone, I'm trying to get the maximum value in a line in an 2d array. For example is this greyscale image. For me it's no problem to calculate the horizontal and vertical maximum grey value. However, I don't have a clue how to calculate an angled line (green line) from this 2d array. Anyone can help me out with this. ...

How to get camera position from such data generated by LSD lines detector?

So for example I have such lines with coordinates. how (using what algorithm) is it possible to generate some kind of simple 3d scene meaning get relative distance from camera to the wall that is facing us? ...

php- recursive 2d array function

I have a 2d array say, Array A[60][150] and have another array, Array B[60][150]. Now what I am trying to do is: Given a point in Array A say x,y i want to access its neighbors to find similarity between the two elements. if they are similar then find its neighbors. So right now i am using recursive function to do it. But its throws an ...

XNA - Getting mouse coordinates with a 2d Camera system with rotation/zoom/translation

I have a 2d Camera with this translation matrix: Transform = Matrix.CreateTranslation(new Vector3(-Position.X, -Position.Y, 0)) * Matrix.CreateRotationZ(Rotation) * Matrix.CreateScale(new Vector3(Scale, Scale, 0)) * Matrix.CreateTranslation(new Vector3((GraphicsDevic...

Android 2D Graphics - Dragging an Image onto Another Image

Hi, This is just a "where do I start" question, really. I'm working on an app where you dress up a 2D ragdoll from a selection of body parts. The aim is that the user will have a sillouhette figure on one side, and a selection of arms, legs, heads and bodies that they can sort through on the right. They can drag an image from the rig...

How to use an SVG file as input for drawing with Cairo in a pyGTK application (python)?

I am writing a small python GTK application in which I have a drawing area that I am trying to "populate" using Cairo, which is a library I never used before (so bare with me if the answer is obvious and I did not see due to inexperience). What I am trying to achieve is using an SVG image as part of my drawing (if I got Cairo naming rig...

OpenGL 2D game question

I want to make a game with Worms-like destructible terrain in 2D, using OpenGL. What is the best approach for this? Draw pixel per pixel? (Uh, not good?) Have the world as a texture and manipulate it (is that possible?) Thanks in advance ...

[DELPHI] Canvas/Bitmap scrolling question

Hello. I'm trying to make a small game based on the canvas in Delphi. Basically, I'd like to make a fairly large bitmap ( 3000x3000, for example ), then load it into the canvas, and being able to scroll right/left/up/down just like an ordinary image viewer, however I can't seem to find what I'm looking for. Any ideas? ...

Ipad application crashed when invoke CGContextDrawPDFPage

Hi everybody, I have a pdf document with 1000 pages and I am drawing them using CGContextDrawPDFPage function. But on page 466 application crashed. Here is my page drawing code... NSLog(@"%@",@"Before drawing pdf page."); CGContextDrawPDFPage(context, page); NSLog(@"%@",@"After drawing pdf page."); This is Console output: 20...

2D Canvas in Browser

Hi, I'm looking for a framework or library to use the browser as a 2D "drawing" tool. Acctually drawing is not the right word. It should be a adding, removing and moving around of 2D objects and images on a canvas. The objects should be graphically connectable. So - kind a visio in a browser I guess it's a bit to much for a javascrip...

Pixel dilemma: Choosing the right graphics API

I want to make a sidescrolling 2D game with destructible terrain. My approach is having the terrain as a BMP and having access to each pixel. However I have a problem with choosing the right graphics API for my game. I have already considered several options: SDL I started writing the game in SDL, I had the terrain as surface which...

Obstacle path detection for 2D game

Hey I'm pretty much working on a platformer and still starting out so I was curious about best practices/algorithms. I have in my background just a castle and about 200px high at the bottom some grass which slightly curves up and down. In the middle (which is part of the background png) I have a rounded rectangle rock. So nothing is its...

Scale a large image and keep same focal point on display.

float getNewScrollPoint(float displayPt, float scrollPt, float imageSize, float scaleFactor) { float imagePt = (displayPt / _Scale) + scrollPt; float nuScale = _Scale * scaleFactor; float nuDisplayPt = imagePt - (displayPt / nuScale); return nuDisplayPt; } public boolean onScale(ScaleGestureDetector detector) { final float scale =...

Graphing x-y coordinates from a mouse with Processing

I've found this really cool site on interfacing an Arduino to an optical mouse to read out x-y readings from it. I've done it, and it's working nicely. Then I was thinking, 'Why not plot all this to become a graph?' and I came across Processing. I am aware that Processing has an example named 'MouseSignal' This example is the EXACT th...

OpenGL ES on iPhone, How to Optimize for 2D (+ questions)

Hello ! I begin with OpenGL (and ES), so I have some (|| a lot) of troubles ^^ I Have two questions. 1°) I would like to have your opinion about my code. Because I don't know if all lines doing what they should do. The aim is to draw the lines of a polygon (but not to fill it, yet ^^). So I just want to do 2D on background transparent....

Math me - 2d video games.

I'm a hobbyist game programmer. I only do 2d games, no 3d stuff. I don't have a math background and lots of things are tripping me up like bullet projections and angles. I took two college level Algebra courses at the local community college, but really disappointed. I got As in both, but really don't feel like I'm using any of it in...

SQL: search of nearest in 2d square and circle.

I have a table: points it has 2 filds: X, Y each row represents a dot on 2d field I want to be capable of performing search of dots with in some radius R like and is square with side A like BTW: I use PHP to access my DB. My main point is to get nearest to center of figure point as first result in the quqe like How to do su...

Generating 2D regions

Are there any good approaches to generating regions for a 2D map? Suppose you have a world map and would like to create country or province borders with a somewhat realistic look. ...

Convert mouse position to world coordinates in 2D openGL after window resize

When the program I wrote starts up, I have some vertices in a window. The viewport is set to take up the entire window. On a mouse click, the distance from the mouse position to each of the vertices is calculated. If any of them are within a certain threshold (let's say 5 units), the vertex is selected. This part works with no problem. ...

Checking to see if 3 points are on the same line

Hi, I want to know a piece of a code which can actually tell me if 3 points in a 2D space are on the same line or not. A pseudocode is also sufficient but Python is better. Thanks ...