Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualIgnifex

Posted 09 October 2012 - 04:48 AM

I first noticed that your triangle is not interpolating between red, green and blue, but between cyan, magenta en yellow. So somewhere your colors are being "reversed".

Your problem is indeed in the code fragment you have shown below. The interpolation between corner points does not depend linearly on the distance, but the inverse of it. If the distance to your red point (d0) is very small, your "red weight" should be high.

You can have a look at Barycentric coordinates, which seem to most closely match what you are doing.

#2Ignifex

Posted 09 October 2012 - 04:47 AM

I first noticed that your triangle is not interpolating between red, green and blue, but between cyan, magenta en yellow. So somewhere your colors are being "reversed".

Your problem is indeed in the code fragment you have shown below. The interpolation between corner points does not depend linearly on the distance, but the inverse of it. If the distance to your red point (d0) is very small, your "red weight" should be high. Perhaps all you need to do is to normalize the distances (so that their sum equals 1), and use (2/3 - d0) as a weight.

You can have a look at Barycentric coordinates, which seem to most closely match what you are doing.

#1Ignifex

Posted 09 October 2012 - 04:44 AM

I first noticed that your triangle is not interpolating between red, green and blue, but between cyan, magenta en yellow. So somewhere your colors are being "reversed".

Your problem is indeed in the code fragment you have shown below. The interpolation between corner points does not depend linearly on the distance, but the inverse of it. If the distance to your red point (d0) is very small, your "red weight" should be high. Perhaps all you need to do is to normalize the distances (so that their sum equals 1), and use (1-d0) as a weight.

You can have a look at Barycentric coordinates, which seem to most closely match what you are doing.

PARTNERS