Squirrels have fuzzy tails.

0 Members and 1 Guest are viewing this topic.

I really need to write up that linear interpolation tutorial...You don't need to store all 90 values, if you are willing to burn up some computation to calculate a y from 2 points and an x value.

/** Interpolate between two numbers* value - the current value to be used* minVal - the minimum that 'value' can be* maxVal - the maximum that 'value' can be* minRtn - the return value if 'value = minVal'* maxRtn - the return value if 'value = maxVal'* return a value in the range minRtn to maxRtn*/int interpolate(int value, int minVal, int maxVal, int minRtn, int maxRtn){ long int lRtnRange = maxRtn - minRtn; long int lValRange = maxVal - minVal; long int lRelVal = value - minVal; lRtnRange = minRtn + ( lRtnRange * lRelVal / lValRange ); return (int)lRtnRange;}

I don't think it's a good idea to interpolate sin() in a linear fashion. You can balance it, like 2/3 to first value, or 2/3 to the second one, but in the end, without a correction matrix you wouldn't get any good extra values.

'The hypotenuse is the longest side plus one third of the shortest side'.

SQRT( (side1 * side1) + (side2 * side2) ) = side1 + 1/3*side2

Should have added that the amount of error will depend on the gradient of the sin curve. So if you are looking at 85 degrees then this is near the top of the sin curve, the gradient is small, so the error is less. But if you are looking at 5 degrees, where the gradient is steeper, than the error is greater.

Quote'The hypotenuse is the longest side plus one third of the shortest side'.starting with what you said:hypotenuse = SQRT( (side1 * side1) + (side2 * side2) ) = side1 + 1/3*side2moving sqrt over:(side1 * side1) + (side2 * side2) = (side1 + 1/3*side2)^{2}breaking it all apart, because (a + b)^{2} = a^{2} + 2ab + b^{2}:side1^{2} + side2^{2} = side1^{2} + 2*side1*1/3*side2 + (1/3*side2)^{2}canceling out terms, bringing them out:side2^{2} = 2*side1*1/3*side2 + 1/3*1/3*side2^{2}getting rid of side2 and 1/3:3*side2 = 2*side1 + 1/3*side2and:3*side2 - 1/3*side2 = 2*side1is:side2*(3 - 1/3) = 2*side1so:side2 = 0.75*side1sides don't match up . . .so therefore . . . hmmmm darnit not sure what I just solved . . . lol