(pc *B2ContactPositionConstraint, xfA B2Transform, xfB B2Transform, index int)
| 690 | } |
| 691 | |
| 692 | func (solvermanifold *B2PositionSolverManifold) Initialize(pc *B2ContactPositionConstraint, xfA B2Transform, xfB B2Transform, index int) { |
| 693 | |
| 694 | B2Assert(pc.PointCount > 0) |
| 695 | |
| 696 | switch pc.Type { |
| 697 | case B2Manifold_Type.E_circles: |
| 698 | { |
| 699 | pointA := B2TransformVec2Mul(xfA, pc.LocalPoint) |
| 700 | pointB := B2TransformVec2Mul(xfB, pc.LocalPoints[0]) |
| 701 | solvermanifold.Normal = B2Vec2Sub(pointB, pointA) |
| 702 | solvermanifold.Normal.Normalize() |
| 703 | solvermanifold.Point = B2Vec2MulScalar(0.5, B2Vec2Add(pointA, pointB)) |
| 704 | solvermanifold.Separation = B2Vec2Dot(B2Vec2Sub(pointB, pointA), solvermanifold.Normal) - pc.RadiusA - pc.RadiusB |
| 705 | } |
| 706 | break |
| 707 | |
| 708 | case B2Manifold_Type.E_faceA: |
| 709 | { |
| 710 | solvermanifold.Normal = B2RotVec2Mul(xfA.Q, pc.LocalNormal) |
| 711 | planePoint := B2TransformVec2Mul(xfA, pc.LocalPoint) |
| 712 | |
| 713 | clipPoint := B2TransformVec2Mul(xfB, pc.LocalPoints[index]) |
| 714 | solvermanifold.Separation = B2Vec2Dot(B2Vec2Sub(clipPoint, planePoint), solvermanifold.Normal) - pc.RadiusA - pc.RadiusB |
| 715 | solvermanifold.Point = clipPoint |
| 716 | } |
| 717 | break |
| 718 | |
| 719 | case B2Manifold_Type.E_faceB: |
| 720 | { |
| 721 | solvermanifold.Normal = B2RotVec2Mul(xfB.Q, pc.LocalNormal) |
| 722 | planePoint := B2TransformVec2Mul(xfB, pc.LocalPoint) |
| 723 | |
| 724 | clipPoint := B2TransformVec2Mul(xfA, pc.LocalPoints[index]) |
| 725 | solvermanifold.Separation = B2Vec2Dot(B2Vec2Sub(clipPoint, planePoint), solvermanifold.Normal) - pc.RadiusA - pc.RadiusB |
| 726 | solvermanifold.Point = clipPoint |
| 727 | |
| 728 | // Ensure normal points from A to B |
| 729 | solvermanifold.Normal = solvermanifold.Normal.OperatorNegate() |
| 730 | } |
| 731 | break |
| 732 | } |
| 733 | } |
| 734 | |
| 735 | // Sequential solver. |
| 736 | func (solver *B2ContactSolver) SolvePositionConstraints() bool { |
no test coverage detected