DistanceSq: Calculate the Square Distance Between Two Points

Description Usage Arguments Value Author(s) Examples

Description

A function to calculate the square of the distance between two points.

Usage

1
DistanceSq(point1, point2, dimensions=length(point1))

Arguments

point1

An n dimensional vector representing point1.

point2

An n dimensional vector representing point2.

dimensions

An integer representing the number of dimensions being used for the distance square calculation. This defaults to the length of the first vector.

Value

A floating point value is returned, representing the square of the distance between the two points.

Author(s)

Kevin Toohey

Examples

1
2
3
4
5
6
7
# Creating two points.
point1 <- c(0, 2, 4, 6)
point2 <- c(0, 1, 2, 3)

# Calculating the square distance between the two points 
# in 4 dimensions.
DistanceSq(point1, point2, 4)

Example output

[1] 14

SimilarityMeasures documentation built on May 1, 2019, 10:06 p.m.