protected void lightNormal(int num, float dx, float dy, float dz) { // Applying normal matrix to the light direction vector, which is the // transpose of the inverse of the modelview. float nx = dx*modelviewInv.m00 + dy*modelviewInv.m10 + dz*modelviewInv.m20; float ny = dx*modelviewInv.m01 + dy*modelviewInv.m11 + dz*modelviewInv.m21; float nz = dx*modelviewInv.m02 + dy*modelviewInv.m12 + dz*modelviewInv.m22; float d = PApplet.dist(0, 0, 0, nx, ny, nz); if (0 < d) { float invn = 1.0f / d; lightNormal[3 * num + 0] = invn * nx; lightNormal[3 * num + 1] = invn * ny; lightNormal[3 * num + 2] = invn * nz; } else { lightNormal[3 * num + 0] = 0; lightNormal[3 * num + 1] = 0; lightNormal[3 * num + 2] = 0; } }
protected void lightNormal(int num, float dx, float dy, float dz) { // Applying normal matrix to the light direction vector, which is the // transpose of the inverse of the modelview. float nx = dx*modelviewInv.m00 + dy*modelviewInv.m10 + dz*modelviewInv.m20; float ny = dx*modelviewInv.m01 + dy*modelviewInv.m11 + dz*modelviewInv.m21; float nz = dx*modelviewInv.m02 + dy*modelviewInv.m12 + dz*modelviewInv.m22; float d = PApplet.dist(0, 0, 0, nx, ny, nz); if (0 < d) { float invn = 1.0f / d; lightNormal[3 * num + 0] = invn * nx; lightNormal[3 * num + 1] = invn * ny; lightNormal[3 * num + 2] = invn * nz; } else { lightNormal[3 * num + 0] = 0; lightNormal[3 * num + 1] = 0; lightNormal[3 * num + 2] = 0; } }
public void mouseMoved() { hoverVar = null; for (Variable var: points.keySet()) { SoftPoint pt = points.get(var); if (pt == null) continue; if (PApplet.dist(pt.x(), pt.y(), mouseX, mouseY) < 15) { hoverVar = var; hoverAlpha.setTarget(100); break; } } if (hoverVar == null) hoverAlpha.set(255); }
public Selection getSelection(double valx, double valy, boolean shift) { if (canDraw()) { if (points.size() < 500) { int count = PApplet.min(500, points.size()); float rad = PApplet.map(count, 0, 500, 0.05f, 0.01f); for (Value2D pt : points) { float px = (float) pt.x; float py = 1 - (float) (pt.y); if (PApplet.dist((float) valx, (float) valy, px, py) < rad) { Selection sel = new Selection(px, py, rad, rad); sel.isEllipse = true; sel.setLabel(pt.label); return sel; } } return null; } else { // TODO: needs some kind of tree representation of the data to search // efficiently when there are many data points. return null; } } else { return getUnavailableSelection(); } }
int span = (int) PApplet.dist(tx1, ty1, tx2, ty2) * ACCURACY; if (span <= 0) {
for (int j = 0; j < h; j++) { for (int i = 0; i < w; i++) { float distance = PApplet.dist(cx, cy, x + i, y + j); int which = PApplet.min((int) (distance * ACCURACY), interp.length-1);
if (0 < PApplet.dist(vert[PGraphics.NX], vert[PGraphics.NY], vert[PGraphics.NZ], 0, 0, 0)) {
if (0 < PApplet.dist(vert[PGraphics.NX], vert[PGraphics.NY], vert[PGraphics.NZ], 0, 0, 0)) {
(int) (TWO_PI * PApplet.dist(sx1, sy1, sx2, sy2) / POINT_ACCURACY_FACTOR))); float inc = (float) SINCOS_LENGTH / accuracy;
(int) (TWO_PI * PApplet.dist(sx1, sy1, sx2, sy2) / POINT_ACCURACY_FACTOR))); float inc = (float) SINCOS_LENGTH / accuracy;
(int) (TWO_PI * PApplet.dist(sx1, sy1, sx2, sy2) / POINT_ACCURACY_FACTOR))); inc = PApplet.max(1, SINCOS_LENGTH / accuracy);
(int) (TWO_PI * PApplet.dist(sx1, sy1, sx2, sy2) / POINT_ACCURACY_FACTOR))); inc = PApplet.max(1, SINCOS_LENGTH / accuracy);