Fix off-by-1 positional error in graph
The distribution graph was scaling off by 1, and areas the noise doesn't produce were being interpolated with neighbouring values, making the grey box part of the graph thin and transparent.master
parent
20ad4b5712
commit
5e2473e3d4
|
@ -29,10 +29,10 @@ public class FrequencyGraph {
|
|||
*/
|
||||
public BufferedImage render(IHistogram2D histogram2d, int x_min, int x_max, int y_min, int y_max) {
|
||||
|
||||
int xRange = 1 + x_max - x_min; // inclusive range
|
||||
int yRange = 1 + y_max - y_min; // inclusive range
|
||||
float xScale = xRange / (float)width;
|
||||
float yScale = yRange / (float)height;
|
||||
int xRange = x_max - x_min; // inclusive range (x_max is an inclusive value)
|
||||
int yRange = y_max - y_min; // inclusive range (y_max is an inclusive value)
|
||||
float xScale = xRange / (float)(width - 1); // xRange is inclusive, but width is not, so subtract 1 from width so that at the top of the range, scaling by xScale will give the correct pixel location of (width-1) and vice versa.
|
||||
float yScale = yRange / (float)(height - 1); // yRange is inclusive, but height is not, so subtract 1 from height so that at the top of the range, scaling by yScale will give the correct pixel location of (height-1) and vice versa.
|
||||
|
||||
if (graph == null || graph.getWidth() != width || graph.getHeight() != height) {
|
||||
graph = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
||||
|
|
|
@ -55,8 +55,8 @@ public class VoronoiPanel extends JPanel {
|
|||
private static Stroke stroke_capSquare = new BasicStroke(AXIS_WIDTH, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND);
|
||||
private static AffineTransform noTransform = new AffineTransform();
|
||||
|
||||
public int axis_min = -40;
|
||||
public int axis_max = 140;
|
||||
public int axis_min = -40; // This should be considered an inclusive value, i.e. position -40 should be visible in graphs
|
||||
public int axis_max = 140; // This should be considered an inclusive value, i.e. position 140 should be visible in graphs
|
||||
public int graph_resolution = 1000;
|
||||
|
||||
private IHistogram2D climateHistogram = null;
|
||||
|
|
|
@ -254,8 +254,8 @@ public class VoronoiWindow implements BiomeProfileUpdateListener, ChangeListener
|
|||
+ " The innermost red ring contains 25% of the world inside it, with 25%\r\n"
|
||||
+ " between it and the middle ring, etc.\r\n"
|
||||
+ " * Blue solid rings - these are spaced at 10 percentile intervals. Note\r\n"
|
||||
+ " that the 50th percentile ring is drawn red, but can also be considered\r\n"
|
||||
+ " one of the blue rings.\r\n"
|
||||
+ " that the 50th percentile ring is drawn red, but should also be\r\n"
|
||||
+ " considered one of the blue rings.\r\n"
|
||||
+ " * Red dot - the center of the distribution. This is the most common\r\n"
|
||||
+ " temperature and humidity value\r\n.");
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package amidst.minetest.world;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
|
|
@ -81,10 +81,14 @@ public class ClimateHistogram implements IHistogram2D {
|
|||
|
||||
double freq_floor = FrequencyOfTemperature(temperature_floor);
|
||||
double freq_ceil = FrequencyOfTemperature((float)Math.ceil(temperature));
|
||||
|
||||
if (!(freq_floor > 0 && freq_ceil > 0) && FrequencyOfTemperature(temperature) == 0) return 0; // Don't interpolate the frequency if it's a value that cannot ever happen (the first two checks are just an optimization to prevent unnecessarily invoking FrequencyOfTemperature)
|
||||
double temperature_interp = freq_floor + (freq_ceil - freq_floor) * (temperature - temperature_floor);
|
||||
|
||||
freq_floor = FrequencyOfHumidity(humidity_floor);
|
||||
freq_ceil = FrequencyOfHumidity((float)Math.ceil(humidity));
|
||||
|
||||
if (!(freq_floor > 0 && freq_ceil > 0) && FrequencyOfTemperature(humidity) == 0) return 0; // Don't interpolate the frequency if it's a value that cannot ever happen (the first two checks are just an optimization to prevent unnecessarily invoking FrequencyOfTemperature)
|
||||
double humidity_interp = freq_floor + (freq_ceil - freq_floor) * (humidity - humidity_floor);
|
||||
|
||||
return temperature_interp * humidity_interp;
|
||||
|
@ -217,7 +221,7 @@ public class ClimateHistogram implements IHistogram2D {
|
|||
/**
|
||||
* Processes the sample counts from sampledHistogram_Heat & sampledHistogram_Humidity and
|
||||
* uses what we know about the climate noise algorithm (the center and symmetry) to create
|
||||
* data likely to be closer to the true distrubtion.
|
||||
* data likely to be closer to the true distribution.
|
||||
*
|
||||
* This matters if you want quartile lines to look smooth.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue