/** Determines on which side of the given line the point is. Returns -1 if the point is on the left side of the line, 0 if the * point is on the line and 1 if the point is on the right side of the line. Left and right are relative to the lines direction * which is linePoint1 to linePoint2. */ public static int pointLineSide (Vector2 linePoint1, Vector2 linePoint2, Vector2 point) { return (int)Math.signum( (linePoint2.x - linePoint1.x) * (point.y - linePoint1.y) - (linePoint2.y - linePoint1.y) * (point.x - linePoint1.x)); }
static private int computeSpannedAreaSign (float p1x, float p1y, float p2x, float p2y, float p3x, float p3y) { float area = p1x * (p3y - p2y); area += p2x * (p1y - p3y); area += p3x * (p2y - p1y); return (int)Math.signum(area); } }
static private int computeSpannedAreaSign (float p1x, float p1y, float p2x, float p2y, float p3x, float p3y) { float area = p1x * (p3y - p2y); area += p2x * (p1y - p3y); area += p3x * (p2y - p1y); return (int)Math.signum(area); } }
/** Determines on which side of the given line the point is. Returns -1 if the point is on the left side of the line, 0 if the * point is on the line and 1 if the point is on the right side of the line. Left and right are relative to the lines direction * which is linePoint1 to linePoint2. */ public static int pointLineSide (Vector2 linePoint1, Vector2 linePoint2, Vector2 point) { return (int)Math.signum( (linePoint2.x - linePoint1.x) * (point.y - linePoint1.y) - (linePoint2.y - linePoint1.y) * (point.x - linePoint1.x)); }
public static int pointLineSide (float linePoint1X, float linePoint1Y, float linePoint2X, float linePoint2Y, float pointX, float pointY) { return (int)Math .signum((linePoint2X - linePoint1X) * (pointY - linePoint1Y) - (linePoint2Y - linePoint1Y) * (pointX - linePoint1X)); }
public static int pointLineSide (float linePoint1X, float linePoint1Y, float linePoint2X, float linePoint2Y, float pointX, float pointY) { return (int)Math .signum((linePoint2X - linePoint1X) * (pointY - linePoint1Y) - (linePoint2Y - linePoint1Y) * (pointX - linePoint1X)); }
@Override public int compare (Decal o1, Decal o2) { float dist1 = camera.position.dst(o1.position); float dist2 = camera.position.dst(o2.position); return (int)Math.signum(dist2 - dist1); } });
@Override public int compare (Decal o1, Decal o2) { float dist1 = camera.position.dst(o1.position); float dist2 = camera.position.dst(o2.position); return (int)Math.signum(dist2 - dist1); } });
@Description("round to integer by dropping digits after decimal point") @ScalarFunction @SqlType(StandardTypes.REAL) public static long truncate(@SqlType(StandardTypes.REAL) long num) { float numInFloat = intBitsToFloat((int) num); return floatToRawIntBits((float) (Math.signum(numInFloat) * Math.floor(Math.abs(numInFloat)))); }
@Description("round to integer by dropping digits after decimal point") @ScalarFunction @SqlType(StandardTypes.DOUBLE) public static double truncate(@SqlType(StandardTypes.DOUBLE) double num) { return Math.signum(num) * Math.floor(Math.abs(num)); }
@Description("signum") @ScalarFunction("sign") @SqlType(StandardTypes.REAL) public static long signFloat(@SqlType(StandardTypes.REAL) long num) { return floatToRawIntBits((Math.signum(intBitsToFloat((int) num)))); }
@LiteralParameters({"p", "s"}) @SqlType("decimal(1,0)") public static long signDecimalShort(@SqlType("decimal(p, s)") long num) { return (long) Math.signum(num); }
@ScalarFunction @SqlType(StandardTypes.BIGINT) public static long sign(@SqlType(StandardTypes.BIGINT) long num) { return (long) Math.signum(num); }
public void testCompare() { // This is the only ordering for primitives that does not have a // corresponding Comparable wrapper in java.lang. for (int i = 0; i < VALUES.length; i++) { for (int j = 0; j < VALUES.length; j++) { byte x = VALUES[i]; byte y = VALUES[j]; // note: spec requires only that the sign is the same assertEquals( x + ", " + y, Math.signum(UnsignedBytes.compare(x, y)), Math.signum(Ints.compare(i, j))); } } }
@Description("signum") @ScalarFunction @SqlType(StandardTypes.DOUBLE) public static double sign(@SqlType(StandardTypes.DOUBLE) double num) { return Math.signum(num); }
@Description("signum") @ScalarFunction("sign") @SqlType(StandardTypes.INTEGER) public static long signInteger(@SqlType(StandardTypes.INTEGER) long num) { return (long) Math.signum(num); }
@Description("signum") @ScalarFunction("sign") @SqlType(StandardTypes.SMALLINT) public static long signSmallint(@SqlType(StandardTypes.SMALLINT) long num) { return (long) Math.signum(num); }
@Description("signum") @ScalarFunction("sign") @SqlType(StandardTypes.TINYINT) public static long signTinyint(@SqlType(StandardTypes.TINYINT) long num) { return (long) Math.signum(num); }
public void verifyReauthenticationMetrics(int successfulReauthentications, final int failedReauthentications) throws InterruptedException { waitForMetrics("successful-reauthentication", successfulReauthentications, EnumSet.of(MetricType.TOTAL, MetricType.RATE)); waitForMetrics("failed-reauthentication", failedReauthentications, EnumSet.of(MetricType.TOTAL, MetricType.RATE)); waitForMetrics("successful-authentication-no-reauth", 0, EnumSet.of(MetricType.TOTAL)); waitForMetrics("reauthentication-latency", Math.signum(successfulReauthentications), EnumSet.of(MetricType.MAX, MetricType.AVG)); }