Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Lerp and int/float conversions
#4
Perhaps it was just MonoDevelop, but yeah, it was stopping me at the compilation phase...

Well, the wiki page still uses the 3 parameter version that I know!  But looking again at your code, particularly this line, because I know what it's doing now; index = (int)lerp(line, 170, Vres, 7, 0);

I can work out; lerp(cur_pos, min_pos, max_pos, min_output, max_output)

So you're converting the line position to an index in the palette based on its position between the min_pos and max_pos... I like it!  I can see how the palette output is inverted for the bottom half of the screen. Thinking back I always used to do this in a 2 step process - get the position between two points as a percentage, then use that percentage to work out the position between two other points. Now I can use this handy dandy function to do it in one line of code.
Reply


Messages In This Thread
Lerp and int/float conversions - by Domarius - 07-18-2018, 10:17 AM
RE: Lerp and int/float conversions - by Domarius - 07-18-2018, 08:30 PM
RE: Lerp and int/float conversions - by megamarc - 07-18-2018, 11:23 PM
RE: Lerp and int/float conversions - by Domarius - 07-19-2018, 08:00 AM
RE: Lerp and int/float conversions - by megamarc - 07-19-2018, 03:58 PM
RE: Lerp and int/float conversions - by Domarius - 07-19-2018, 09:18 PM
RE: Lerp and int/float conversions - by megamarc - 07-24-2018, 02:02 AM
RE: Lerp and int/float conversions - by Domarius - 07-24-2018, 08:34 PM
RE: Lerp and int/float conversions - by megamarc - 08-07-2018, 06:39 AM
RE: Lerp and int/float conversions - by Domarius - 08-08-2018, 06:44 AM
RE: Lerp and int/float conversions - by megamarc - 08-09-2018, 06:30 AM
RE: Lerp and int/float conversions - by Domarius - 08-20-2018, 04:50 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)