interpolation

Writing a paint program à la MS Paint - how to interpolate between mouse move events?

我们两清 提交于 2019-12-17 23:47:33
问题 I want to write a paint program in the style of MS Paint. For painting things on screen when the user moves the mouse, I have to wait for mouse move events and draw on the screen whenever I receive one. Apparently, mose move events are not sent very often, so I have to interpolate the mouse movement by drawing a line between the current mouse position and the previous one. In pseudocode, this looks something like this: var positionOld = null def handleMouseMove(positionNew): if mouse.button

Writing a paint program à la MS Paint - how to interpolate between mouse move events?

一世执手 提交于 2019-12-17 23:47:26
问题 I want to write a paint program in the style of MS Paint. For painting things on screen when the user moves the mouse, I have to wait for mouse move events and draw on the screen whenever I receive one. Apparently, mose move events are not sent very often, so I have to interpolate the mouse movement by drawing a line between the current mouse position and the previous one. In pseudocode, this looks something like this: var positionOld = null def handleMouseMove(positionNew): if mouse.button

What to do if I want 3D spline/smooth interpolation of random unstructured data?

徘徊边缘 提交于 2019-12-17 23:28:31
问题 I was inspired by this answer by @James to see how griddata and map_coordinates might be used. In the examples below I'm showing 2D data, but my interest is in 3D. I noticed that griddata only provides splines for 1D and 2D, and is limited to linear interpolation for 3D and higher (probably for very good reasons). However, map_coordinates seems to be fine with 3D using higher order (smoother than piece-wise linear) interpolation. My primary question: if I have random, unstructured data (where

3d geometry: how to interpolate a matrix

余生颓废 提交于 2019-12-17 23:18:03
问题 i store the position of an object in 3d space in a 4by4 transformation matrix. now in order to move the object from the position stored in matrix A to the position stored in matrix B, i would like to interpolate them. so do i just do this by interpolating each of the 16 values in the matrix, or do i have to take special care about something? thanks! 回答1: Check out Ken Shoemake and Tom Duff's Matrix Animation and Polar Decomposition . The basic idea is to break down transformation matrices

Resizing in MATLAB w/ different filters

让人想犯罪 __ 提交于 2019-12-17 21:31:59
问题 I have an image. I want to resize it to double the original size, filling in the new pixels by interpolation. I need to specify which type of interpolation I want to use. I see the imresize function, which has an option for 'method'. The problem is, there are only 3 options: nearest, bilinear, bicubic. Bilinear and bicubic are averaging/mean methods, but is there any way to set the neighborhood size / weighting? The main problem is, I need to do it with a 'median' interpolation method,

Error in calculating integral for 2D interpolation. Comparing numpy arrays

南笙酒味 提交于 2019-12-17 21:01:11
问题 My optimization task deals with calculation of the following integral and finding the best values of xl and xu : Iterations take too long, so I decided to speed them up by calculating integral for all possible values xl and xu and then interpolate calculated values during optimization. I wrote the following function: def k_integrand(x, xl, xu): return((x**2)*mpmath.exp(x))/((xu - xl)*(mpmath.exp(x)-1)**2) @np.vectorize def K(xl, xu): y, err = integrate.quad(k_integrand, xl, xu, args = (xl, xu

Interpolation between two curves (matlab)

一个人想着一个人 提交于 2019-12-17 20:38:52
问题 Ok guys. I have the following problem: I have the data of the following plot. So the data file of this plot contains three columns. The 2nd and 3rd ones the x,y points. And the 1st one is to which system those points belong. In this case the red ones are for the system of 20 years. The blue ones for the 30 years. What I want to find is the curve at 25 years. So if I plot it it should be between the red and blue curves. I have no idea how interpolate the data in order to obtain what I want.

How to interpolate a color sequence?

為{幸葍}努か 提交于 2019-12-17 19:30:05
问题 I need to interpolate or change gradually a sequence of colors, so it goes from colorA to colorB to colorC to colorD and them back to colorA, this need to be based on time elapsed in milliseconds, any help will be much appreciated (algorithms, pseudo code will be great). Note that I am working with RGB, it could be 0-255 or 0.0-1.0 range. This is what I have so far, I need to change the colors on every "timePeriod", them I calculate the percentage of time elapsed and change the colors, the

Rotation Interpolation

好久不见. 提交于 2019-12-17 17:39:40
问题 NB: I'll present this question in degrees purely for simplicity, radians, degrees, different zero-bearing, the problem is essentially the same. Does anyone have any ideas on the code behind rotational interpolation? Given a linear interpolation function: Lerp(from, to, amount), where amount is 0...1 which returns a value between from and to, by amount. How could I apply this same function to a rotational interpolation between 0 and 360 degrees? Given that degrees should not be returned

Piecewise linear integer curve interpolation in C#/Unity3D

半世苍凉 提交于 2019-12-17 17:14:11
问题 Is there a simple, efficient way to implement a piecewise linear integer-to-integer curve interpolation in C# (for Unity3D, if it matters) ? Details are as follows: The piecewise linear curve representation has to be built over time. The first interpolation request comes before we have all data points The curve is strictly monotonous The first point is always (0, 0) The data points' first coordinates are also strictly monotonous w.r.t arrival time, i.e. the points are naturally ordered by