From c9daae367f07ff9dbdb2bf5078aa2dc1d59cefb0 Mon Sep 17 00:00:00 2001 From: alex-eg Date: Fri, 9 Oct 2026 18:16:06 +0300 Subject: [PATCH] write the noise constants the C# divides as divisions A define's body is walked and parenthesised now (sex#55). The four written as divisions fold to exactly the doubles they replace. Co-Authored-By: Claude Opus 5.5 --- src/noise.sex | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/noise.sex b/src/noise.sex index dfda6ef..5f80067 100644 --- a/src/noise.sex +++ b/src/noise.sex @@ -7,16 +7,14 @@ (pub include stdint.h) (include stdlib.h math.h) -;;; The C# folds these at compile time; written as divisions here they -;;; would be unparenthesized macros and round differently in context. -;; TODO sex#55: write the divisions, e.g. (/ -1.0 6.0), once define -;; bodies are translated and parenthesized. +;;; As the C# writes them. Its divisions are folded at compile time, +;;; and C's are too, to the same doubles. (define STRETCH-2D -0.211324865405187) (define SQUISH-2D 0.366025403784439) -(define STRETCH-3D -0.16666666666666666) -(define SQUISH-3D 0.3333333333333333) -(define NORM-2D 0.02127659574468085) -(define NORM-3D 0.009708737864077669) +(define STRETCH-3D (/ -1.0 6.0)) +(define SQUISH-3D (/ 1.0 3.0)) +(define NORM-2D (/ 1.0 47.0)) +(define NORM-3D (/ 1.0 103.0)) (define NORM-2D-WARP 0.020435461373899677) (pub define MAX-VALUE-3D 0.9871465422297019) (define VALUE-MULTIPLIER 1.2)