Possible regions: - points[2] - edge points[0]-points[2] - edge points[1]-points[2] - inside the triangle
()
| 461 | // // - edge points[1]-points[2] |
| 462 | // // - inside the triangle |
| 463 | func (simplex *B2Simplex) Solve3() { |
| 464 | |
| 465 | w1 := simplex.M_vs[0].W |
| 466 | w2 := simplex.M_vs[1].W |
| 467 | w3 := simplex.M_vs[2].W |
| 468 | |
| 469 | // Edge12 |
| 470 | // [1 1 ][a1] = [1] |
| 471 | // [w1.e12 w2.e12][a2] = [0] |
| 472 | // a3 = 0 |
| 473 | e12 := B2Vec2Sub(w2, w1) |
| 474 | w1e12 := B2Vec2Dot(w1, e12) |
| 475 | w2e12 := B2Vec2Dot(w2, e12) |
| 476 | d12_1 := w2e12 |
| 477 | d12_2 := -w1e12 |
| 478 | |
| 479 | // Edge13 |
| 480 | // [1 1 ][a1] = [1] |
| 481 | // [w1.e13 w3.e13][a3] = [0] |
| 482 | // a2 = 0 |
| 483 | e13 := B2Vec2Sub(w3, w1) |
| 484 | w1e13 := B2Vec2Dot(w1, e13) |
| 485 | w3e13 := B2Vec2Dot(w3, e13) |
| 486 | d13_1 := w3e13 |
| 487 | d13_2 := -w1e13 |
| 488 | |
| 489 | // Edge23 |
| 490 | // [1 1 ][a2] = [1] |
| 491 | // [w2.e23 w3.e23][a3] = [0] |
| 492 | // a1 = 0 |
| 493 | e23 := B2Vec2Sub(w3, w2) |
| 494 | w2e23 := B2Vec2Dot(w2, e23) |
| 495 | w3e23 := B2Vec2Dot(w3, e23) |
| 496 | d23_1 := w3e23 |
| 497 | d23_2 := -w2e23 |
| 498 | |
| 499 | // Triangle123 |
| 500 | n123 := B2Vec2Cross(e12, e13) |
| 501 | |
| 502 | d123_1 := n123 * B2Vec2Cross(w2, w3) |
| 503 | d123_2 := n123 * B2Vec2Cross(w3, w1) |
| 504 | d123_3 := n123 * B2Vec2Cross(w1, w2) |
| 505 | |
| 506 | // w1 region |
| 507 | if d12_2 <= 0.0 && d13_2 <= 0.0 { |
| 508 | simplex.M_vs[0].A = 1.0 |
| 509 | simplex.M_count = 1 |
| 510 | return |
| 511 | } |
| 512 | |
| 513 | // e12 |
| 514 | if d12_1 > 0.0 && d12_2 > 0.0 && d123_3 <= 0.0 { |
| 515 | inv_d12 := 1.0 / (d12_1 + d12_2) |
| 516 | simplex.M_vs[0].A = d12_1 * inv_d12 |
| 517 | simplex.M_vs[1].A = d12_2 * inv_d12 |
| 518 | simplex.M_count = 2 |
| 519 | return |
| 520 | } |
no test coverage detected