2d

How to select a line

谁说我不能喝 提交于 2019-12-17 17:07:57
问题 So I'm trying to figure out how to implement a method of selecting lines or edges in a drawing area but my math is a bit lacking. This is what I got so far: A collection of lines, each line has two end points (one to start and one to end the line) The lines are drawn correctly on a canvas Mouse clicks events are received when clicking the canvas, so I can get the x and y coordinate of the mouse pointer I know I can iterate through the list of lines, but I have no idea how to construct an

Curve fitting with y points on repeated x positions (Galaxy Spiral arms)

匆匆过客 提交于 2019-12-17 16:53:10
问题 I currently have a MATLAB program which takes RGB images of traced spiral arms from galaxies and selects the biggest arm component and plots only that. I have tried using matlab's built in curve fitting tool with smoothing spline to fit it and I get the following result: I have tried using interp1 with parametric fitting to only get bad results. Is there a way to fit this type of curve at all? 回答1: Your fail is due to that you handle your 2D curve as function which is not the case (you got

Allocate 2D Array on Device Memory in CUDA

人走茶凉 提交于 2019-12-17 15:36:36
问题 How do I allocate and transfer(to and from Host) 2D arrays in device memory in Cuda? 回答1: I found a solution to this problem. I didn't have to flatten the array. The inbuilt cudaMallocPitch() function did the job. And I could transfer the array to and from device using cudaMemcpy2D() function. For example cudaMallocPitch((void**) &array, &pitch, a*sizeof(float), b); This creates a 2D array of size a*b with the pitch as passed in as parameter. The following code creates a 2D array and loops

Random points inside a parallelogram

非 Y 不嫁゛ 提交于 2019-12-17 10:16:11
问题 I have a 4 side convex Polygon defined by 4 points in 2D, and I want to be able to generate random points inside it. If it really simplifies the problem, I can limit the polygon to a parallelogram, but a more general answer is preferred. Generating random points until one is inside the polygon wouldn't work because it's really unpredictable the time it takes. 回答1: A. If you can restrict your input to parallelogram, this is really simple: Take two random numbers between 0 and 1. We'll call

Closest point to a given point

本秂侑毒 提交于 2019-12-17 08:59:46
问题 I have a set K of randomly selected pixels in a 2D image. For every other pixel in the image I need to find out which pixel in set K is closest to it (using the standard sqrt(dx^2 + dy^2) measure of distance). I am aware that there may be more than one solution for each pixel. Obviously it can be done by brute force against every pixel in the set, but I'd rather avoid this as it's not efficient. Any other good suggestions? Cheers. 回答1: Don't forget that you don't need to bother with the

fast 2dimensional histograming in matlab

不想你离开。 提交于 2019-12-17 07:32:25
问题 I have written a 2D histogram algorithm for 2 matlab vectors. Unfortunately, I cannot figure out how to vectorize it, and it is about an order of magnitude too slow for my needs. Here is what I have: function [ result ] = Hist2D( vec0, vec1 ) %Hist2D takes two vectors, and computes the two dimensional histogram % of those images. It assumes vectors are non-negative, and bins % are the integers. % % OUTPUTS % result - % size(result) = 1 + [max(vec0) max(vec1)] % result(i,j) = number of pixels

fast 2dimensional histograming in matlab

对着背影说爱祢 提交于 2019-12-17 07:32:06
问题 I have written a 2D histogram algorithm for 2 matlab vectors. Unfortunately, I cannot figure out how to vectorize it, and it is about an order of magnitude too slow for my needs. Here is what I have: function [ result ] = Hist2D( vec0, vec1 ) %Hist2D takes two vectors, and computes the two dimensional histogram % of those images. It assumes vectors are non-negative, and bins % are the integers. % % OUTPUTS % result - % size(result) = 1 + [max(vec0) max(vec1)] % result(i,j) = number of pixels

Image to ASCII art conversion

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 03:21:12
问题 Prologue This subject pops up here on SO from time to time, but is removed usually because of being a poorly written question. I saw many such questions and then silence from the OP (usual low rep) when additional info is requested. From time to time if the input is good enough for me I decide to respond with an answer and it usually gets a few up-votes per day while active but then after a few weeks the question gets removed/deleted and all starts from the beginning. So I decided to write

Sending and receiving 2D array over MPI

本小妞迷上赌 提交于 2019-12-17 02:33:09
问题 The issue I am trying to resolve is the following: The C++ serial code I have computes across a large 2D matrix. To optimize this process, I wish to split this large 2D matrix and run on 4 nodes (say) using MPI. The only communication that occurs between nodes is the sharing of edge values at the end of each time step. Every node shares the edge array data, A[i][j], with its neighbor. Based on reading about MPI, I have the following scheme to be implemented. if (myrank == 0) { for (i= 0 to x)

UNITY touch position to world position 2D

只愿长相守 提交于 2019-12-14 03:47:50
问题 How can I transform the touch position (On phones) to world position. For instance if my phone's screen size is 1440 by 2560 and my touch position on the phone is X 600 Y 700. How can I transform that position to world position on unity? I need that so I can know where the user put his finger. 回答1: There is a method that already does that for you. Have a look at Camera.ScreenToWorldPoint. Once you have a reference to the desired camera you can use it like this: Vector2 touchPos = Input