linear-interpolation

How to properly blend colors across two triangles and remove diagonal smear

纵饮孤独 提交于 2020-05-09 06:25:08
问题 I am learning WebGL and I've drawn a full screen quad with colors for each vertex. No lighting or normals or perspective matrix or depth buffer; I'm just drawing a gradient background. This is what I get: It looks good but I cannot help noticing the diagonal smear from the bottom right to the top left. I feel this is an artifact of linear interpolating the far opposite vertices. I'm drawing two triangles: the bottom left, and the top right. I think I would get similar results using OpenGL

Using MATLAB linspace between every element in an array

ぐ巨炮叔叔 提交于 2020-01-11 09:55:10
问题 Using MATLAB, I would like to linearly interpolate between every point in an array. Using interpolate will do it in a non-linear fashion. What I want to do is similar to producing low-pass filter coefficients. I have come up with a solution, but I would like to avoid using for loops: a=[0 0 1 0 0]; %Input matrix N=5; %Number of points to be added b=[]; for i=1:length(a)-1 b=[b linspace(a(i),a(i+1),N)]; end Is it possible to do this without a loop? 回答1: You can create a linear spline with the

How to interpolate points between two irregular sets of data?

丶灬走出姿态 提交于 2019-12-30 08:12:17
问题 I'm sorry for the somewhat confusing title, but I wasn't sure how to sum this up any clearer. I have two sets of X,Y data, each set corresponding to a general overall value. They are fairly densely sampled from the raw data. What I'm looking for is a way to find an interpolated X for any given Y for a value in between the sets I already have. The graph makes this more clear: In this case, the red line is from a set corresponding to 100, the yellow line is from a set corresponding to 50. I

linear interpolate missing values in time series

感情迁移 提交于 2019-12-30 04:47:07
问题 I would like to add all missing dates between min and max date in a data.frame and linear interpolate all missing values, like df <- data.frame(date = as.Date(c("2015-10-05","2015-10-08","2015-10-09", "2015-10-12","2015-10-14")), value = c(8,3,9,NA,5)) date value 2015-10-05 8 2015-10-08 3 2015-10-09 9 2015-10-12 NA 2015-10-14 5 date value approx 2015-10-05 8 8 2015-10-06 NA 6.33 2015-10-07 NA 4.67 2015-10-08 3 3 2015-10-09 9 9 2015-10-10 NA 8.20 2015-10-11 NA 7.40 2015-10-12 NA 6.60 2015-10

How to get t for average distance of Bézier curve

自作多情 提交于 2019-12-24 15:33:05
问题 I am calculating the interpolation position of Bézier curve by using the formula: pow(1 - t, 2) * start + 2.0 * (1 - t) * t * control + t * t * end The problem is that if I linear step the t by for example 0.1 per segment, the length of segment on the Bézier curve is not average. Is there any way to get the corresponding array of t for getting average or approximately average length of the segment on the curve. 回答1: It seems you want an approximate parametrization by arc length. For the

Linear interpolation: calculate correction based on 2D table

扶醉桌前 提交于 2019-12-24 12:43:56
问题 I try to do a thing that should be nothing more than a two-dimensional, linear interpolation but currently I fail finding the correct approach. To describe the problem a bit simplified: there is a drawing area with a size of 3000x3000 pixels where I have to draw e.g. a horizontal line. To do that I'm drawing dots or short lines from every pixel position to the next pixel position which then forms a line. Now a correction has to be applied to the whole thing where correction information can be

Cubic/Curve Smooth Interpolation in C# [closed]

淺唱寂寞╮ 提交于 2019-12-20 19:37:52
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . Below is a cubic interpolation function: public float Smooth(float start, float end, float amount) { // Clamp to 0-1; amount = (amount > 1f) ? 1f : amount; amount = (amount < 0f) ? 0f : amount; // Cubicly adjust the amount value. amount = (amount * amount) * (3f - (2f * amount)); return (start + ((end - start) *

R: Interpolation of NAs by group

北城以北 提交于 2019-12-17 19:53:12
问题 I would like to perform a linear interpolation in a variable of a data frame which takes into account the: 1) time difference between the two points, 2) the moment when the data was taken and 3) the individual taken for measure the variable. For example in the next dataframe: df <- data.frame(time=c(1,2,3,4,5,6,7,1,2,3), Individuals=c(1,1,1,1,1,1,1,2,2,2), Value=c(1, 2, 3, NA, 5, NA, 7, 5, NA, 7)) df I would like to obtain: result <- data.frame(time=c(1,2,3,4,5,6,7,1,2,3), Individuals=c(1,1,1

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

Floating point linear interpolation

99封情书 提交于 2019-12-17 15:36:25
问题 To do a linear interpolation between two variables a and b given a fraction f , I'm currently using this code: float lerp(float a, float b, float f) { return (a * (1.0 - f)) + (b * f); } I think there's probably a more efficient way of doing it. I'm using a microcontroller without an FPU, so floating point operations are done in software. They are reasonably fast, but it's still something like 100 cycles to add or multiply. Any suggestions? n.b. for the sake of clarity in the equation in the