/** * <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; }
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] = ' '; } }
void setDepthAttachment( final JCGLFramebufferDepthAttachmentType a, final int bits) { Preconditions.checkPreconditionI( this.depth_bits, this.depth_bits == 0, ignored -> "Depth bits must be zero"); Preconditions.checkPreconditionI( this.stencil_bits, this.stencil_bits == 0, ignored -> "Stencil bits must be zero"); this.refs.referenceAdd((FakeReferable) a); this.depth_bits = bits; }
void setDepthAttachment( final JCGLFramebufferDepthAttachmentType a, final int bits) { Preconditions.checkPreconditionI( this.depth_bits, this.depth_bits == 0, ignored -> "Depth bits must be zero"); Preconditions.checkPreconditionI( this.stencil_bits, this.stencil_bits == 0, ignored -> "Stencil bits must be zero"); this.refs.referenceAdd((LWJGL3Referable) a); this.depth_bits = bits; }
void setDepthAttachment( final JCGLFramebufferDepthAttachmentType a, final int bits) { Preconditions.checkPreconditionI( this.depth_bits, this.depth_bits == 0, ignored -> "Depth bits must be zero"); Preconditions.checkPreconditionI( this.stencil_bits, this.stencil_bits == 0, ignored -> "Stencil bits must be zero"); this.refs.referenceAdd((FakeReferable) a); this.depth_bits = bits; }
void setDepthAttachment( final JCGLFramebufferDepthAttachmentType a, final int bits) { Preconditions.checkPreconditionI( this.depth_bits, this.depth_bits == 0, ignored -> "Depth bits must be zero"); Preconditions.checkPreconditionI( this.stencil_bits, this.stencil_bits == 0, ignored -> "Stencil bits must be zero"); this.refs.referenceAdd((LWJGL3Referable) a); this.depth_bits = bits; }
void setDepthStencilAttachment( final JCGLFramebufferDepthStencilAttachmentType a, final int d_bits, final int s_bits) { Preconditions.checkPreconditionI( this.depth_bits, this.depth_bits == 0, ignored -> "Depth bits must be zero"); Preconditions.checkPreconditionI( this.stencil_bits, this.stencil_bits == 0, ignored -> "Stencil bits must be zero"); this.refs.referenceAdd((FakeReferable) a); this.depth_bits = d_bits; this.stencil_bits = s_bits; } }
void setDepthStencilAttachment( final JCGLFramebufferDepthStencilAttachmentType a, final int d_bits, final int s_bits) { Preconditions.checkPreconditionI( this.depth_bits, this.depth_bits == 0, ignored -> "Depth bits must be zero"); Preconditions.checkPreconditionI( this.stencil_bits, this.stencil_bits == 0, ignored -> "Stencil bits must be zero"); this.refs.referenceAdd((LWJGL3Referable) a); this.depth_bits = d_bits; this.stencil_bits = s_bits; } }
void setDepthStencilAttachment( final JCGLFramebufferDepthStencilAttachmentType a, final int d_bits, final int s_bits) { Preconditions.checkPreconditionI( this.depth_bits, this.depth_bits == 0, ignored -> "Depth bits must be zero"); Preconditions.checkPreconditionI( this.stencil_bits, this.stencil_bits == 0, ignored -> "Stencil bits must be zero"); this.refs.referenceAdd((FakeReferable) a); this.depth_bits = d_bits; this.stencil_bits = s_bits; } }
void setDepthStencilAttachment( final JCGLFramebufferDepthStencilAttachmentType a, final int d_bits, final int s_bits) { Preconditions.checkPreconditionI( this.depth_bits, this.depth_bits == 0, ignored -> "Depth bits must be zero"); Preconditions.checkPreconditionI( this.stencil_bits, this.stencil_bits == 0, ignored -> "Stencil bits must be zero"); this.refs.referenceAdd((LWJGL3Referable) a); this.depth_bits = d_bits; this.stencil_bits = s_bits; } }
/** * <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); }
/** * An {@code int} 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 int checkPreconditionI( final int value, final ContractIntConditionType condition) throws PreconditionViolationException { return checkPreconditionI( value, condition.predicate(), condition.describer()); }
/** * An {@code int} 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 int checkPreconditionI( final int value, final ContractIntConditionType condition) throws PreconditionViolationException { return checkPreconditionI( value, condition.predicate(), condition.describer()); }
/** * <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.checkPreconditionI( id, id > 0, ignored -> "Generated shader ID must be positive");
Preconditions.checkPreconditionI( id, id > 0, ignored -> "Generated shader ID must be positive");
/** * <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; }
/** * Check preconditions for the type. */ @Value.Check default void checkPreconditions() { HashMap<Integer, SMFByteBufferPackedAttribute> m = HashMap.empty(); final SortedMap<Integer, SMFByteBufferPackedAttribute> by_offset = this.packedAttributesByOffset(); for (final Integer offset : by_offset.keySet()) { Preconditions.checkPreconditionI( offset.intValue(), !m.containsKey(offset), i -> "All attribute offsets must be unique"); m = m.put(offset, by_offset.get(offset).get()); } } }
/** * Determine the offset in octets of the attribute with order {@code index} * at vertex {@code vertex}. * * @param index The attribute index * @param vertex The vertex index * * @return The offset in octets */ default long offsetOctetsForIndex( final int index, final long vertex) { final Seq<SMFByteBufferPackedAttribute> packed = this.packedAttributesByOrder(); Preconditions.checkPreconditionI( index, index < packed.size(), i -> "Index must point to valid attribute"); final long base = Math.multiplyExact( (long) this.vertexSizeOctets(), vertex); return Math.addExact(base, (long) packed.get(index).offsetOctets()); }
config.packedAttributesByOrder().contains(packed_attr), a -> "Packed attribute must exist in configuration"); Preconditions.checkPreconditionI( attr.componentCount(), attr.componentCount() == 3,