Description Usage Arguments Value Author(s) Examples
A function to calculate the square of the distance between two points.
1 | DistanceSq(point1, point2, dimensions=length(point1))
|
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. |
A floating point value is returned, representing the square of the distance between the two points.
Kevin Toohey
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)
|
[1] 14
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.