2d

How do I create 2d object collision from every side(top,left,bottom,right) properly

霸气de小男生 提交于 2019-12-23 04:10:54
问题 Just adding this for the people not looking to read a whole bunch of text, at least read this and look at the picture to understand my question; I have collision set up between the "player" and "objects", so that when the "player" hits the "Left" of the "object" the "player" is put to the "Left" of the "object". (this is what i want). But I would like the player to be able to hit any side ("top","left","right","bottom") of the object and be placed appropriately. So looking at the image above,

Reallocation of contiguous 2D array

偶尔善良 提交于 2019-12-23 01:59:08
问题 I am generating contiguous 2d arrays using the method posted on here by Shawn Chin.[1][2] It works very well. Briefly from his post: char** allocate2Dchar(int count_x, int count_y) { int i; # allocate space for actual data char *data = malloc(sizeof(char) * count_x * count_y); # create array or pointers to first elem in each 2D row char **ptr_array = malloc(sizeof(char*) * count_x); for (i = 0; i < count_x; i++) { ptr_array[i] = data + (i*count_y); } return ptr_array; } And the following free

Variadic C function printing multiple 2-D char arrays

家住魔仙堡 提交于 2019-12-23 01:24:39
问题 I need to set up a variadic function in C that prints a variable number of 2-D char arrays side-by-side. I'm having a hard time figuring out how to initialize the boards variable with va_arg() . The key problematic line is: boards[i] = va_arg(ap, char*[][BOARDSIZE]); The line produces a compiler error (currently, Second argument to 'va_arg' is of incomplete type 'char *[][10]' ), but basically I'm sure I'm not doing something right. I'm just not sure what that something is. I've tried several

Infinite Scrolling Background in XNA

狂风中的少年 提交于 2019-12-22 13:05:08
问题 I'm drawing a ground texture in a sidescrolling platformer like this: spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, _camera.GetViewMatrix(Parallax)); foreach (Sprite sprite in Sprites) sprite.Draw(spriteBatch); spriteBatch.End(); In Sprite.Draw() public void Draw(SpriteBatch spriteBatch) { if (Texture != null) spriteBatch.Draw(Texture, Position, new Rectangle(0, 0, Texture.Width, Texture.Height), Color.White, Rotation, Origin, Scale, SpriteEffects.None, ZIndex); }

Infinite Scrolling Background in XNA

柔情痞子 提交于 2019-12-22 13:03:59
问题 I'm drawing a ground texture in a sidescrolling platformer like this: spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, _camera.GetViewMatrix(Parallax)); foreach (Sprite sprite in Sprites) sprite.Draw(spriteBatch); spriteBatch.End(); In Sprite.Draw() public void Draw(SpriteBatch spriteBatch) { if (Texture != null) spriteBatch.Draw(Texture, Position, new Rectangle(0, 0, Texture.Width, Texture.Height), Color.White, Rotation, Origin, Scale, SpriteEffects.None, ZIndex); }

Python lmfit: Fitting a 2D Model

冷暖自知 提交于 2019-12-22 12:29:13
问题 I'm trying to fit a 2D-Gaussian to some greyscale image data, which is given by one 2D array. The lmfit library implements a easy-to-use Model class, that should be capable of doing this. Unfortunately the documentation (http://lmfit.github.io/lmfit-py/model.html) does only provide examples for 1D fitting. For my case I simply construct the lmfit Model with 2 independent variables. The following code seems valid for me, but causes scipy to throw a "minpack.error: Result from function call is

2D histogram with Python

烂漫一生 提交于 2019-12-22 10:16:52
问题 I'm trying to plot a 2D histogram in Python using these code from math import * import pylab as p import matplotlib.pyplot as plt import numpy as np x=part.points[:,0] y=part.points[:,1] z=part.points[:,2] H, xedges, yedges = np.histogram2d(x, y, bins=(128,128)) H.shape, xedges.shape, yedges.shape extent = [yedges[0], yedges[-1], xedges[-1], xedges[0]] plt.imshow(H, extent=extent, interpolation='nearest') plt.colorbar() plt.xlabel("x") plt.ylabel("y") plt.show() Every thing works fine: I have

How to decode U.P.S. Information from UPS MaxiCode Barcode?

守給你的承諾、 提交于 2019-12-22 09:25:09
问题 I recently purchased a 2D Barcode reader. When scanning a U.P.S. barcode, I get about half of the information I want, and about half of it looks to be encrypted in some way. I have heard there is a UPS DLL. Example - Everything in bold seems to be encrypted, while the non-bold text contains valuable, legitimate data. [)>01961163522424800031Z50978063UPSN12312307G:%"6*AH537&M9&QXP2E:)16(E&539R'64O In other words, this text seems OK - and I can parse the information [)

Ray-Polygon Intersection Point on the surface of a sphere

試著忘記壹切 提交于 2019-12-22 07:58:30
问题 I have a point (Lat/Lon) and a heading in degrees (true north) for which this point is traveling along. I have numerous stationary polygons (Points defined in Lat/Lon) which may or may not be convex. My question is, how do I calculate the closest intersection point, if any, with a polygon. I have seen several confusing posts about Ray Tracing but they seem to all relate to 3D when the Ray and Polygon are not on the same Plane and also the Polygons must be convex. 回答1: sounds like you should

Bound CUDA texture reads zero

只谈情不闲聊 提交于 2019-12-22 06:40:53
问题 I try to read values from a texture and write them back to global memory. I am sure the writing part works, beause I can put constant values in the kernel and I can see them in the output: __global__ void bartureKernel( float* g_odata, int width, int height) { unsigned int x = blockIdx.x*blockDim.x + threadIdx.x; unsigned int y = blockIdx.y*blockDim.y + threadIdx.y; if(x < width && y < height) { unsigned int idx = (y*width + x); g_odata[idx] = tex2D(texGrad, (float)x, (float)y).x; } } The