Rotate the order of points along the outline without changing the shape.
Usage
coo_slide_id(x, ..., .cols = NULL, .ldk_col = NULL)
coo_slide_ldk(x, ..., .cols = NULL, .ldk_col = NULL)
coo_slide_closest(x, ..., .cols = NULL, .ldk_col = NULL)
coo_slide_angle(x, ..., .cols = NULL, .ldk_col = NULL)
coo_slide_direction(x, ..., .cols = NULL, .ldk_col = NULL)
coo_slide_gap(x, ..., .cols = NULL, .ldk_col = NULL)Arguments
- x
A matrix (nx2), list of matrices, or tibble with coo columns.
- ...
Additional arguments (reserved for future use).
- .cols
Column name(s) to process when
xis a tibble. IfNULL, automatically detects columns containing coo objects.- .ldk_col
Character. Name of landmark column. If
NULL, usescolname_ldk.- id
Integer. Index of point to become the first point. Default is 1.
- ldk_id
Integer. Index of landmark (in ldk column) to become first point.
- target
Numeric vector of length 2 (x, y). Find closest point to target.
- theta
Numeric. Angle in radians. Find point closest to this angle.
- direction
Character. Direction ("right", "up", "left", "down").
Value
If
xis a single matrix: returns the matrix with reordered pointsIf
xis a list: returns a list of matrices with reordered pointsIf
xis a tibble: returns the tibble with specified coo columns reordered
Details
coo_slide_id(): slide to specific point indexcoo_slide_ldk(): slide to make ith landmark become first pointcoo_slide_closest(): slide to point closest to spatial targetcoo_slide_angle(): slide to point closest to angle directioncoo_slide_direction(): slide to point in specified directioncoo_slide_gap(): slide to largest gap in perimeter
These functions are landmark-aware: landmark indices are automatically shifted (with wrapping) to match the new point order.
See also
coo_reverse() for reversing point order; coo_sample() for resampling
Examples
# Slide to point 50
coo_slide_id(shapes$cat, id = 50)
#> <xy [120 x 2]>
#> [,1] [,2]
#> [1,] 136 69
#> [2,] 135 74
#> [3,] 134 80
#> [4,] 134 86
#> [5,] 133 92
#> [6,] ... ...
#> [7,] 130 39
#> [8,] 130 45
#> [9,] 132 51
#> [10,] 135 57
#> [11,] 136 63
# Slide to first landmark
coo_slide_ldk(hearts, ldk_id = 1)
#> ✔ Updated landmarks in 'coo_ldk'
#> # A tibble: 40 × 4
#> img coo coo_ldk author
#> <path> <out> <named list> <fct>
#> 1 viodnwqb.jpg (80 x 2) <dbl [4]> ced
#> 2 ohmlpeqy.jpg (80 x 2) <dbl [4]> ced
#> 3 qleyuxan.jpg (80 x 2) <dbl [4]> ced
#> 4 esjuanpl.jpg (80 x 2) <dbl [4]> ced
#> 5 zjhldwkx.jpg (80 x 2) <dbl [4]> ced
#> 6 jgiurtke.jpg (80 x 2) <dbl [4]> jeya
#> 7 ctigzqxl.jpg (80 x 2) <dbl [4]> jeya
#> 8 azvxubnr.jpg (80 x 2) <dbl [4]> jeya
#> 9 pydkrcxh.jpg (80 x 2) <dbl [4]> jeya
#> 10 zxitnlfc.jpg (80 x 2) <dbl [4]> jeya
#> # ℹ 30 more rows
# Slide to point closest to coordinates
coo_slide_closest(shapes$cat, target = c(200, 100))
#> <xy [120 x 2]>
#> [,1] [,2]
#> [1,] 221 102
#> [2,] 221 97
#> [3,] 221 91
#> [4,] 221 85
#> [5,] 221 79
#> [6,] ... ...
#> [7,] 235 132
#> [8,] 231 126
#> [9,] 227 120
#> [10,] 224 114
#> [11,] 222 108
# Slide to rightmost point
coo_slide_direction(bot$coo, direction = "right")
#> $brahma
#> <xy [138 x 2]>
#> [,1] [,2]
#> [1,] 297 534
#> [2,] 301 555
#> [3,] 305 576
#> [4,] 307 587
#> [5,] 310 608
#> [6,] ... ...
#> [7,] 290 450
#> [8,] 290 460
#> [9,] 291 481
#> [10,] 292 502
#> [11,] 295 523
#>
#> $caney
#> <xy [168 x 2]>
#> [,1] [,2]
#> [1,] 310 503
#> [2,] 311 513
#> [3,] 312 523
#> [4,] 311 543
#> [5,] 311 553
#> [6,] ... ...
#> [7,] 311 432
#> [8,] 311 442
#> [9,] 311 462
#> [10,] 311 472
#> [11,] 312 483
#>
#> $chimay
#> <xy [189 x 2]>
#> [,1] [,2]
#> [1,] 286 317
#> [2,] 286 325
#> [3,] 286 333
#> [4,] 286 341
#> [5,] 286 348
#> [6,] ... ...
#> [7,] 288 271
#> [8,] 288 279
#> [9,] 286 294
#> [10,] 286 302
#> [11,] 286 310
#>
#> $corona
#> <xy [129 x 2]>
#> [,1] [,2]
#> [1,] 276 410
#> [2,] 276 421
#> [3,] 276 431
#> [4,] 273 452
#> [5,] 270 461
#> [6,] ... ...
#> [7,] 276 339
#> [8,] 276 349
#> [9,] 276 359
#> [10,] 276 380
#> [11,] 277 391
#>
#> $deusventrue
#> <xy [152 x 2]>
#> [,1] [,2]
#> [1,] 294 472
#> [2,] 290 481
#> [3,] 279 501
#> [4,] 276 510
#> [5,] 271 519
#> [6,] ... ...
#> [7,] 315 406
#> [8,] 313 416
#> [9,] 308 434
#> [10,] 305 444
#> [11,] 301 454
#>
#> $duvel
#> <xy [161 x 2]>
#> [,1] [,2]
#> [1,] 298 282
#> [2,] 298 293
#> [3,] 297 304
#> [4,] 297 315
#> [5,] 296 326
#> [6,] ... ...
#> [7,] 298 239
#> [8,] 298 250
#> [9,] 298 260
#> [10,] 298 271
#> [11,] 298 271
#>
#> $franziskaner
#> <xy [124 x 2]>
#> [,1] [,2]
#> [1,] 266 419
#> [2,] 266 430
#> [3,] 266 450
#> [4,] 266 461
#> [5,] 266 481
#> [6,] ... ...
#> [7,] 266 337
#> [8,] 266 347
#> [9,] 266 368
#> [10,] 266 378
#> [11,] 266 399
#>
#> $grimbergen
#> <xy [126 x 2]>
#> [,1] [,2]
#> [1,] 291 389
#> [2,] 290 410
#> [3,] 290 420
#> [4,] 288 431
#> [5,] 282 450
#> [6,] ... ...
#> [7,] 292 326
#> [8,] 291 336
#> [9,] 291 347
#> [10,] 291 368
#> [11,] 291 378
#>
#> $guiness
#> <xy [183 x 2]>
#> [,1] [,2]
#> [1,] 295 374
#> [2,] 295 391
#> [3,] 295 399
#> [4,] 297 406
#> [5,] 297 415
#> [6,] ... ...
#> [7,] 294 333
#> [8,] 294 342
#> [9,] 295 350
#> [10,] 295 358
#> [11,] 295 366
#>
#> $hoegardeen
#> <xy [193 x 2]>
#> [,1] [,2]
#> [1,] 305 527
#> [2,] 304 540
#> [3,] 302 552
#> [4,] 300 564
#> [5,] 298 577
#> [6,] ... ...
#> [7,] 305 476
#> [8,] 305 489
#> [9,] 305 502
#> [10,] 305 502
#> [11,] 305 514
#>
#> $jupiler
#> <xy [156 x 2]>
#> [,1] [,2]
#> [1,] 294 518
#> [2,] 292 531
#> [3,] 290 545
#> [4,] 287 559
#> [5,] 284 572
#> [6,] ... ...
#> [7,] 294 436
#> [8,] 294 449
#> [9,] 294 463
#> [10,] 295 477
#> [11,] 295 490
#>
#> $kingfisher
#> <xy [182 x 2]>
#> [,1] [,2]
#> [1,] 255 365
#> [2,] 253 375
#> [3,] 253 384
#> [4,] 251 394
#> [5,] 249 404
#> [6,] ... ...
#> [7,] 255 326
#> [8,] 255 336
#> [9,] 255 345
#> [10,] 255 345
#> [11,] 255 355
#>
#> $latrappe
#> <xy [136 x 2]>
#> [,1] [,2]
#> [1,] 326 340
#> [2,] 326 352
#> [3,] 326 377
#> [4,] 326 390
#> [5,] 326 402
#> [6,] ... ...
#> [7,] 326 277
#> [8,] 326 290
#> [9,] 326 302
#> [10,] 326 315
#> [11,] 326 327
#>
#> $lindemanskriek
#> <xy [176 x 2]>
#> [,1] [,2]
#> [1,] 270 403
#> [2,] 269 411
#> [3,] 267 419
#> [4,] 265 427
#> [5,] 262 443
#> [6,] ... ...
#> [7,] 272 344
#> [8,] 272 352
#> [9,] 271 369
#> [10,] 272 377
#> [11,] 272 386
#>
#> $nicechouffe
#> <xy [146 x 2]>
#> [,1] [,2]
#> [1,] 262 342
#> [2,] 261 350
#> [3,] 259 358
#> [4,] 256 374
#> [5,] 254 382
#> [6,] ... ...
#> [7,] 266 283
#> [8,] 266 300
#> [9,] 264 308
#> [10,] 264 317
#> [11,] 263 334
#>
#> $pecheresse
#> <xy [129 x 2]>
#> [,1] [,2]
#> [1,] 286 489
#> [2,] 283 509
#> [3,] 282 519
#> [4,] 277 538
#> [5,] 273 557
#> [6,] ... ...
#> [7,] 290 403
#> [8,] 290 422
#> [9,] 290 442
#> [10,] 290 451
#> [11,] 288 471
#>
#> $sierranevada
#> <xy [176 x 2]>
#> [,1] [,2]
#> [1,] 272 329
#> [2,] 272 342
#> [3,] 272 342
#> [4,] 272 354
#> [5,] 272 366
#> [6,] ... ...
#> [7,] 272 280
#> [8,] 272 292
#> [9,] 272 305
#> [10,] 272 317
#> [11,] 272 317
#>
#> $tanglefoot
#> <xy [174 x 2]>
#> [,1] [,2]
#> [1,] 298 345
#> [2,] 298 353
#> [3,] 298 361
#> [4,] 299 369
#> [5,] 299 377
#> [6,] ... ...
#> [7,] 298 297
#> [8,] 298 305
#> [9,] 298 313
#> [10,] 298 321
#> [11,] 298 329
#>
#> $tauro
#> <xy [174 x 2]>
#> [,1] [,2]
#> [1,] 293 520
#> [2,] 293 532
#> [3,] 291 545
#> [4,] 288 557
#> [5,] 285 569
#> [6,] ... ...
#> [7,] 293 447
#> [8,] 294 459
#> [9,] 295 471
#> [10,] 295 484
#> [11,] 295 496
#>
#> $westmalle
#> <xy [141 x 2]>
#> [,1] [,2]
#> [1,] 254 389
#> [2,] 252 397
#> [3,] 249 413
#> [4,] 247 421
#> [5,] 244 436
#> [6,] ... ...
#> [7,] 258 322
#> [8,] 259 339
#> [9,] 257 347
#> [10,] 256 364
#> [11,] 256 372
#>
#> $amrut
#> <xy [191 x 2]>
#> [,1] [,2]
#> [1,] 268 423
#> [2,] 268 433
#> [3,] 268 443
#> [4,] 268 453
#> [5,] 268 463
#> [6,] ... ...
#> [7,] 268 363
#> [8,] 268 373
#> [9,] 268 383
#> [10,] 268 403
#> [11,] 268 413
#>
#> $ballantines
#> <xy [146 x 2]>
#> [,1] [,2]
#> [1,] 309 335
#> [2,] 309 343
#> [3,] 309 359
#> [4,] 309 366
#> [5,] 308 382
#> [6,] ... ...
#> [7,] 310 272
#> [8,] 310 280
#> [9,] 310 296
#> [10,] 310 311
#> [11,] 310 319
#>
#> $bushmills
#> <xy [165 x 2]>
#> [,1] [,2]
#> [1,] 288 430
#> [2,] 288 445
#> [3,] 288 460
#> [4,] 288 460
#> [5,] 288 476
#> [6,] ... ...
#> [7,] 286 368
#> [8,] 286 383
#> [9,] 287 399
#> [10,] 287 399
#> [11,] 288 414
#>
#> $chivas
#> <xy [164 x 2]>
#> [,1] [,2]
#> [1,] 332 406
#> [2,] 332 423
#> [3,] 330 431
#> [4,] 327 439
#> [5,] 320 455
#> [6,] ... ...
#> [7,] 332 349
#> [8,] 332 365
#> [9,] 332 373
#> [10,] 332 381
#> [11,] 333 398
#>
#> $dalmore
#> <xy [155 x 2]>
#> [,1] [,2]
#> [1,] 311 334
#> [2,] 310 347
#> [3,] 310 347
#> [4,] 306 359
#> [5,] 301 371
#> [6,] ... ...
#> [7,] 312 273
#> [8,] 312 285
#> [9,] 312 297
#> [10,] 311 310
#> [11,] 311 322
#>
#> $famousgrouse
#> <xy [169 x 2]>
#> [,1] [,2]
#> [1,] 250 296
#> [2,] 250 305
#> [3,] 250 315
#> [4,] 250 315
#> [5,] 250 324
#> [6,] ... ...
#> [7,] 250 249
#> [8,] 248 258
#> [9,] 248 268
#> [10,] 248 277
#> [11,] 250 286
#>
#> $glendronach
#> <xy [197 x 2]>
#> [,1] [,2]
#> [1,] 272 404
#> [2,] 272 416
#> [3,] 272 428
#> [4,] 272 440
#> [5,] 272 440
#> [6,] ... ...
#> [7,] 271 355
#> [8,] 271 367
#> [9,] 271 379
#> [10,] 271 392
#> [11,] 271 392
#>
#> $glenmorangie
#> <xy [179 x 2]>
#> [,1] [,2]
#> [1,] 298 491
#> [2,] 298 508
#> [3,] 298 508
#> [4,] 300 524
#> [5,] 300 541
#> [6,] ... ...
#> [7,] 296 424
#> [8,] 297 441
#> [9,] 297 458
#> [10,] 297 458
#> [11,] 298 474
#>
#> $highlandpark
#> <xy [169 x 2]>
#> [,1] [,2]
#> [1,] 291 347
#> [2,] 291 361
#> [3,] 291 361
#> [4,] 291 375
#> [5,] 291 389
#> [6,] ... ...
#> [7,] 291 292
#> [8,] 291 306
#> [9,] 291 320
#> [10,] 291 320
#> [11,] 291 333
#>
#> $jackdaniels
#> <xy [150 x 2]>
#> [,1] [,2]
#> [1,] 301 389
#> [2,] 301 402
#> [3,] 301 415
#> [4,] 298 428
#> [5,] 300 441
#> [6,] ... ...
#> [7,] 301 336
#> [8,] 301 349
#> [9,] 301 362
#> [10,] 301 362
#> [11,] 301 376
#>
#> $jb
#> <xy [174 x 2]>
#> [,1] [,2]
#> [1,] 300 500
#> [2,] 300 522
#> [3,] 299 532
#> [4,] 299 543
#> [5,] 300 554
#> [6,] ... ...
#> [7,] 301 436
#> [8,] 300 457
#> [9,] 300 468
#> [10,] 300 479
#> [11,] 300 489
#>
#> $johnniewalker
#> <xy [168 x 2]>
#> [,1] [,2]
#> [1,] 217 164
#> [2,] 217 172
#> [3,] 217 176
#> [4,] 217 180
#> [5,] 217 184
#> [6,] ... ...
#> [7,] 217 144
#> [8,] 217 148
#> [9,] 217 152
#> [10,] 217 156
#> [11,] 217 160
#>
#> $magallan
#> <xy [141 x 2]>
#> [,1] [,2]
#> [1,] 255 385
#> [2,] 255 400
#> [3,] 257 414
#> [4,] 257 421
#> [5,] 257 436
#> [6,] ... ...
#> [7,] 252 328
#> [8,] 252 342
#> [9,] 253 350
#> [10,] 254 363
#> [11,] 254 378
#>
#> $makersmark
#> <xy [177 x 2]>
#> [,1] [,2]
#> [1,] 338 400
#> [2,] 333 413
#> [3,] 333 413
#> [4,] 326 426
#> [5,] 316 439
#> [6,] ... ...
#> [7,] 345 343
#> [8,] 345 343
#> [9,] 345 358
#> [10,] 343 371
#> [11,] 343 386
#>
#> $oban
#> <xy [179 x 2]>
#> [,1] [,2]
#> [1,] 278 449
#> [2,] 279 458
#> [3,] 279 466
#> [4,] 279 483
#> [5,] 279 492
#> [6,] ... ...
#> [7,] 277 398
#> [8,] 278 407
#> [9,] 278 415
#> [10,] 278 424
#> [11,] 278 441
#>
#> $oldpotrero
#> <xy [131 x 2]>
#> [,1] [,2]
#> [1,] 265 282
#> [2,] 261 289
#> [3,] 256 298
#> [4,] 249 307
#> [5,] 238 323
#> [6,] ... ...
#> [7,] 273 222
#> [8,] 273 239
#> [9,] 273 247
#> [10,] 273 256
#> [11,] 271 265
#>
#> $redbreast
#> <xy [177 x 2]>
#> [,1] [,2]
#> [1,] 255 200
#> [2,] 255 205
#> [3,] 255 209
#> [4,] 255 214
#> [5,] 252 223
#> [6,] ... ...
#> [7,] 256 172
#> [8,] 255 177
#> [9,] 255 181
#> [10,] 255 186
#> [11,] 255 195
#>
#> $tamdhu
#> <xy [176 x 2]>
#> [,1] [,2]
#> [1,] 299 527
#> [2,] 299 539
#> [3,] 299 551
#> [4,] 299 564
#> [5,] 301 576
#> [6,] ... ...
#> [7,] 297 465
#> [8,] 297 477
#> [9,] 299 489
#> [10,] 299 502
#> [11,] 299 514
#>
#> $wildturkey
#> <xy [185 x 2]>
#> [,1] [,2]
#> [1,] 327 537
#> [2,] 327 551
#> [3,] 327 565
#> [4,] 327 579
#> [5,] 330 592
#> [6,] ... ...
#> [7,] 327 467
#> [8,] 327 481
#> [9,] 327 495
#> [10,] 327 509
#> [11,] 327 523
#>
#> $yoichi
#> <xy [123 x 2]>
#> [,1] [,2]
#> [1,] 292 356
#> [2,] 293 371
#> [3,] 293 386
#> [4,] 293 393
#> [5,] 293 408
#> [6,] ... ...
#> [7,] 292 283
#> [8,] 292 298
#> [9,] 292 312
#> [10,] 292 327
#> [11,] 292 342
#>
#> attr(,"class")
#> [1] "out" "coo" "list"
# Slide to largest gap
coo_slide_gap(shapes$cat)
#> <xy [120 x 2]>
#> [,1] [,2]
#> [1,] 159 157
#> [2,] 165 160
#> [3,] 171 162
#> [4,] 177 165
#> [5,] 183 170
#> [6,] ... ...
#> [7,] 139 128
#> [8,] 142 134
#> [9,] 144 139
#> [10,] 148 145
#> [11,] 153 151
