Public Member Functions | |
IEnumerator | PerformUnitTests () |
Private Member Functions | |
void | PickRandomPositions (out Vector3 particlePositionOne, out Vector3 particlePositionTwo) |
void | Test_SolveStretchConstraint (int iterations, Vector3 particlePositionOne, Vector3 particlePositionTwo, BSM.Quaternion orientation, GuidewireSim.MathHelper mathHelper, GuidewireSim.ConstraintSolvingStep constraintSolvingStep) |
Private Attributes | |
float | maximalDistanceOffset = 1f |
int | sampleSize = 10 |
int | constraintSolverSteps = 1000 |
How often the constraint solver iterates over each constraint during the Constraint Solving Step. More... | |
float | rodElementLength = 10f |
The distance between two spheres, also the distance between two orientations. More... | |
This class provides unit tests that test the method SolveStretchConstraint() of ConstraintSolvingStep. Executing this test once generates sampleSize
many random value pairs and executes the unit test with each of these pairs.
IEnumerator UnitTest_SolveStretchConstraint.PerformUnitTests | ( | ) |
Arranges all necessary data, generates sampleSize many random value pairs, and then passes all data to Test_SolveStretchConstraint(), where the unit tests are executed.
|
private |
Picks the first particle position uniformly distributed with \( x,y,z \in [-5, 5] \) and the second uniformly distributed around the first position with a uniformly distributed distance in \( [rodElementLength - maximalDistanceOffset, rodElementLength + maximalDistanceOffset] \).
[out] | particlePositionOne | The first particle position that got picked. |
[out] | particlePositionTwo | The second particle position that got picked. |
Picks the first particle position uniformly distributed so that \( x,y,z \in [-5, 5] \).
Picks a distance between the two particles that is uniformly distributed in the interval \( [rodElementLength - maximalDistanceOffset, rodElementLength + maximalDistanceOffset] \).
Picks the second particle position uniformly distributed on the surface of the sphere with center particlePositionOne
and radius startDistance
.
|
private |
Executes SolveStretchConstraint() of ConstraintSolvingStep iterations
many times for one values pair, and then asserts whether the results of the algorithm of SolveStretchConstraint() converged towards the expected values.
iterations | The number of iterations that SolveStretchConstraint() of ConstraintSolvingStep is executed. |
particlePositionOne | The first particle position for SolveStretchConstraint(). |
particlePositionTwo | The second particle position for SolveStretchConstraint(). |
orientation | The orientation for SolveStretchConstraint(). |
mathHelper | The component MathHelper. |
constraintSolvingStep | The component ConstraintSolvingStep. |
orientation
is still a unit quaternion at the end of the test.
The deviation between the stretch constraint and zero is lower than the tolerance 0.1, which means that the algorithm of SolveStretchConstraint() converges towards the fulfillment of the stretch constraint.
The deviation between the actual distance of particlePositionOne
and particlePositionTwo
and the rest rod element length is lower than a reasonable tolerance, i.e. close to zero.
|
private |
How often the constraint solver iterates over each constraint during the Constraint Solving Step.
|
private |
The maximal deviation from the rest rodElementLength
.
rodElementLength
be 10 and maximalDistanceOffset be 2. Then the two random particle positions drawn will have a distance between 8 and 12.
|
private |
The distance between two spheres, also the distance between two orientations.
|
private |
The number of value-pairs the test is executed with. E.g. if sampleSize is 10, then the unit test is executed with 10 randomly drawn value-pairs. A higher number needs more time to execute.