int Electra2D::Collision() { for (std::list<Entity>::iterator affecting = entities.begin(); affecting != entities.end(); ++affecting) { for (std::list<Entity>::iterator affected = entities.begin(); affected != entities.end(); ++affected) { if (affecting->type == DrawTypes::Circle && affected->type == DrawTypes::Circle && affecting->object->id != affected->object->id) { float distance = affected->pos.getDistance(affecting->pos); float limit = ((ObjectCircle*)affected->object)->radius + ((ObjectCircle*)affecting->object)->radius; if (distance <= limit) { Vector2 SP = affected->velocity ..

#### Category : 2d

Is there a formula to draw, for example, a (100 * 200) rectangle on (10, 10) (regular 2D ortho coordinate) using opengl? I have found no real define answers to this question on internet apart from this post. public: float pixelToScreenX(int screen_width, int width, int x) { return (2.0 * tan(0.5 * width) * -1) ..

So I’m working on a project where I need to find the largest contiguous region of a 2D array that has the same element. So far I’ve tried to use two for loops but haven’t been able to get the results I want. Any help would be greatly appreciated. Here’s the code I’ve tried so ..

#include<iostream> using namespace std; int add(int x[2][2], int y[2][2],int z[2][2]); int main() { int a[2][2], b[2][2]; cout << "Enter two matrices to add them " << endl; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { cin >> a[i][j]; } } cout << endl; ..

These days I am working on a Paint App in Windows Form. I created my own variation of TaW’s code for live painting on picturebox: enum ArtMode { HandDraw, Erase, Line, Rectangle, Ellipse, Circle, AutoPainter } class ArtManager { Pen pen; public void Draw(PaintEventArgs G, List<ArtAction> actions) { foreach (ArtAction da in actions) { pen ..

I’m drawing a 2D tilemap using OpenGL and I will like to be able to know where the position of the mouse corresponds into my scene. This is what I currently have: To draw this screen this projection is used glm::mat4 projection = glm::perspective( glm::radians(45.0f), (float)screenWidth / (float)screenHeight, 1.0f, 100.0f ); Then this camera is ..

I’m drawing a 2D tilemap using OpenGL and I will like to be able to know where the position of the mouse corresponds into my scene. This is what I currently have: To draw this screen this projection is used glm::mat4 projection = glm::perspective( glm::radians(45.0f), (float)screenWidth / (float)screenHeight, 1.0f, 100.0f ); Then this camera is ..

I’m trying to build a simple 2D application on the Windows Console using C++ to display various primitives so I started with the most basic one: a triangle. I can display the triangle’s outline and vertices correctly but I’m having problems with filling it. I have come across some rasterization algorithms presented here: http://www.sunshine2k.de/coding/java/TriangleRasterization/TriangleRasterization.html and ..

I have a 1 dimensional vector std::vector<int> vec1 = {4, 5, 6, 7}; and I want to store these elements in a 2 dimensional vector std::vector<std::vector<int>> vec2; but vec2 can only have height 3 and I have in vec1 – 4 elements. The output of vec2 should be: 4 7 5 6 Source: Windows Questions ..

I am currently trying to parallelise the ‘scatter’ and ‘connect’ part of 2D Transmission Line Matrix(TLM) in CUDA Programming. I require only to use x-dimension threads. I am stuck and have no idea how to program the ‘connect’ part. For example, I use 8196threads to solve 100 x 100nodes problems. My threads will be limited ..

## Recent Comments