@Override public PMatrixDirectReadable4x4FType<R2SpaceEyeType, R2SpaceLightEyeType> matrixProjectiveEyeToLightEye() { Preconditions.checkPrecondition(this.active, "Projective must be active"); return this.m_projective_eye_to_light_eye; }
private JPTextImage( final int in_width, final int in_height) { Preconditions.checkPreconditionI( in_width, in_width > 0, w -> "Width must be positive"); Preconditions.checkPreconditionI( in_height, in_height > 0, h -> "Height must be positive"); this.width = in_width; this.height = in_height; this.chars = new int[this.width * this.height]; for (int index = 0; index < this.chars.length; ++index) { this.chars[index] = ' '; } }
/** * <p>A version of {@link #checkPrecondition(boolean, String)} that constructs * a description message from the given format string and arguments.</p> * * <p>Note that the use of variadic arguments may entail allocating memory on * virtual machines that fail to eliminate the allocations with <i>escape * analysis</i>.</p> * * @param condition The predicate * @param format The format string * @param objects The format string arguments * * @since 1.1.0 */ public static void checkPreconditionV( final boolean condition, final String format, final Object... objects) { checkPreconditionV("<unspecified>", condition, format, objects); }
/** * <p>Calculate the area of an approximation of a circle with radius {@code r} * constructed with {@code s} line segments.</p> * * @param r The radius * @param s The number of segments in the approximation * * @return The approximation area */ public static double getUVSphereApproximationArea( final double r, final int s) { Preconditions.checkPreconditionI( s, s > 0, c -> "Segment count must be positive"); Preconditions.checkPreconditionD( r, r > 0.0, c -> "Radius must be positive"); final double ds = (double) s; final double a = getUVSphereApproximationTriangleArea(r, s); return ds * a; }
Preconditions.checkPrecondition( packed_attr, config.packedAttributesByOrder().contains(packed_attr), a -> "Packed attribute must exist in configuration"); Preconditions.checkPreconditionI( attr.componentCount(), attr.componentCount() == 3, n -> "Attribute must have 3 components"); Preconditions.checkPrecondition( attr.componentType(), attr.componentType() == SMFComponentType.ELEMENT_TYPE_INTEGER_UNSIGNED,
private void evict( final C context, final TimedEntry<K, T> e) { Preconditions.checkPrecondition( e.key, this.entries_free.containsKey(e.key), k -> "Key " + k + " must be free"); Preconditions.checkPreconditionL( this.size_now, Long.compareUnsigned(this.size_now, 0L) > 0, x -> "Size " + x + " must be > 0"); final SortedSet<TimedEntry<K, T>> free = this.entries_free.get(e.key); free.remove(e); this.entries_free_timed.remove(e); this.size_now = BigUnsigned.checkedSubtractLong(this.size_now, e.size); Postconditions.checkPostconditionL( this.size_now, Long.compareUnsigned(this.size_now, 0L) >= 0, x -> "Size " + x + " must be >= 0"); this.listener.onDelete(context, e.key, e.value); }
/** * A {@code long} specialized version of {@link #checkPrecondition(Object, * ContractConditionType)}. * * @param value The value * @param condition The predicate * * @return value * * @throws PreconditionViolationException If the predicate is false */ public static long checkPreconditionL( final long value, final ContractLongConditionType condition) throws PreconditionViolationException { return checkPreconditionL( value, condition.predicate(), condition.describer()); }
/** * <p>Calculate the area of a circle with radius {@code r}.</p> * * @param r The radius * * @return The circle area */ public static double getCircleArea( final double r) { Preconditions.checkPreconditionD( r, r > 0.0, c -> "Radius must be positive"); return Math.PI * (r * r); }
Preconditions.checkPrecondition( packed_attr, config.packedAttributesByOrder().contains(packed_attr), a -> "Packed attribute must exist in configuration"); Preconditions.checkPreconditionI( attr.componentCount(), attr.componentCount() == 4, n -> "Attribute must have 4 components"); Preconditions.checkPrecondition( attr.componentType(), attr.componentType() == SMFComponentType.ELEMENT_TYPE_INTEGER_SIGNED,
/** * <p>Calculate the area of one of the triangles that make up an approximation * of a circle with radius {@code r} constructed with {@code s} line * segments.</p> * * @param r The radius * @param s The number of segments in the approximation * * @return The approximation area */ public static double getUVSphereApproximationTriangleArea( final double r, final int s) { Preconditions.checkPreconditionI( s, s > 0, c -> "Segment count must be positive"); Preconditions.checkPreconditionD( r, r > 0.0, c -> "Radius must be positive"); final double a = getUVSphereTriangleInteriorAngle(s); final double rs = r * r; return 0.5 * rs * Math.sin(a); }
/** * A {@code long} specialized version of {@link #checkPrecondition(Object, * ContractConditionType)}. * * @param value The value * @param condition The predicate * * @return value * * @throws PreconditionViolationException If the predicate is false */ public static long checkPreconditionL( final long value, final ContractLongConditionType condition) throws PreconditionViolationException { return checkPreconditionL( value, condition.predicate(), condition.describer()); }
/** * A {@code double} specialized version of {@link #checkPrecondition(Object, * ContractConditionType)}. * * @param value The value * @param condition The predicate * * @return value * * @throws PreconditionViolationException If the predicate is false */ public static double checkPreconditionD( final double value, final ContractDoubleConditionType condition) throws PreconditionViolationException { return checkPreconditionD( value, condition.predicate(), condition.describer()); }
@Override public PMatrixDirectReadable4x4FType<R2SpaceLightEyeType, R2SpaceLightClipType> matrixProjectiveProjection() { Preconditions.checkPrecondition(this.active, "Projective must be active"); return this.m_projective_projection; }
Preconditions.checkPrecondition( packed_attr, config.packedAttributesByOrder().contains(packed_attr), a -> "Packed attribute must exist in configuration"); Preconditions.checkPreconditionI( attr.componentCount(), attr.componentCount() == 4, n -> "Attribute must have 4 components"); Preconditions.checkPrecondition( attr.componentType(), attr.componentType() == SMFComponentType.ELEMENT_TYPE_FLOATING,
/** * <p>A UV sphere approximates a real sphere by using a fixed number of * vertical segments. When using {@code 8} segments, for example, the sphere * looks like an octagon when viewed from above. This function returns the * interior angle, in radians, of one of the triangles that make up the * shape.</p> * * <p>The following always holds: {@code 2 * π = n * getUVSphereTriangleInteriorAngle(n)}</p> * * @param s The number of segments * * @return The interior angle of one of the resulting triangles */ public static double getUVSphereTriangleInteriorAngle( final int s) { Preconditions.checkPreconditionI( s, s > 0, c -> "Segment count must be positive"); return (2.0 * Math.PI) / (double) s; }
/** * <p>Calculate the scale factor required to completely contain a circle of * radius {@code r} inside an approximation with radius {@code r} constructed * with {@code s} line segments.</p> * * @param r The radius * @param s The number of segments in the approximation * * @return The approximation area */ public static double getUVSphereApproximationScaleFactor( final double r, final int s) { Preconditions.checkPreconditionI( s, s > 0, c -> "Segment count must be positive"); Preconditions.checkPreconditionD( r, r > 0.0, c -> "Radius must be positive"); final double ac = getCircleArea(r); final double aa = getUVSphereApproximationArea(r, s); return ac / aa; }
private void checkXY( final int x, final int y) { Preconditions.checkPreconditionV( x >= 0, "X (%d) must be >= 0", Integer.valueOf(x)); Preconditions.checkPreconditionV( x < this.width, "X (%d) must be < width (%d)", Integer.valueOf(x), Integer.valueOf(this.width)); Preconditions.checkPreconditionV( y >= 0, "Y (%d) must be >= 0", Integer.valueOf(y)); Preconditions.checkPreconditionV( y < this.height, "Y (%d) must be < height (%d)", Integer.valueOf(y), Integer.valueOf(this.height)); } }
/** * Check preconditions for the type. */ @Value.Check default void checkPreconditions() { { final long tri_lsize = (long) this.triangles().size(); final long tri_hcount = this.header().triangles().triangleCount(); Preconditions.checkPreconditionL( tri_lsize, tri_lsize == tri_hcount, x -> "Triangle list size must match header count"); } { this.arrays().forEach(p -> { final long array_lsize = (long) p._2.size(); final long array_hcount = this.header().vertexCount(); Preconditions.checkPreconditionL( array_lsize, array_lsize == array_hcount, x -> "Attribute array size must match header count"); }); } } }
/** * A {@code double} specialized version of {@link #checkPrecondition(Object, * ContractConditionType)}. * * @param value The value * @param condition The predicate * * @return value * * @throws PreconditionViolationException If the predicate is false */ public static double checkPreconditionD( final double value, final ContractDoubleConditionType condition) throws PreconditionViolationException { return checkPreconditionD( value, condition.predicate(), condition.describer()); }
@Override public PMatrixDirectReadable4x4FType<R2SpaceWorldType, R2SpaceLightEyeType> matrixProjectiveView() { Preconditions.checkPrecondition(this.active, "Projective must be active"); return this.m_projective_view; }