coordinatesBetweenRectangles: Calculate coordinates of line between bounding boxes.

Description Usage Arguments Details Value

View source: R/grplot.R

Description

We have points (x1, y1) and (x2, y2) in Cartesian space. We wish to draw a line between these two points.

Usage

1
2
  coordinatesBetweenRectangles(x1, y1, x2, y2, w1, h1, w2,
  h2)

Arguments

x1

The x-coordinate of the first point

y1

The y-coordinate of the first point

x2

The x-coordinate of the second point

y2

The y-coordinate of the second point

w1

The width of the bounding box around (x1, y1)

h1

The height of the bounding box around (x1, y1)

w2

The width of the bounding box around (x2, y2)

h2

The height of the bounding box around (x1, y1)

Details

However, these two points have rectangles centred around them. The first point has a rectangle width w1 and height h1 drawn around it; the second has a rectangle with w2 and height h2 drawn around it. Note that the vertices of the first rectangle are (x1-w1/2, x1+h1/2), (x1+w1/2, x1+h1/2), (x1+w1/2, x1-h1/2) (x1-w1/2, x1-h1/2).

This function returns the coordinates of the points on which the line drawn between the two points intersects with each bounding box.

Value

A numeric vector of length 4. The first two are the x- and y-coordinates on the bounding box of (x1, y1). The third and fourth are the x- and y-coordinates on the bounding box of (x2, y2)


rjbgoudie/parental documentation built on May 27, 2019, 9:11 a.m.