targetArray.forEach(function(obj, index) { var x = obj.x - item.x, y = obj.y - item.y, dis = Math.sqrt(x*x + y*y) if(dis < item.width / 2 + obj.width / 2 + 50) { isOk = false } })
/* * Get the count of follows a user has * * @param {object} state Global state tree * @returns {Integer} Follow count */ const getReaderFollowsCount = ( state ) => Math.max( state.reader.follows.itemsCount, size( filter( state.reader.follows.items, { is_following: true } ) ) )
/** * Hyperbolic tan */ export function activate(weight: number): number { return Math.tanh(weight); }
predictTargetIndex(input, target) { const output = this.runIndex(input); // set gradients into log probabilities const logProbabilities = output; // interpret output as log probabilities const probabilities = softmax(output); // compute the softmax probabilities // write gradients into log probabilities logProbabilities.deltas = probabilities.weights.slice(0); logProbabilities.deltas[target] -= 1; // accumulate base 2 log prob and do smoothing return -Math.log2(probabilities.weights[target]); }
/** * Returns a random float between given min and max bounds (inclusive) * @param min Minimum value of the ranfom float * @param max Maximum value of the random float */ export function randomFloat(min: number, max: number): number { return Math.random() * (max - min) + min; }
// Float to byte function f2b(f) { f = Math.round(255 * f); if (!(f > 0)) return 0; else if (!(f < 255)) return 255; else return f & 0xFF; }
function() { var degreeToRadiansFactor = Math.PI / 180; return function ( degrees ) { return degrees * degreeToRadiansFactor; }; }()
function getPos( u, in_q, in_p, radius, heightScale ) { var cu = Math.cos( u ); var su = Math.sin( u ); var quOverP = in_q / in_p * u; var cs = Math.cos( quOverP ); var tx = radius * ( 2 + cs ) * 0.5 * cu; var ty = radius * ( 2 + cs ) * su * 0.5; var tz = heightScale * radius * Math.sin( quOverP ) * 0.5; return new THREE.Vector3( tx, ty, tz ); }
const displayNumberOfEventProcessedBySeconds = (time) => { const elapsed = process.hrtime(time)[1] / 1000000; // divide by a million to get nano to milli const perSecond = (1000 * NUMBER_OF_EVENTS_TO_THROW) / elapsed; const millionEventProcessedPerSecond = perSecond / 1000000; const millionEventProcessedPerSecondBeautiful = Math.round(millionEventProcessedPerSecond * 100) / 100; logger.info( `Processed 1 million events in ${elapsed} ms, so ${millionEventProcessedPerSecondBeautiful}M events/per second`, ); }
// Texture fixing helper. Spheres have some odd behaviours. function correctUV( uv, vector, azimuth ) { if ( ( azimuth < 0 ) && ( uv.x === 1 ) ) uv = new THREE.Vector2( uv.x - 1, uv.y ); if ( ( vector.x === 0 ) && ( vector.z === 0 ) ) uv = new THREE.Vector2( azimuth / 2 / Math.PI + 0.5, uv.y ); return uv.clone(); }
// Float to byte function f2b(f) { f = Math.round(255 * f); if (!(f > 0)) return 0; else if (!(f < 255)) return 255; else return f & 0xFF; }
const displayNumberOfEventProcessedBySeconds = (time) => { const elapsed = process.hrtime(time)[1] / 1000000; // divide by a million to get nano to milli const perSecond = (1000 * NUMBER_OF_EVENTS_TO_THROW) / elapsed; const millionEventProcessedPerSecond = perSecond / 1000000; const millionEventProcessedPerSecondBeautiful = Math.round(millionEventProcessedPerSecond * 100) / 100; logger.info( `Processed 1 million events in ${elapsed} ms, so ${millionEventProcessedPerSecondBeautiful}M events/per second`, ); }