* Generate a sample pose sequence for testing * @param {number} count - Number of poses * @param {string} pattern - 'circle', 'line', 'helix' * @returns {Array}
(count = 10, pattern = 'circle')
| 434 | * @returns {Array} |
| 435 | */ |
| 436 | static generateSample(count = 10, pattern = 'circle') { |
| 437 | const poses = []; |
| 438 | |
| 439 | for (let i = 0; i < count; i++) { |
| 440 | const t = i / (count - 1 || 1); |
| 441 | let matrix; |
| 442 | |
| 443 | switch (pattern) { |
| 444 | case 'circle': |
| 445 | const angle = t * Math.PI * 2; |
| 446 | const radius = 2; |
| 447 | matrix = this.createPoseMatrix( |
| 448 | Math.cos(angle) * radius, |
| 449 | 0, |
| 450 | Math.sin(angle) * radius, |
| 451 | 0, angle + Math.PI, 0 |
| 452 | ); |
| 453 | break; |
| 454 | |
| 455 | case 'line': |
| 456 | matrix = this.createPoseMatrix(t * 4 - 2, 0, 0, 0, 0, 0); |
| 457 | break; |
| 458 | |
| 459 | case 'helix': |
| 460 | const helixAngle = t * Math.PI * 4; |
| 461 | const helixRadius = 1.5; |
| 462 | matrix = this.createPoseMatrix( |
| 463 | Math.cos(helixAngle) * helixRadius, |
| 464 | t * 2 - 1, |
| 465 | Math.sin(helixAngle) * helixRadius, |
| 466 | 0, helixAngle + Math.PI, 0 |
| 467 | ); |
| 468 | break; |
| 469 | |
| 470 | default: |
| 471 | matrix = this.createIdentityMatrix(); |
| 472 | } |
| 473 | |
| 474 | poses.push(matrix); |
| 475 | } |
| 476 | |
| 477 | return poses; |
| 478 | } |
| 479 | |
| 480 | /** |
| 481 | * Create a 4x4 transformation matrix from position and Euler angles |
no test coverage detected