WY Posn Util
posn=?
posn-add
posn-subtract
posn-scale
posn-distance
place-image/  posn
posn-length
posn-length-squared
posn-within?
posn-unit
posn-dot
posn-projection
posn-angle-between-rad
posn-angle-between-deg
xy->polar
polar->xy
8.0

WY Posn Util

Andrew Mauer-Oats

 (require wy-posn-util) package: wy-posn-util

This package implements a stack of functions for working with "posn"s.

procedure

(posn=? p q)  boolean?

  p : posn?
  q : posn?
True when two posns have the same coordinates.

procedure

(posn-add p q)  posn?

  p : posn?
  q : posn?
Sum each coordinate separately.

procedure

(posn-subtract p q)  posn?

  p : posn?
  q : posn?
Coordinates of p minus the coordinates of q.

procedure

(posn-scale k p)  posn?

  k : number?
  p : posn?
Multiply each coordinate of p by the same number k.

procedure

(posn-distance p q)  nonnegative-real?

  p : posn?
  q : posn?
The Euclidean distance between the points specified by p and q.

procedure

(place-image/posn img pt bg)  image?

  img : image?
  pt : posn?
  bg : image?
Place img at the coordinates specified by pt on the bg image.

procedure

(posn-length p)  nonnegative-real?

  p : posn?
The length of the vector p.

procedure

(posn-length-squared p)  nonnegative-real?

  p : posn?
The square of the length of the vector p. This will be an integer if the coordinates of p are integers.

procedure

(posn-within? p q eps)  boolean?

  p : posn?
  q : posn?
  eps : real?
True if each of the corresponding components of p and q are within eps of each other.

procedure

(posn-unit p)  posn?

  p : posn?
The posn p rescaled so it is of unit length.

procedure

(posn-dot p q)  real?

  p : posn?
  q : posn?
The dot product.

procedure

(posn-projection p q)  real?

  p : posn?
  q : posn?
The projection of p on q. This is the length of the shadow of p on q when the sun shines perpendicular to q.

procedure

(posn-angle-between-rad p q)  real?

  p : posn?
  q : posn?
The angle between the vectors, in radians. Uses acos.

procedure

(posn-angle-between-deg p q)  real?

  p : posn?
  q : posn?
The angle between the vectors, in degrees. Uses acos.

procedure

(xy->polar p)  posn?

  p : posn?
Convert from rectangular to polar representation (radius, angle).

procedure

(polar->xy q)  posn?

  q : posn?
Convert from polar representation (radius, angle) to rectangular (x,y).