Calculate the distance between 2 touches (pinch)
@param {point} startPoint A point object containing x and y co-ordinates
@param {point} endPoint A point object containing x and y co-ordinates
@return int;
@inner
969682
function calculateTouchesDistance(startPoint, endPoint) {
			var diffX = Math.abs(startPoint.x - endPoint.x);
			var diffY = Math.abs(startPoint.y - endPoint.y);
				
			return Math.round(Math.sqrt(diffX*diffX+diffY*diffY));
		}
371622
public void addGreatCircle(final GeoPoint startPoint, final GeoPoint endPoint) {
        //	get the great circle path length in meters
        final int greatCircleLength = (int) startPoint.distanceToAsDouble(endPoint);

        //	add one point for every 100kms of the great circle path
        final int numberOfPoints = greatCircleLength/100000;

        addGreatCircle(startPoint, endPoint, numberOfPoints);
	}
416990
def overlaps(self, begin, end=None):
        
        if end is not None:
            return self.overlaps_range(begin, end)
        elif isinstance(begin, Number):
            return self.overlaps_point(begin)
        else:
            return self.overlaps_range(begin.begin, begin.end)
1279866
function(lineP1, lineP2, point, radius) {
    var distance =
      Math.abs(
        ((lineP2.y - lineP1.y)*point.x) - ((lineP2.x - lineP1.x)*point.y) + (lineP2.x*lineP1.y) - (lineP2.y*lineP1.x)
      ) /
      Math.sqrt(
        Math.pow(lineP2.y - lineP1.y, 2) + Math.pow(lineP2.x - lineP1.x, 2)
      );
    return distance <= radius;
  }
156201
function getScale(start, end) {
    return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
}
271079
protected static double calculateReachDistance(LofPoint basePoint, LofPoint targetPoint)
    {
        double distance = MathUtils.distance(basePoint.getDataPoint(), targetPoint.getDataPoint());

        double reachDistance = (double) ComparatorUtils.max(distance, targetPoint.getkDistance(),
                ComparatorUtils.NATURAL_COMPARATOR);
        return reachDistance;
    }
1185720
function(startPoint, endPoint) {
                startPoint = vector.create(startPoint).to3D();
                endPoint = vector.create(endPoint).to3D();
                if (startPoint === null || endPoint === null) { return null; }
                this.line = line.create(startPoint, endPoint.subtract(startPoint));
                this.start = startPoint;
                this.end = endPoint;
                return this;
              }
1082318
function (e) {
            if (!this.dragging) {
                return;
            }

            var x = e.pageX || e.originalEvent.touches && e.originalEvent.touches[0].pageX;
            this.coords.x_pointer = x - this.coords.x_gap;

            this.calc();
        }
58972
function lineToPoint(previousPoint, point) {
				var pointVM = point._view;
				if (point._view.steppedLine === true) {
					ctx.lineTo(pointVM.x, previousPoint._view.y);
					ctx.lineTo(pointVM.x, pointVM.y);
				} else if (point._view.tension === 0) {
					ctx.lineTo(pointVM.x, pointVM.y);
				} else {
					ctx.bezierCurveTo(
						previousPoint._view.controlPointNextX,
						previousPoint._view.controlPointNextY,
						pointVM.controlPointPreviousX,
						pointVM.controlPointPreviousY,
						pointVM.x,
						pointVM.y
					);
				}
			}
1272549
function validatePinch() {
		    var hasCorrectFingerCount = validateFingers();
		    var hasEndPoint = validateEndPoint();
			var hasCorrectDistance = validatePinchDistance();
			return hasCorrectFingerCount && hasEndPoint && hasCorrectDistance;
			
		}
