# Help understanding Accidental Noise Gradient function

Background:

I am trying to create a set of functions to manipulate noise, similar to Libnoise, Fastnoise and the Accidental Noise Library. The end goal is to produce terrain.

As recommended by this article (http://accidentalnoise.sourceforge.net/minecraftworlds.html) I am starting out with a 'Gradient' function. Quoting the author:

The Gradient function is given a line-segment in N-dimensional space (ie, in whatever coordinate space we are working in, be it 2D, 3D, or higher) and calculates a gradient field aligned along this segment. Input coordinates are projected on this line, and their gradient value is calculated depending where on the line they lie in relation to the endpoints of the defining segment.

Even after repeatedly reading the article and looking at these two other questions I found (2D Terra(ria)in generation - Accidental noise and Accidental noise - Gradient function) I'm still having problems understanding exactly what the function is doing.

Questions:

1. My test chunk is of size 32x32x32 and ranges from -16 to +16 on the x, y and z axis. In this case, would the inputs to the function be x/32, y/32, z/32?
2. Does the function map points between 0 and 1 (as input) to a point between 1 and -1 (as output)? I.e if my x, y and z where -16, -16, -16, would I get 1, 1, 1 back?
3. Why in the extract below is the line segment (0,1)->(0,0) rather than (0,0)->(0,1)? Given that the example line segment is defined as x1=0, x2=0, y1=0, y2=1.

The Gradient function accepts a line segment in the form of (x1,x2, y1,y2) for the 2D case, extended to (x1,x2, y1,y2, z1,z2) for the 3D case. The point formed by (x1,y1) delineates the start of the line segment, which is mapped to 0. The point formed by (x2,y2) is the end of the line segment that maps to 1. So here we are mapping the line segment (0,1)->(0,0) to the gradient.

Any help on this would be greatly appreciated, thanks.

• I'm voting to close this question as off-topic because I'm not sure why you're asking game developers about this. – Almo Jun 28 '19 at 19:35
• @Almo I'm trying to implement noise manipulation techniques to supplement the procedural terrain generation system for the game I'm developing. The two questions I linked on this topic were asked and answered on this site. – MasterReDWinD Jun 28 '19 at 20:34
• It's still a poorly constructed question for our format. It's conversational, and doesn't ask one question with a well-defined answer. Instead it reads like a forum post. – Almo Jun 29 '19 at 0:16
• @Almo are there specific edits you'd recommend to help focus it better for our format? Constructive feedback or edit proposals can go a long way to improving a question. – DMGregory Jun 29 '19 at 5:01