From 78053779ec3fde7c5d46057c2240600515e4a3eb Mon Sep 17 00:00:00 2001 From: Jonathan Hughes <10040216+jphsd@users.noreply.github.com> Date: Mon, 9 Sep 2024 17:37:59 -0700 Subject: [PATCH] Fix InvertWave bug --- wave.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/wave.go b/wave.go index 83b64eb..7c000ba 100644 --- a/wave.go +++ b/wave.go @@ -1,6 +1,9 @@ package texture -import "math" +import ( + //"fmt" + "math" +) type Wave interface { Eval(v float64) float64 @@ -9,6 +12,12 @@ type Wave interface { // Given a value in (-inf, inf) and a wavelength, return number of waves [0,inf) and t [0,lambda) for the value. func MapValueToLambda(v, lambda float64) (int, float64) { + n, l := MapValueToLambda0(v, lambda) + //fmt.Printf("v %f lambda %f n %d fl %f\n", v, lambda, n, l) + return n, l +} + +func MapValueToLambda0(v, lambda float64) (int, float64) { if v < 0 { if v > -lambda { return 0, v + lambda @@ -432,7 +441,7 @@ func NewInvertWave(src Wave) *InvertWave { } func (g *InvertWave) Eval(v float64) float64 { - return 2 - g.Src.Eval(v) + return -g.Src.Eval(v) } func (g *InvertWave) Lambda() float64 {