Learn R Programming

SimilarityMeasures (version 1.4)

DistanceCheck: Check if Two Points Lie Within some Distance in All Dimensions

Description

A function to check whether two points lie within some distance in every dimension.

Usage

DistanceCheck(point1, point2, dist, dimensions=length(point1))

Arguments

point1
An n dimensional vector representing point1.
point2
An n dimensional vector representing point2.
dist
A floating point number representing the maximum distance in each dimension allowed for points to be considered equivalent.
dimensions
An integer representing the number of dimensions being checked. This defaults to the length of the first vector.

Value

A boolean value is returned. The value is true if the points are within the distance in every dimension and false if not.

Examples

Run this code
# Creating two points.
point1 <- c(0, 2, 4, 6)
point2 <- c(0, 1, 2, 3)

# Running the check with distances 1 and 3 in 4 dimensions.
DistanceCheck(point1, point2, 1, 4)
DistanceCheck(point1, point2, 3, 4)

Run the code above in your browser using DataLab