makecluster: Simulate point clustering in an RCP matrix

View source: R/rapt_cluster-sim.R

makeclusterR Documentation

Simulate point clustering in an RCP matrix

Description

The makecluster function simulates point clusters using two RCP point clouds. The first point cloud is the "underlaying" pattern. This is the set of points that will be used as actual cluster point locations in the final product. The second point cloud is the "overlaying" pattern. This is the set of points that will determine the positions of the clusters within the underlaying pattern.

Usage

makecluster(
  under,
  over,
  radius1,
  radius2,
  type = "cr",
  ppc = NULL,
  cr = NULL,
  speed = "superfast",
  d = NULL,
  pic = 1,
  pcp = 0.06,
  den = 1,
  gb = FALSE,
  gbp = c(0, 1),
  gbmethod = "r",
  rb = FALSE,
  rbp = 1,
  rbmethod = 1,
  s = 100,
  toPlot = FALSE,
  showOverPts = FALSE
)

Arguments

under

The underlaying RCP pattern. A pp3 object containing the correctly scaled RCP pattern point locations. Should have used scaleRCP prior to putting the object into this argument.

over

The overlaying RCP pattern. A pp3 object containing the RCP pattern point locations. Scaled equal to the underlaying pattern.

radius1

The small radius of the underlaying RCP pattern. Can be found in the system output file, or as whatever the pattern is scaled to.

radius2

The small radius of the overlaying RCP pattern. Can be found in the system output file, or as whatever the pattern is scaled to.

type

How to create the clusters. Either "ppc", "cr", or "dist". See below for more information on each.

ppc

Number of points per cluster if type = "ppc", otherwise NULL.

cr

Cluster radius if type = "cr", otherwise NULL.

speed

"slow", "fast", or "superfast" for type = "cr".

d

Distance between clusters if type = "dist", otherwise NULL.

pic

Percent In Clusters. Percent of the points marked as cluster type that should actually be contained within the clusters. Number between 0 and 1 For example, if pic = 0.5, 50 percent of the cluster type points will be in clusters and 50 percent will be randomly spread through the point cloud.

pcp

Percent Cluster Points. Percent of the points in the underlaying RCP pattern that should be marked as cluster type points. Number between 0 and 1.

den

Intra cluster density of cluster points. Number between 0 and 1. Currently written for application to type = "cr" speed = "fast" and "superfast", and to type = "dist".

gb

TRUE or FALSE. Whether or not to apply a gaussian blur to the cluster center positions. See rgblur for more information on the blur function.

gbp

Parameters for the cluster center gaussian blurs. gbp = c(mean, sd). Default is mean = 0, sd = 1.

gbmethod

See method argument in rgblur.

rb

TRUE or FALSE. Whether or not to apply a gaussian blur to the cluster radius.

rbp

Parameters for the cluster radius blurs. If rbmethod = 1, then rbp = sd for the normal distribution. If rbmethod = 2, then rbp = c(p, r1, r2)), where p is the percent of r1, and (1-p) is then the percent of r2. r1 < r2.

rbmethod

Metod for distributing radius blur. rbmethod = 1 means gaussian distributed, rbmethod = 2 mean split between two radii. Can ignore cr if rbmethod = 2.

s

Seed for the random parts of the cluster generation process.

toPlot

Show a 3D plot of the cluster points once generation is done? TRUE or FALSE.

showOverPts

If toPlot = TRUE, show all of the points in the RCP pattern, with clustered points marked in red, or just show the clustered points? TRUE or FALSE.

Details

Hello friends. A quick update as of 11/8/18; I have added quite a few features and upgrades to this function, but mostly just to the cr superfast type. It should be fairly easy to generalize these upgrades to the other types, but I haven't gotten around to it yet. Some time soon perhaps. Let me, Galen Vincent, know if you need some upgrades sooner. Thanks!

Value

Returns are different based on type.

type = "ppc" or "dist"

List of: [1] pp3 object containing the cluster marked point locations. [2] pp3 object containing the overlaying RCP pattern after scaling. [3] Numeric vector containing: 1 points per cluster 1 2 number of points with points per cluster 1 3 points per cluster 2 4 number of points with points per cluster 2.

type = "cr", speed = "slow"

List of: [1] pp3 object containing the cluster marked point locations. [2] pp3 object containing the overlaying RCP pattern after scaling. [3] Numeric vector containing: 1 number of clusters 2 number of points in those clusters.

type = "cr", speed = "fast"

List of: [1] pp3 object containing the cluster marked point locations. [2] pp3 object containing the overlaying RCP pattern after scaling. [3] factor containing the number of points in each cluster.

type = "cr", speed = "superfast", rb = FALSE

List of: [1] pp3 object containing the cluster marked point locations. [2] pp3 object containing the overlaying RCP pattern after scaling. [3] number of points put in or taken away at random. [4] Vector of nearest neighbor distance (cluster center to center) from each cluster

type = "cr", speed = "superfast", rb = TRUE

List of: [1] pp3 object containing the cluster marked point locations. [2] pp3 object containing the overlaying RCP pattern after scaling. [3] number of points put in or taken away at random. [4] Vector of nearest neighbor distance (cluster center to center) from each cluster. [5] A vector contining the radius of each cluster.

Cluster Creation Methods

What the different arguments for type argument mean.

Points Per Cluster - "ppc"

Specify the number of points that should be in each cluster. Needs to be paired with the ppc argument The program will scale the overlaying pattern so that there are approximately the correct number of clusters placed through the underlaying patten, mark the n closest points to these cluster centers as cluster points, where n is the value input to the ppc argument. The cluster centers are defined by the point locations of the scaled overlaying RCP pattern. At this point, there should be approximately N x pcp x pip points containined in clusters (N = total points in the underlaying RCP pattern). The method cleans up by marking or removing marks around the centers as necesary so that there are exactly N x pcp x pip points in clusters. The rest of the N x pcp x (1-pip) points are then placed randomly through the remaining non-cluster-marked points.

Cluster Radius - "cr"

Specify the radius of the clusters. Needs to be paried with the cr argument. The overlaying RCP pattern will be scaled so that there are approximately the correct number of clusters placed through the underlaying pattern. All points in the underlaying pattern within distance cr of the cluster centers are marked as cluster points. The cluster centers are defined by the point locations of the scaled overlaying RCP pattern. At this point, there should be approximately N x pcp x pip points containined in clusters (N = total points in the underlaying RCP pattern). The method cleans up by marking or removing marks around the centers as necesary so that there are exactly N x pcp x pip points in clusters. The rest of the N x pcp x (1-pip) points are then placed randomly through the remaining non-cluster-marked points. speed = "slow" gives the most accurate, but slowest realization. speed = "fast" gives the second fastest, but less accurate realization (fails with large data sets). Clusters may not be 100\ with points. speed = "superfast" gives the fastest, but least accurate realization (works well with large data sets). Clusters may not be 100\ through the pattern.

Distance - "dist"

Specify the distance between clusters. Needs to be paired with the d argument. The overlaying RCP pattern will be scaled according to the d argumnet so that the small radius of the overlaying RCP pattern is d/2. Selects the closest n points around each cluster center so that there are N x pcp x pip points contained in clusters. The rest of the N x pcp x (1-pip) points are then placed randomly through the remaining non-cluster-marked points.

See Also

Other simulation functions: clustersim(), lattice(), morph_lamellar(), morph_rods(), nmers(), read.rcp(), scaleRCP(), stitch.size()


aproudian2/rapt documentation built on Dec. 15, 2022, 4:24 a.m.