1002312
function getEventPoint(ev) {
  ev = ev.originalEvent || ev; // support jQuery events
  return (ev.touches && ev.touches[0]) ||
    (ev.changedTouches && ev.changedTouches[0]) ||
    ev;
}
861836
function touchStart(element, clientX, clientY) {
  element[symbols.dragging] = true;
  element[startXSymbol] = clientX;
  element[previousXSymbol] = clientX;
  element[previousYSymbol] = clientY;
  element[deltaXSymbol] = 0;
  element[deltaYSymbol] = 0;
}
633254
function (event) {
            // Standard touch
            if (event.touches && event.changedTouches
                    && (event.changedTouches.length || 0) + (event.touches.length || 0) >= 2) {
                var positions = aria.touch.Event.getPositions(event);
                this.primaryPoint = positions[0];
                this.secondaryPoint = positions[1];
            }
            // IE10 touch
            if (typeof event.isPrimary != 'undefined') {
                if (event.isPrimary) {
                    this.primaryPoint = aria.touch.Event.getPositions(event);
                } else {
                    this.secondaryPoint = aria.touch.Event.getPositions(event);
                }
            }
            if (event.touches && event.changedTouches
                    && (event.changedTouches.length || 0) + (event.touches.length || 0) >= 2
                    || typeof event.isPrimary != 'undefined') {
                var finalDist = this._calculateDistance(this.primaryPoint.x, this.primaryPoint.y, this.secondaryPoint.x, this.secondaryPoint.y);
                var finalAngle = this.__calculateAngle(this.primaryPoint.x, this.primaryPoint.y, this.secondaryPoint.x, this.secondaryPoint.y);
                if (Math.abs(finalAngle - this.lastKnownAngle) > 150) {
                    finalAngle = this.__calculateAngle(this.secondaryPoint.x, this.secondaryPoint.y, this.primaryPoint.x, this.primaryPoint.y);
                }
                var finalData = {
                    distance : finalDist,
                    dVariation : (finalDist - this.initialPinchData.distance),
                    angle : finalAngle
                };
                this.$raiseEvent({
                    name : "pinchend",
                    distance : finalDist,
                    dVariation : (finalDist - this.initialPinchData.distance),
                    angle : finalAngle,
                    originalEvent : event
                });
                return this._gestureEnd(event, finalData);
            } else {
                this.$raiseEvent({
                    name : "pinchcancel"
                });
                return this._gestureCancel(event);
            }
        }
