2d

Order / Sequence of matrix transformations in 2D

柔情痞子 提交于 2019-12-02 12:16:37
问题 I have an image containing: a set of coordinates that act as orientation markers. a set of coordinates containing data. Let's call this image A. This image is fed to a scanner that returns a copy of the image with certain transformations applied (rotation, scale, translation). Let's call the transformed image B. The transformation values applied are not know to me, of course. Once I receive the transformed image (B), I can easily track the coordinates of the orientation markers and calculate

Java- How to add sum of a row in 2d array [closed]

筅森魡賤 提交于 2019-12-02 12:07:13
My problem is to add the sum of each row in a 2d array, and put those values in a new 1d array. This is my code public static int[] sumRow(int[][] N){ int[] rowSum = new int[N.length]; for(int i = 0; i<N.length;i++){ for(int j = 0; j<N[i].length; j++){ rowSum[i] = N[i][j] + N[i+1][j+1]; } } return rowSum; } But it is not working, please help. public static int[] sumRow(int[][] N){ int[] rowSum = new int[N.length]; for(int i = 0; i<N.length;i++){ rowSum[i] = 0; //<= initialize value for(int j = 0; j<N[i].length; j++){ rowSum[i] += N[i][j]; //<= sum of row } } return rowSum; } You have written

OnTriggerEnter not working

无人久伴 提交于 2019-12-02 11:09:07
问题 public var enemy:GameObject; enemy = GameObject.FindGameObjectWithTag("enemy"); function OnTriggerEnter(other:Collider) { if(other.gameObject.tag == "enemy") { Debug.Log("Dead"); Destroy(gameObject); } } This script is attached to a prefab arrow that gets instantiated. The enemy has a circle collider and the arrow has a box collider. The arrow has on IsTrigger checked. What have I done wrong? Both gameobjects have a rigidbobdy2D attached. 回答1: If you use the 2D physics engine, you need to use

c++ passing 2d arrays to funcions

痴心易碎 提交于 2019-12-02 11:06:20
问题 I know my code isnt finished yet im not asking for it to be done. It's supposed to input food eaten by 3 monkeys over a week and other stuff. But I've hit a snag. It gives me an error(Error: no operator "<<" matches these operands) when i put the cin in the poundsEaten function. Am I not passing the array right is that why it isnt working? Thanks for any help #include <iomanip> #include <iostream> using namespace std; //Global Constants const int NUM_MONKEYS = 3; const int DAYS = 7; /

Can't add multiple of same rectangle

∥☆過路亽.° 提交于 2019-12-02 09:55:31
I want to make multiple of the same rectangle on my borderPane to make walls for the game. Each wall is going to look the same and be the same size. I know the image works and that there are no other errors. I use the following code to add the rectangles: public class Antz extends Application{ public BorderPane borderPane; public Scene scene; public Image wallImage = new Image("/recources/images/walls.png"); public Rectangle wall = new Rectangle(); public int[][] walls = {{1,0,0,0,0,1,1,1,0,1,0,0,0,0,0,1,0}, {1,1,1,1,0,1,0,0,0,1,0,1,1,1,0,1,0}, {0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0}, {0,1,0,1,1,1

.FillRectangle not drawing anything

给你一囗甜甜゛ 提交于 2019-12-02 09:31:00
I'm having trouble figuring out why .FillRectangle is not working for me. Furthermore, as it's not thorwing any exception, I ran out of ideas why it could be, so I need some help here:/ The part of the code affected is this try { using (FileStream fileStream = File.OpenRead(filePath)) { using (StreamReader streamReader = new StreamReader(fileStream, Encoding.UTF8, true, 1024)) { String line; int mW = Convert.ToInt32(Math.Round(this.Size.Width / 2d)); int mH = Convert.ToInt32(Math.Round(this.Size.Height / 2d)); SolidBrush myBrush; myBrush = new SolidBrush(Color.Black); PointF A = new PointF(0f,

Collision detection 2D between rectangles

戏子无情 提交于 2019-12-02 09:17:50
问题 I am writting a collision detection engine for my game and I have some problems. Indeed, since I have several fixed rectangle and one moving (the player), I need to know which side of the fixed one was collided at first by the player, to replace him correctly. The fixed rectangle are NOT in a grid so they can be placed anywhere on the map and they can have diffents size. They are not rotated. The player class stores it's direction vector. Any idea? KiTe 回答1: In a nutshell: You'll compare the

Rotating objects in a grid (GUI, JAVA SWING)

别等时光非礼了梦想. 提交于 2019-12-02 08:38:18
Ok, so I am trying to do this tutorial: http://mathcs.slu.edu/~fritts/cse131/labs/lab9/index.html But I don't know how to rotate objects synchronized void moveDown() { } Is there any defined method for that or do I have to implement my own code? I thought about changing the shape of the object, but that would imply I have to change my current object every time, which might be a little complicated to implement. The method that calls moveDown: public void keyPressed(KeyEvent event) { int key = event.getKeyCode(); switch (key) { case KeyEvent.VK_UP: // up arrow case KeyEvent.VK_KP_UP:

Determine rotation direction /toward/ variable point on a circle

℡╲_俬逩灬. 提交于 2019-12-02 08:27:35
Given circle centre: vectorA and another Vector on the circle's perimeter:vectorB, how can you determine the shorter route for vectorB to translate to another point on the circle's perimeter that is variable:vectorC? Will the shorter route be clockwise or counter clockwise rotation? If it helps think of a clock. If the times is a random point on the clock's perimeter eg. 6, and the minute hand position is known, eg. 4. Does the hand need to rotate around the clock's centre point clockwise or counter clockwise to reach the random point (6)? See also: Vec1 = Circle centre, Vec2 = mousepos, find

C++ Zoom into the centre of the screen in 2D coordinates

拈花ヽ惹草 提交于 2019-12-02 08:15:11
I'm having difficulty working out the correct calculations in order to zoom into the centre of the screen in 2D coordinates whilst keeping everything in the correct scale. I have a vector which I use to handle moving around my map editor as follows: scroll = sf::Vector2<float>(-640.0f, -360.0f); It's set at -640.0f, -360.0f to make 0,0 the centre of the screen on initialising (based on my window being 1280x720). My zoom value ranges from 0.1f to 2.0f and it's increased or decreased in 0.05 increments: zoomScale = zoomScale + 0.05; When drawing elements on to the screen they are drawn using the