2d

Two dimensional unordered_map

人走茶凉 提交于 2019-12-10 21:34:42
问题 typedef boost::unordered_map<int, void*> OneDimentionalNodes; typedef boost::unordered_map<int, OneDimentionalNodes> TwoDimentionalNodes; TwoDimentionalNodes nodes; is this valid? i don't use any hash functions since keys of the unordered_maps' are single integers. it compiles, but when i iterate it like this, it crashes while trying to access this->hash_function()(k); for (TwoDimentionalNodes::iterator it= nodes.begin(); it != nodes.end() ; ++it) { for(OneDimentionalNodes::iterator it2 =

Is drawing through the Canvas class hardware accelerated on Android?

你说的曾经没有我的故事 提交于 2019-12-10 20:56:39
问题 Are calls to Canvas.drawPath()/drawArc()/etc hardware accelerated, passed to a device native implementation or implemented in Java? Or is OpenGL the only way to achieve hardware accelerated drawing? I am trying to determine if it is feasible to use the Canvas API for realtime animation. 回答1: currently Canvas is not hardware accelerated. there are hints in the source code which point to the plans of implementing wrapping canvas calls around so HW accelerator, but it's not functional as of now.

How to determine the projection (2D or 3D) of a matplotlib axes object?

送分小仙女□ 提交于 2019-12-10 20:55:50
问题 In Python's matplotlib library it is easy to specify the projection of an axes object on creation: import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D ax = plt.axes(projection='3d') But how do I determine the projection of an existing axes object? There's no ax.get_projection , ax.properties contains no "projection" key, and a quick google search hasn't turned up anything useful. 回答1: I don't think there is an automated way, but there are obviously some properties that

OpenGL drawing thousands of 2D circles

余生长醉 提交于 2019-12-10 20:51:45
问题 In my application, I am rendering thousands (~10k) 2D circles on top of a 3D scene. I have it working, but the performance is very slow when there are this many circles (the circles are small, ~16 pixels diameter). My code for drawing the circles looks like: for ( int i = 0; i < numCircles; i++) { int attributeMask = GL.GL_DEPTH_BUFFER_BIT | GL.GL_TRANSFORM_BIT | GL.GL_VIEWPORT_BIT | GL.GL_CURRENT_BIT | GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_ENABLE_BIT | GL.GL_LIGHTING_BIT;

Sprite sheet generator for iPhone? [closed]

被刻印的时光 ゝ 提交于 2019-12-10 19:58: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 6 years ago . Until now I have been making my own 1024*1024 sprite sheets by placing the images in an 64 x 64 grid to help to identify easily the position and size of each sprite. Needless to say, it works but i'm wasting a lot of space. Is there any kind of tool to help me take separate sprites in .png format and generate

Perfect circle to perfect circle and Perfect circle to straight line collision HANDLING in Java

帅比萌擦擦* 提交于 2019-12-10 19:54:18
问题 I am a newbie at Java, but decided to make a application that has a bunch of balls bouncing around. Please keep in mind that I know almost nothing about normals, which I have seen mentioned a lot in this kind of thread. I have also only take Algebra 1, and know a little bit of trig (sin, cosin and tangent). Anyways... I have collision detection covered, using if (java.awt.geom.Point2D.distance(X1, Y1, X2, Y2) < ball1.radius + ball2.radius) {return true;} else {return false;} and if (ball.x +

How to create 2D arrays in Python

丶灬走出姿态 提交于 2019-12-10 18:42:32
问题 Im trying to create an indexed 2D array within Python, but I keep running into errors, one way or another. The following code: #Declare Constants (no real constants in Python) PLAYER = 0 ENEMY = 1 X = 0 Y = 1 AMMO = 2 CURRENT_STATE = 3 LAST_STATE = 4 #Initilise as list information_state = [[]] #Create 2D list structure information_state.append([PLAYER,ENEMY]) information_state[PLAYER].append ([0,0,0,0,0])#X,Y,AMMO,CURRENT_STATE,LAST_STATE information_state[ENEMY].append([0,0,0,0,0])#X,Y,AMMO

C function that takes const 2d array

这一生的挚爱 提交于 2019-12-10 17:33:34
问题 I want to write a C function that takes a dynamic 2D array as an input, but doesn't alter the array. I'm trying to be const correct, not only to make my code clearer, but because my functions are going to be called from within C++ code, and C++ is pretty persnickety about these things. How do I declare a function to take 'const' pointer to a pointer, i.e. how do I indicate that the function will not alter the contents of the 2d array? What follows is a specific, super-simple example. I'm

Transparent circular dialog in Java

别来无恙 提交于 2019-12-10 16:55:28
问题 I'm building a Poker Odds Calc app in Java. I want to select a new card by clicking the card's placeholder which is basically an extended JPanel that I "draw" the card's face and has a mouseListener. What I have imagined to do is that when I clicked the card, I would like a round menu to pop up around the mouse cursor having a circle in the middle cut in four with each suite in a quarter and a ring around it cut in thirteen for the value of the card. Then I will select suit and value and it

Appropriate Transformation for 3D-looking 2D drawing (Java)

∥☆過路亽.° 提交于 2019-12-10 16:38:28
问题 I'm looking for the appropriate transformation to make a 2D image look like a 3D drawing. If I draw a "road" with parallel lines on a sheet of paper, and then tilt the top of the page away from you, so that the road appears to be disappearing into the distance is what I am looking for. I'm using Java and would like an appropriate API/library. I don't believe "AffineTransformation" accomplishes this. 回答1: You don't want an AffineTransformation, as that will always preserve parallel lines,