1336051
function touchNavigation() {
    if (this.events.hasOwnProperty('touchStart')) {
        return false;
    }
    let index,
        hDistance,
        vDistance,
        hDistanceLast,
        vDistanceLast,
        hDistancePercent,
        vSwipe = false,
        hSwipe = false,
        hSwipMinDistance = 0,
        vSwipMinDistance = 0,
        doingPinch = false,
        pinchBigger = false,
        startCoords = { },
        endCoords = { },
        slider = this.slidesContainer,
        activeSlide = null,
        xDown = 0,
        yDown = 0,
        activeSlideImage = null,
        activeSlideMedia = null,
        activeSlideDesc = null;

    let winWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
    let winHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
    let body = document.body;

    this.events['doctouchmove'] = addEvent('touchmove', {
        onElement: document,
        withCallback: (e, target) => {
            if (hasClass(body, 'gdesc-open')) {
                e.preventDefault()
                return false
            }
        }, useCapture: { passive: false }
    })


    this.events['touchStart'] = addEvent('touchstart', {
        onElement: body,
        withCallback: (e, target) => {
            if (hasClass(body, 'gdesc-open')) {
                return;
            }
            addClass(body, 'touching');
            activeSlide = this.getActiveSlide()
            activeSlideImage = activeSlide.querySelector('.gslide-image')
            activeSlideMedia = activeSlide.querySelector('.gslide-media')
            activeSlideDesc = activeSlide.querySelector('.gslide-description')

            index = this.index;
            endCoords = e.targetTouches[0];
            startCoords.pageX = e.targetTouches[0].pageX;
            startCoords.pageY = e.targetTouches[0].pageY;
            xDown = e.targetTouches[0].clientX;
            yDown = e.targetTouches[0].clientY;
        }
    })

    this.events['gestureStart'] = addEvent('gesturestart', {
        onElement: body,
        withCallback: (e, target) => {
            if (activeSlideImage) {
                e.preventDefault()
                doingPinch = true
            }
        }
    })

    this.events['gestureChange'] = addEvent('gesturechange', {
        onElement: body,
        withCallback: (e, target) => {
            e.preventDefault()
            slideCSSTransform(activeSlideImage, `scale(${e.scale})`)
        }
    })

    this.events['gesturEend'] = addEvent('gestureend', {
        onElement: body,
        withCallback: (e, target) => {
            doingPinch = false
            if (e.scale < 1) {
                pinchBigger = false
                slideCSSTransform(activeSlideImage, `scale(1)`)
            } else{
                pinchBigger = true
            }
        }
    })

    this.events['touchMove'] = addEvent('touchmove', {
        onElement: body,
        withCallback: (e, target) => {
            if (!hasClass(body, 'touching')) {
                return;
            }
            if (hasClass(body, 'gdesc-open') || doingPinch || pinchBigger) {
                return;
            }
            e.preventDefault();
            endCoords = e.targetTouches[0];
            let slideHeight = activeSlide.querySelector('.gslide-inner-content').offsetHeight;
            let slideWidth = activeSlide.querySelector('.gslide-inner-content').offsetWidth;

            let xUp = e.targetTouches[0].clientX;
            let yUp = e.targetTouches[0].clientY;
            let xDiff = xDown - xUp;
            let yDiff = yDown - yUp;

            if (Math.abs(xDiff) > Math.abs(yDiff)) { /*most significant*/
                vSwipe = false
                hSwipe = true
            } else {
                hSwipe = false
                vSwipe = true
            }

            if (vSwipe) {
                vDistanceLast = vDistance;
                vDistance = endCoords.pageY - startCoords.pageY;
                if (Math.abs(vDistance) >= vSwipMinDistance || vSwipe) {
                    let opacity = 0.75 - Math.abs(vDistance) / slideHeight;
                    activeSlideMedia.style.opacity = opacity;
                    if (activeSlideDesc) {
                        activeSlideDesc.style.opacity = opacity;
                    }
                    slideCSSTransform(activeSlideMedia, `translate3d(0, ${vDistance}px, 0)`)
                }
                return;
            }

            hDistanceLast = hDistance;
            hDistance = endCoords.pageX - startCoords.pageX;
            hDistancePercent = hDistance * 100 / winWidth;

            if (hSwipe) {
                if (this.index + 1 == this.elements.length && hDistance < -60) {
                    resetSlideMove(activeSlide)
                    return false;
                }
                if (this.index - 1 < 0 && hDistance > 60) {
                    resetSlideMove(activeSlide)
                    return false;
                }

                let opacity = 0.75 - Math.abs(hDistance) / slideWidth;
                activeSlideMedia.style.opacity = opacity;
                if (activeSlideDesc) {
                    activeSlideDesc.style.opacity = opacity;
                }
                slideCSSTransform(activeSlideMedia, `translate3d(${hDistancePercent}%, 0, 0)`)
            }
        }, useCapture: { passive: false }
    })



    this.events['touchEnd'] = addEvent('touchend', {
        onElement: body,
        withCallback: (e, target) => {
            vDistance = endCoords.pageY - startCoords.pageY;
            hDistance = endCoords.pageX - startCoords.pageX;
            hDistancePercent = hDistance * 100 / winWidth;

            removeClass(body, 'touching')

            let slideHeight = activeSlide.querySelector('.gslide-inner-content').offsetHeight;
            let slideWidth = activeSlide.querySelector('.gslide-inner-content').offsetWidth;

            // Swipe to top/bottom to close
            if (vSwipe) {
                let onEnd = (slideHeight / 2)
                    vSwipe = false;
                if (Math.abs(vDistance) >= onEnd) {
                    this.close()
                    return;
                }
                resetSlideMove(activeSlide)
                return
            }

            if (hSwipe) {
                hSwipe = false;
                let where = 'prev'
                let asideExist = true
                if(hDistance < 0){
                    where = 'next'
                    hDistance = Math.abs(hDistance)
                }
                if (where == 'prev' && this.index - 1 < 0) {
                    asideExist = false
                }
                if (where == 'next' && this.index + 1 >= this.elements.length) {
                    asideExist = false
                }
                if (asideExist && hDistance >= (slideWidth / 2) - 90) {
                    if (where == 'next') {
                       this.nextSlide();
                    }
                    else{
                       this.prevSlide();
                    }
                    return;
                }
                resetSlideMove(activeSlide)
            }
        }
    })
}
423811
function getCenter(touches) {
      var valuesX = [], valuesY = [];

      for(var t= 0,len=touches.length; t<len; t++) {
        valuesX.push(touches[t].pageX);
        valuesY.push(touches[t].pageY);
      }

      return {
        pageX: ((Math.min.apply(Math, valuesX) + Math.max.apply(Math, valuesX)) / 2),
          pageY: ((Math.min.apply(Math, valuesY) + Math.max.apply(Math, valuesY)) / 2)
      };
    }
177530
function(p) {

            var refPointDelta = 30;
            var x0 = p.x;
            var y0 = p.y;
            var a = this.a;
            var b = this.b;
            var center = this.bbox().center();
            var m = center.x;
            var n = center.y;

            var q1 = x0 > center.x + a / 2;
            var q3 = x0 < center.x - a / 2;

            var y, x;
            if (q1 || q3) {
                y = x0 > center.x ? y0 - refPointDelta : y0 + refPointDelta;
                x = (a * a / (x0 - m)) - (a * a * (y0 - n) * (y - n)) / (b * b * (x0 - m)) + m;

            } else {
                x = y0 > center.y ? x0 + refPointDelta : x0 - refPointDelta;
                y = ( b * b / (y0 - n)) - (b * b * (x0 - m) * (x - m)) / (a * a * (y0 - n)) + n;
            }

            return (new Point(x, y)).theta(p);

        }
842895
function estimateCost(from, endPoints) {

        var min = Infinity;

        for (var i = 0, len = endPoints.length; i < len; i++) {
            var cost = from.manhattanDistance(endPoints[i]);
            if (cost < min) min = cost;
        }

        return min;
    }