MGC()
### Two static clusters
stream <- DSD_MG(dim=2,
MGC_Static(den = 1, center=c(1, 0), par=.1),
MGC_Static(den = 1, center=c(2, 0), par=.4, shape=MGC_Shape_Block)
)
plot(stream)
### Example of several MGC_Randoms
stream <- DSD_MG(dimension=2,
MGC_Random(den = 100, center=c(1, 0), par=.1, rand=.1),
MGC_Random(den = 100, center=c(2, 0), par=.4, shape=MGC_Shape_Block, rand=.1)
)
if (FALSE) {
animate_data(stream, 2500, xlim=c(0,3), ylim=c(-2,2), horizon=100)
}
### Example of several MGC_Functions
stream <- DSD_MG(dim = 2)
### block-shaped cluster moving from bottom-left to top-right increasing size
c1 <- MGC_Function(
density = function(t){100},
parameter = function(t){1*t},
center = function(t) c(t,t),
shape = MGC_Shape_Block
)
add_cluster(stream,c1)
### cluster moving in a circle (default shape is Gaussian)
c2 <- MGC_Function(
density = function(t){25},
parameter = function(t){5},
center= function(t) c(sin(t/10)*50+50, cos(t/10)*50+50)
)
add_cluster(stream,c2)
if (FALSE) {
animate_data(stream,10000,xlim=c(-20,120),ylim=c(-20,120), horizon=100)
}
### Example of several MGC_Linears: A single cluster splits at time 50 into two.
### Note that c2 starts at time=50!
stream <- DSD_MG(dim = 2)
c1 <- MGC_Linear(dim = 2)
add_keyframe(c1, time=1, dens=50, par=5, center=c(0,0))
add_keyframe(c1, time=50, dens=50, par=5, center=c(50,50))
add_keyframe(c1, time=100,dens=50, par=5, center=c(50,100))
add_cluster(stream,c1)
c2 <- MGC_Linear(dim = 2, shape=MGC_Shape_Block)
add_keyframe(c2, time=50, dens=25, par=c(10,10), center=c(50,50))
add_keyframe(c2, time=100,dens=25, par=c(30,30), center=c(100,50))
add_cluster(stream,c2)
if (FALSE) {
animate_data(stream,5000,xlim=c(0,100),ylim=c(0,100), horiz=100)
}
### two fixed and a moving cluster
stream <- DSD_MG(dim = 2,
MGC_Static(dens=1, par=.1, center=c(0,0)),
MGC_Static(dens=1, par=.1, center=c(1,1)),
MGC_Linear(dim=2,list(
keyframe(time = 0, dens=1, par=.1, center=c(0,0)),
keyframe(time = 1000, dens=1, par=.1, center=c(1,1)),
keyframe(time = 2000, dens=1, par=.1, center=c(0,0), reset=TRUE)
)))
noise <- MGC_Noise(dens=.1, range=rbind(c(-.2,1.2),c(-.2,1.2)))
add_cluster(stream, noise)
if (FALSE) {
animate_data(stream, n=2000*3.1, xlim=c(-.2,1.2), ylim=c(-.2,1.2), horiz=200)
}
#' @export MGC
Run the code above in your browser using DataLab