2d

How to get 1D column array and 1D row array from 2D array? (C# .NET)

戏子无情 提交于 2020-01-23 05:00:34
问题 i have double[,] Array; . Is it possible to get something like double[] ColumnArray0 = Array[0,].toArray() and double[] RowArray1 = Array[,1].toArray() without making a copy of every elemet(using for)? Thanks. 回答1: Arrays are a memory area where all entries are stored in a consecutive way. Depending on the data layout in memory this is only possible for either rows or columns. Instead of the 2d array double[,] type it is in your case better to use an array of arrays double[][] double[][]

operator overloading [][] 2d array c++

杀马特。学长 韩版系。学妹 提交于 2020-01-22 15:04:27
问题 I have a 2D array and I want to define a function that returns the value of the index that the user gives me using operator overloading. In other words: void MyMatrix::ReturnValue() { int row = 0, col = 0; cout << "Return Value From the last Matrix" << endl; cout << "----------------------------------" << endl; cout << "Please Enter the index: [" << row << "][" << col << "] =" << ((*this).matrix)[row][col] << endl; } The operation ((*this).matrix)[row][col] should return an int . I have no

How to determine path from noisy X, Y data

心不动则不痛 提交于 2020-01-22 11:46:33
问题 I have an unsorted list of noisy X, Y points. They do, however, form a path through the world. I would like an algorithm to draw an approximation of this data using line segments. This is similar to how you would use a line -fitting algorithm to pick an approximation of linear data. My problem is only harder because the path bends and winds around the world. alt text http://www.praeclarum.org/so/pathfinder.png Does anyone know of any standard / robust / easy to comprehend algorithms to

Why will my image not move?

狂风中的少年 提交于 2020-01-22 03:42:29
问题 I am making a 2d top-down game where the player controls a cat. To do this, the person uses the WASD keys to move. I have Form1, GameManager, Cat, and Moveable classes. Form1 sends GameManager the cat imagelist and e.graphics (for the picturebox). GameManager has a timer and each tick checks to see if the cat has moved. Cat handles the move logic. When I run the program, the cat sprite shows up at its initial position, but does not move upon pressing a key. I can't figure out my issue, could

Mouse hover canvas/shape

那年仲夏 提交于 2020-01-20 09:22:11
问题 I have this code on in Jquery. I would like to change the opacity percentage of the individual shapes on mouseover. I normaly don't have this kind of problems, but I don't know a lot about canvas... Any help/advice would be appreciate! Thanks in advance! var canvas = document.getElementById('canvas'); if (canvas.getContext) { var ctx = canvas.getContext('2d'); ctx.canvas.addEventListener('mousemove', function(event){ var mouseX = event.clientX; var mouseY = event.clientY; var status =

Mouse hover canvas/shape

≯℡__Kan透↙ 提交于 2020-01-20 09:17:55
问题 I have this code on in Jquery. I would like to change the opacity percentage of the individual shapes on mouseover. I normaly don't have this kind of problems, but I don't know a lot about canvas... Any help/advice would be appreciate! Thanks in advance! var canvas = document.getElementById('canvas'); if (canvas.getContext) { var ctx = canvas.getContext('2d'); ctx.canvas.addEventListener('mousemove', function(event){ var mouseX = event.clientX; var mouseY = event.clientY; var status =

Mouse hover canvas/shape

会有一股神秘感。 提交于 2020-01-20 09:17:46
问题 I have this code on in Jquery. I would like to change the opacity percentage of the individual shapes on mouseover. I normaly don't have this kind of problems, but I don't know a lot about canvas... Any help/advice would be appreciate! Thanks in advance! var canvas = document.getElementById('canvas'); if (canvas.getContext) { var ctx = canvas.getContext('2d'); ctx.canvas.addEventListener('mousemove', function(event){ var mouseX = event.clientX; var mouseY = event.clientY; var status =

Matplotlib Save imshow array

半腔热情 提交于 2020-01-20 09:09:05
问题 I was wondering if it were at all possible to save the array of an imshow function? What do I mean by this? Well, I have a 2d array with unique values. I would like to see that represented in colour, so I naturally would use the imshow function. I understand that the imshow function applies a colormap to my array and then displays that. I would like to be able to get the array that matplotlib uses to show my original 2d array in colour. Can this be done? 回答1: You can actually just get the

Trying to make a “solid” block in pygame but it doesnt work

 ̄綄美尐妖づ 提交于 2020-01-17 20:21:33
问题 Hopefully you can help me, i have been struggling with this problem for the last few days. I want to make a "solid" block for my 2d platformer game that i am working on but when i go into that "solid" block i teleport to the other side or to the bottom of the block, i dont know why, hopefully you know why So here is my code: class Block(pygame.sprite.Sprite): def __init__(self, color = blue,widht = 64, height = 64): super(Block, self).__init__() self.image = pygame.Surface((widht, height))

Point Outside of Area Which is Closest to Point Inside?

∥☆過路亽.° 提交于 2020-01-16 04:29:06
问题 I have a program where an entity moves around in two-dimensional space. To move one step, the entity picks its next point, and then sets it as his current point. Sometimes, however, the entity's next point lies in an Area (java.awt.geom.Area) that is forbidden (the "forbidden area" is actually a velocity obstacle). How can the entity pick the point outside the Area which is closest to the entity's preferred point? The Area is composed of different shapes (sometimes, the shapes are not