Here you can find the source of pixelSpacing(int n)
public static double pixelSpacing(int n)
//package com.java2s; //License from project: Open Source License public class Main { /**/* w ww. java2s . c o m*/ * Axial coordinates are a coordinate system referring to vertices of a triangular grid. The * grid is oriented such that triangle edges are horizontal (coincident with the x-axis) and at * +/-60 degrees. For a grid coordinate (u, v), u refers to coordinates increasing from the * origin in the line 60 degrees counter-clockwise from the +x axis, while v refers to * increasing along the x-axis. */ static double SQRT_3 = Math.sqrt(3.); public static double pixelSpacing(int n) { // Even spacing across the panel gap. .5*SQRT_3 may be a better choice as it makes the density more // consistent across the gap (the gaps jump out less), but makes a bunch of other logic more complicated. double k = 1.; return 1. / (n - 1 + k * SQRT_3); } }