2d

WPF 2D image binding performance

I have a high speed camera that I am displaying in a WPF control. The camera's SDK provides me with an array of bytes representing the image data. I'm looking for the most efficient way to bind to these images on a Canvas control. These images are displayed side-by-side from a collection capped at 20 images. My current method does work ...

Multidimensional vectors in scheme?

I earlier asked a question about arrays in scheme (turns out they're called vectors but are basically otherwise the same as you'd expect). Is there an easy way to do multidimensional arrays vectors in PLT Scheme though? For my purposes I'd like to have a procedure called make-multid-vector or something. By the way if this doesn't alrea...

Applying a 2d mesh to a 3d surface

I have a very complex 3d surface I need to apply a 2d mesh to. What I need is something like the Solidworks Wrap tool : http://www.rickyjordan.com/2009/01/the-solidworks-secret-weapon-the-wrap-tool.html Due to the complexity of the 3d surface normal texture UV unwrapping won't work. For instance, if I want to map a O and the 3d surface ...

Making Billiards in Box2D

As a quick overview: I'm trying to make a game of pool using Box2D as a basis. Now my question: How should I set up the billiard balls and edges so that they act normally? The balls sometimes seem to stick to the edges for no apparent reason. I've got four static wall objects with a restitution of 1 around the edges of the table. Ea...

Optimal rotation of 3D model for 2D projection

I'm looking for a way to determine the optimal X/Y/Z rotation of a set of vertices for rendering (using the X/Y coordinates, ignoring Z) on a 2D canvas. I've had a couple of ideas, one being pure brute-force involving performing a 3-dimensional loop ranging from 0..359 (either in steps of 1 or more, depending on results/speed requiremen...

Assigning a string to a 2D array

char in[100], *temp[10],var[10][10]; int i, n = 0, double val[10]; var[0][]="ANS"; I want to assign a string to var[0][0,1,2] which is 'ANS', but does not work and i cannot figure where i am wrong about this ...

I need a 2D bone engine for JavaScript

Hello. I'm looking for a way to define a Bone animation system, I need a basic one, since my objective is to apply it for inverse kinematics, much like Flash supports. The desirable feature is that: I can set bones (as position in 2D, defined by 2 dots) each having an ID. So I can make an animation based on frames, ie: ['l_leg', [10...

Mouse coordinates and rotation

How would you go about mapping mouse coordinates to world coordinates in a 2d context? For example, you have an image which you can drag. Next, you apply a rotation to that image and redraw it. Now when you drag the image it does not get translated correctly. For example after rotating 90 degrees, dragging up would cause the image to t...

Surface Detection in 2d Game?

I'm working on a 2D Platform game, and I was wondering what's the best (performance-wise) way to implement Surface (Collision) Detection. So far I'm thinking of constructing a list of level objects constructed of a list of lines, and I draw tiles along the lines. I'm thinking every object holds the ID of the surface that he walks on...

Formula to determine if a line segment intersects a circle (flat)

Hi, Apologies if this is considered a repeat question, but the answers I've seen on here are too complex for my needs. I simply need to find out if a line segment intersects a circle. I don't need to find the distance to the line from the circle center, I don't need to solve for the points of intersection. The reason I need something...

How would you update 100+ variables if something is changed in a different class?

I have a class Grid which produces a graph paper like grid on in the drawing area. I then have 5 other classes for different shapes to draw with; Line, Polygon, Ellipse, Curve, Arc Now, these 5 classes use an instance of Grid because Grid has a resolution and a scale. Inside Grid I have: public function set resolution(x:Number):void { ...

Finding OpenGL texture size in bytes after it was loaded

Hey, I have a texture loaded with glTextImage2D. I want to get the texture's size after it was loaded to the VRAM, what do I need to do? My internal format is RGBA and the texture's format varies. ...

Rewriting a simple Pygame 2D drawing function in C++

I have a 2D list of vectors (say 20x20 / 400 points) and I am drawing these points on a screen like so: for row in grid: for point in row: pygame.draw.circle(window, white, (particle.x, particle.y), 2, 0) pygame.display.flip() #redraw the screen This works perfectly, however it's much slower then I expected. I want to...

Android ==> Simple 2d Animation ???

public void MoveMyButton (int x) //where the button suppose to move to { TranslateAnimation anim=new TranslateAnimation(this.getLeft() ,x, this.getTop() ,20)); anim.setFillAfter(true); anim.setDuration(1000); this.setAnimation(anim); anim.start(); } button's x at start is 1. I call the method to move it to 100, and it goes from 1 to 1...

Collision detection 2D between rectangles

Hello. I am writting a collision detection engine for my game and I have some problems. Indeed, since I have several fixed rectangle and one moving (the player), I need to know which side of the fixed one was collided at first by the player, to replace him correctly. The fixed rectangle are NOT in a grid so they can be placed anywhere...

[java] Looking to count frequency of #'s of 2D array output and assign it to a 1D array.

Need to put the frequency of each number occurrence into a 1D array and output the result. The 2D to 1D part is throwing me off, I'm not terribly comfortable with arrays yet. public static void main( String[] args ){ int matrix [][]=new int[20][2]; for (int row=0;row<matrix.length;row++){ for (int column=0;column<matrix[row]...

Polygon to Polygon Collision Detection Issue

Hey guys, I have been having a few issues implementing my narrow phase collision detection. Broadphase is working perfectly. I have a group of polygons, that have a stl::vector array of points for their vertices in clockwise order. Every cycle, I check to see whether they're colliding. I have borrowed the following Point in Polygon ...

How can I find the minimal circle include some given points?

I have given some points (2D-coordinates) and want to find the smallest circle, that includes all of this points. The algorithm doesn't have to be very efficient (while it would be nice naturally). ...

What is the correct way to perform alpha blending? (C)

Hi, I'm writing a very simple graphics library, and I'm trying to figure out how to do alpha blending. I tried it a few times, but my results were less than satisfactory. According to Wikipedia, I should do: Value = (1-alpha)*Value0 + alpha*value1 This, however is not working at all. Maybe I'm doing something wrong? The code I've inc...

barycentric coordinates using quads

Hi everyone, some of you know how fill a quads in 2D using barycentric coordinates?At the present, I'm splitting the quads into 2 triangles, but that way is inefficient because I have to iterate over the second bounding box which repeats pixel that were filled previously (by example, to fill the 2nd triangle I traversed the 1st triangle ...