2d

Freeing 2D array - Heap Corruption Detected

早过忘川 提交于 2019-12-12 02:46:39
问题 EDIT: Sorry guys, I forgot to mention that this is coded in VS2013. I have a globally declared struct: typedef struct data //Struct for storing search & sort run-time statistics. { int **a_collision; } data; data data1; I then allocate my memory: data1.a_collision = (int**)malloc(sizeof(int)*2); //Declaring outer array size - value/key index. for (int i = 0; i < HASH_TABLE_SIZE; i++) data1.a_collision[i] = (int*)malloc(sizeof(int)*HASH_TABLE_SIZE); //Declaring inner array size. I then

Detecting light projections in 2D space using C#

微笑、不失礼 提交于 2019-12-12 02:43:50
问题 A light source is an entity in 2D space that sits in a single coordinate. There are multiple light sources around in various locations and each gives off 8 rays of light in directions N, S, E, W, NW, NE, SW, SE . The coordinates of all lights are known. Given a random point (x, y) , I need to determine if it is being hit by a ray of light. int width = 10000; int height = 10000; List<Point> lights = a bunch of randomly placed light sources. Point position = new Point(8888, 5555); Now I need to

Is there a 2D graphics API with both pixel perfect drawing and 2D hardware acceleration? [closed]

被刻印的时光 ゝ 提交于 2019-12-12 02:37:04
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . We are in the first stages of making a 2D game at the moment, which will focus on destructible environments and objects. However, we have already encountered serious problems with the choice of the right graphics API At the moment, we use SDL - but the problem we see with it is that it isn't really performant,

Displaying this symbol ╠ instead of desired characters

≡放荡痞女 提交于 2019-12-12 02:35:59
问题 Here is a snippet of some code. Instead of displaying the characters I am checking for, ╠ is displayed. while (c!= EOF) { c = getc(fp); if (c==32 || c==33 || (c>=97 && c<=122) || c==35) j++; if(j==clns){ i++; j=0; mA[i][j]=c; } } for (i = 0; i < 10; i++) { for (j = 0; j < 20; j++) { printf("%c", mA[i][j]); } printf("%c\n", mA[i][j]); } Thanks in advance for your help. :) 回答1: You are only ever writing to mA[i][0] : if(j==clns){ i++; j=0; mA[i][j]=c; } so you are printing random garbage that

Optimizing OpenGl Rotation of a 2D grayscale image on iphone

会有一股神秘感。 提交于 2019-12-12 02:33:25
问题 I am rotating an image on the iPhone. It is a full size grayscale image (3264 by 2448 on the 4s). OpenGl appears to be roughly twice as fast as core graphics by my measurements, running about 1.22 seconds as opposed to 2.6 seconds. But this is not fast enough for my needs, I need sub-second rotation, if it is possible. (If not, we go to Plan B which involves rotating a subsection of the image, which is more elegant perhaps but has it's own issues.) I should make clear that this only for

How to multiply two quaternions by python or numpy [duplicate]

烈酒焚心 提交于 2019-12-12 02:10:02
问题 This question already has answers here : Creating uniform random quaternion and multiplication of two quaternions (2 answers) Closed 3 years ago . I have two quaternions: Q1= w0, x0, y0, z0 and Q2 = w1, x1, y1, z1. I would like to multiply them by using NumPy or Python function which can return 2-d array. I found some pseudocodes on the internet which is written by Christoph Gohlke to do this kind of multiplication. I tried a lot but failed to apply it. Can anyone help me please to do this

Draw multiple pie charts in Activity of Android

时光怂恿深爱的人放手 提交于 2019-12-12 02:09:22
问题 Now I'm doing a project which need draw multiple pie charts with text. Can anyone give me some ideas, I use a ListView or loop TextView to achieve this. And, how can I have multiple canvases in one Activity. Cheers!! multiple pie charts with text 回答1: You can create a custom view which draws the pie chart. And create a layout which holds the pie chart view and textviews. Use this layout for the row layout of listview. If you need help drawing piechart, this will give an idea https://github

Simple 2d array java game

微笑、不失礼 提交于 2019-12-12 01:29:16
问题 I'm trying to write a simple game in Java that creates a grid of dots using a 2d array for the user to move on. I've done that and I've gotten to the point where I'm asking the user for their movement selection, however, after that happens I want to reprint the grid with their old space empty, and with the 'o' in the space they moved to. I'm unsure how to go about reprinting the grid though, as when I first printed it I used an if statement to tell the loop where to not put dots. I'll post

How to change MovieClip transparency based on mouse position?

别等时光非礼了梦想. 提交于 2019-12-12 00:07:07
问题 So, I'm trying to make a grid of rectangles each get more transparent the closer the mouse is to it. Using some basic maths, I thought I had got it, but instead it seems I got a weird graphic bug(maybe?) shown here: The middle of the rings is where the mouse is. Part of code that deals with transparency: private function update(e:Event = null):void { for (var i:int = 0; i < buttons.length; i++) { lightFact = getDistance(buttons[i]) lightBrightness = lightPower - (lightFact * 10) buttons[i]

Wrong repositioning circle after collision with segment with a vector algorithm

隐身守侯 提交于 2019-12-11 23:58:16
问题 In a 2D game, i'm trying to repositionate a circle after it passed through a segment. Taking the picture as example situation, i need to reposition back the circle so that B will become the tangent point on the circle. The informations that i have are: x,y of the circle Radius of the circle dirx, diry: Direction of x,y the circle is having Distance between A and B What i'm doing is to calculate the coordinates of point C, then coordinates of point B, and then subtract vector AB from AC