centroid.owin {spatstat}R Documentation

Centroid of a window

Description

Computes the centroid (centre of mass) of a window

Usage

 centroid.owin(w)

Arguments

w A window

Details

The centroid of the window w is computed. The centroid (``centre of mass'') is the point whose x and y coordinates are the mean values of the x and y coordinates of all points in the window.

The argument w should be a window (an object of class "owin", see owin.object for details) or can be given in any format acceptable to as.owin().

Value

A list with components x, y giving the coordinates of the centroid of the window w.

Author(s)

Adrian Baddeley adrian@maths.uwa.edu.au http://www.maths.uwa.edu.au/~adrian/ and Rolf Turner rolf@math.unb.ca http://www.math.unb.ca/~rolf

See Also

owin, as.owin

Examples

  library(spatstat)
  w <- owin(c(0,1),c(0,1))
  centroid.owin(w) 
  # returns 0.5, 0.5

  data(demopat)
  w <- demopat$window
  # an irregular window
  
  plot(w)
  # plot the window
  points(centroid.owin(w))
  # mark its centroid 
  

  wapprox <- as.mask(w)
  # pixel approximation of window
  
  points(centroid.owin(wapprox))
  # should be indistinguishable 
  
       

[Package Contents]