src/elements/Angle.js
function Angle(value, parameters) {
    abstractions.Element.call(this, utilities.types.ANGLE, parameters);

    // analyze the value
    if (value === undefined) value = 0;  // default value
    if (!isFinite(value)) {
        throw new utilities.Exception({
            $module: '/bali/elements/Angle',
            $procedure: '$Angle',
            $exception: '$invalidParameter',
            $parameter: value.toString(),
            $text: '"An invalid angle value was passed to the constructor."'
        });
    }
    if (parameters) {
        const units = parameters.getParameter('$units');
        if (units && units.toString() === '$degrees') {
            // convert degrees to radians
            value = utilities.precision.quotient(utilities.precision.product(value, Math.PI), 180);
        }
    }

    // lock onto pi if appropriate
    value = utilities.precision.lockOnAngle(value);

    // normalize the value to the range (-pi..pi]
    const twoPi = utilities.precision.product(Math.PI, 2);
    if (value < -twoPi || value > twoPi) {
        value = utilities.precision.remainder(value, twoPi);  // make in the range (-2pi..2pi)
    }
    if (value > Math.PI) {
        value = utilities.precision.difference(value, twoPi);  // make in the range (-pi..pi]
    } else if (value <= -Math.PI) {
        value = utilities.precision.sum(value, twoPi);  // make in the range (-pi..pi]
    }
    if (value === -0) value = 0;  // normalize to positive zero

    // since this element is immutable the value must be read-only
    this.getValue = function() { return value; };

    return this;
}
function Angle(value, parameters) {
    abstractions.Element.call(this, utilities.types.ANGLE, parameters);

    // analyze the value
    if (value === undefined) value = 0;  // default value
    if (!isFinite(value)) {
        throw new utilities.Exception({
            $module: '/bali/elements/Angle',
            $procedure: '$Angle',
            $exception: '$invalidParameter',
            $parameter: value.toString(),
            $text: '"An invalid angle value was passed to the constructor."'
        });
    }
    if (parameters) {
        const units = parameters.getParameter('$units');
        if (units && units.toString() === '$degrees') {
            // convert degrees to radians
            value = utilities.precision.quotient(utilities.precision.product(value, Math.PI), 180);
        }
    }

    // lock onto pi if appropriate
    value = utilities.precision.lockOnAngle(value);

    // normalize the value to the range (-pi..pi]
    const twoPi = utilities.precision.product(Math.PI, 2);
    if (value < -twoPi || value > twoPi) {
        value = utilities.precision.remainder(value, twoPi);  // make in the range (-2pi..2pi)
    }
    if (value > Math.PI) {
        value = utilities.precision.difference(value, twoPi);  // make in the range (-pi..pi]
    } else if (value <= -Math.PI) {
        value = utilities.precision.sum(value, twoPi);  // make in the range (-pi..pi]
    }
    if (value === -0) value = 0;  // normalize to positive zero

    // since this element is immutable the value must be read-only
    this.getValue = function() { return value; };

    return this;
}
function Angle ( value , parameters ) { abstractions . Element . call ( this , utilities . types . ANGLE , parameters ) ; // analyze the value if ( value === undefined ) value = 0 ; // default value if ( ! isFinite ( value ) ) { throw new utilities . Exception ( { $module : '/bali/elements/Angle' , $procedure : '$Angle' , $exception : '$invalidParameter' , $parameter : value . toString ( ) , $text : '"An invalid angle value was passed to the constructor."' } ) ; } if ( parameters ) { const units = parameters . getParameter ( '$units' ) ; if ( units && units . toString ( ) === '$degrees' ) { // convert degrees to radians value = utilities . precision . quotient ( utilities . precision . product ( value , Math . PI ) , 180 ) ; } } // lock onto pi if appropriate value = utilities . precision . lockOnAngle ( value ) ; // normalize the value to the range (-pi..pi] const twoPi = utilities . precision . product ( Math . PI , 2 ) ; if ( value < - twoPi || value > twoPi ) { value = utilities . precision . remainder ( value , twoPi ) ; // make in the range (-2pi..2pi) } if ( value > Math . PI ) { value = utilities . precision . difference ( value , twoPi ) ; // make in the range (-pi..pi] } else if ( value <= - Math . PI ) { value = utilities . precision . sum ( value , twoPi ) ; // make in the range (-pi..pi] } if ( value === - 0 ) value = 0 ; // normalize to positive zero // since this element is immutable the value must be read-only this . getValue = function ( ) { return value ; } ; return this ; }
PUBLIC CONSTRUCTOR 
This constructor creates an immutable instance of an angle using the specified value.

@constructor
@param {Number} value The value of the angle.
@param {Parameters} parameters Optional parameters used to parameterize this element.
@returns {Angle} The new angle element.
PUBLIC CONSTRUCTOR This constructor creates an immutable instance of an angle using the specified value .