2d

Positioning elements in 2D space with OpenGL ES

不想你离开。 提交于 2019-12-09 06:01:44
问题 In my spare time I like to play around with game development on the iPhone with OpenGL ES. I'm throwing together a small 2D side-scroller demo for fun, and I'm relatively new to OpenGL, and I wanted to get some more experienced developers' input on this. So here is my question: does it make sense to specify the vertices of each 2D element in model space, then translate each element to it's final view space each time a frame is drawn? For example, say I have a set of blocks (squares) that make

Java slow 2D performance - Resizing

好久不见. 提交于 2019-12-09 04:50:13
问题 I am using Windows 7 with Aero, and have a very fast graphics card (Radeon 6870) that I use for gaming. I have some issues when resizing very simple programs I make with java. For instance, this program does absolutely nothing. It has no action listeners, no loops. It's simply a GUI interface with buttons. Resizing with OpenGL acceleration off: [View fullscreen] It takes about a second to resize the components. For me that's very noticeable. Resizing with OpenGL acceleration on: I have tried

Plotting a 2d Array with mplot3d

核能气质少年 提交于 2019-12-08 22:58:24
问题 I have a 2D numpy array and I want to plot it in 3D. I heard about mplot3d but I cant get to work properly Here's an example of what I want to do. I have an array with the dimensions (256,1024). It should plot a 3D graph where the x axis is from 0 to 256 the y axis from 0 to 1024 and the z axis of the graph displays the value of of the array at each entry. How do I go about this? 回答1: It sounds like you are trying to create a surface plot (alternatively you could draw a wireframe plot or a

Find neighbours outside of 2d grid which is reduced into a 1d array

♀尐吖头ヾ 提交于 2019-12-08 13:55:53
问题 I have a two dimensional grid where width and height are always the same. [0][1][2] [3][4][5] [6][7][8] I reduced it's data source into a one-dimensional array. [0][1][2][3][4][5][6][7][8] Access of elements works, but here comes the tricky part: How to know, whether a neighbour of a cell is outside the grid when still processing the one-dimensional array? For example the upper right neighbour of [5] is out of the grid but using a calculcated offset index, I will get [3]. Anyone with

Determine coordinates for an object at a specific distance and angle from a point

随声附和 提交于 2019-12-08 13:06:28
In a 2d space, I have an object of coordinates x1 and y1 and it is facing a specific direction , we'll call it "viewer". At start, the angle that measures the object rotation is 0, so the object starts always facing the same way. The angle is measured by a variable called yrot. let D be the distance from the object determined by sqrt ((x1-x2)^2 + (y1-y2)^2), consider this distance known. Now, knowing the viewer coordinates, the D distance and the yrot angle I want to determine the coordinates x2, y2 of the object that is at distance D from the viewer object's face. To clarify this I will add a

Convert an array to a 2D array (Square matrix) in javascript

痞子三分冷 提交于 2019-12-08 12:02:19
问题 I have got a little function in javascript and I want to split an array A into a 2d array. I will be used for square matrices. Obviously,I want it to be 2x2 if a square matrix of 2x2 is in the input and so on for 3x3 and. But I'm stuck after having read a first row.So my arr rows are repeated. Does anyone have any ideas about how I can get the next rows read properly.So,for instance,lets say I do have an array A = [2,1,4,5,1,2,3,1,9] Then I want my array arr to look like this: arr = [[2,1,4],

Reallocation of contiguous 2D array

淺唱寂寞╮ 提交于 2019-12-08 11:14:37
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 function: void free2Dchar(char** ptr_array) { if (!ptr_array) return; if (ptr_array[0]) free(ptr_array

How to make all my bullets remove intersected objects

爱⌒轻易说出口 提交于 2019-12-08 10:26:30
问题 I am creating a game were rectangles fall and user shoots at the rectangles when the bullet(a rectangle) intersects the falling rectangle it is removed from the arraylist. The problem now is that when I rapidly click my mouse and the bullets are on the fly they intersect but do not remove any shape except for the last bullet in motion. Please can someone help me correct this error . //class that creates sprite & background class CreateImage extends JPanel implements MouseListener{ ArrayList

JAVA : How can I represent a 2D character array as a String using a toString ?

只谈情不闲聊 提交于 2019-12-08 10:05:18
问题 I am making a program using the LRV(Least recently visited) Algorithm. Basically, I design the algorithm for a robot to traverse through a grid (which is a 2D char array). The robot whilst traversing the grid checks whether each cell is either EMPTY (defined by '-'), OCCUPIED ( defined by 'O' ) or BLOCKED (defined by 'X'). The cells can only be occupied by an object known as Sensor (this has its own class). BLOCKED cells cannot be traversed on. Each time the robot must move, it receives a

Convert 2D planes to 3D model

谁说我不能喝 提交于 2019-12-08 09:55:02
问题 We have a multiple 2D planar image of an object scanned from a fan-beam perspective. An example is in Fig 5 below. We have multiple grainy dotted planes to scan the whole image. The issue with these images is that they cannot be directly mapped to a 3D plane due to the fan beam deformation. Is there correction algorithms/methods that can be recommended so that these planes can be correctly mapped to 3D plane and an object can be reconstructed properly? 回答1: Depending on how you store your