@Override public void compute() { // check origin if (!((GeoElement) origin).isDefined() || origin.isInfinite()) { getQuadric().setUndefined(); return; } // check direction Coords d = getDirection(); if (d.equalsForKernel(0, Kernel.STANDARD_PRECISION)) { getQuadric().setUndefined(); return; } // check number double r = getComputer().getNumber(((NumberValue) getNumber()).getDouble()); if (Double.isNaN(r)) { getQuadric().setUndefined(); return; } // compute the quadric getQuadric().setDefined(); getComputer().setQuadric(getQuadric(), origin.getInhomCoordsInD(3), d, r); }
protected Coords getNormalProjectionParameters(Coords coords) { Coords parameters = super.getNormalProjectionParameters(coords); if (parameters.getY() < getMinParameter(1)) parameters.setY(getMinParameter(1)); else if (parameters.getY() > getMaxParameter(1)) parameters.setY(getMaxParameter(1)); return parameters; }
protected void setColors(double alpha, Coords color, Coords colorHighlighted) { Color c = getGeoElement().getObjectColor(); color.set( new Coords( (double) c.getRed() / 255, (double) c.getGreen() / 255, (double) c.getBlue() / 255, alpha)); if (getView3D().isGrayScaled()) color.convertToGrayScale(); // creates corresponding color for highlighting double r = color.getX(); double g = color.getY(); double b = color.getZ(); double d = r + g + b; Coords color2; double distance; if (d > LIGHT_COLOR) { // color is closer to white : darken it distance = Math.sqrt(r * r + g * g + b * b); // euclidian distance to black color2 = new Coords(0, 0, 0, color.getW()); // black } else { // color is closer to black : lighten it r = 1 - r; g = 1 - g; b = 1 - b; distance = Math.sqrt(r * r + g * g + b * b); // euclidian distance to white color2 = new Coords(1, 1, 1, color.getW()); // white } double s = getColorShift() / distance; colorHighlighted.set(color.mul(1 - s).add(color2.mul(s))); // sufficient alpha to be seen if (colorHighlighted.getW() < ALPHA_MIN_HIGHLIGHTING) colorHighlighted.setW(ALPHA_MIN_HIGHLIGHTING); }