Rename Curve/Curve2D/Curve3D/Gradient interpolate() to sample()
"sampling" is a more accurate term than "interpolating" for what's happening when using that function.
This commit is contained in:
@ -44,13 +44,13 @@ TEST_CASE("[Curve] Default curve") {
|
||||
curve->get_point_count() == 0,
|
||||
"Default curve should contain the expected number of points.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_zero_approx(curve->interpolate(0)),
|
||||
Math::is_zero_approx(curve->sample(0)),
|
||||
"Default curve should return the expected value at offset 0.0.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_zero_approx(curve->interpolate(0.5)),
|
||||
Math::is_zero_approx(curve->sample(0.5)),
|
||||
"Default curve should return the expected value at offset 0.5.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_zero_approx(curve->interpolate(1)),
|
||||
Math::is_zero_approx(curve->sample(1)),
|
||||
"Default curve should return the expected value at offset 1.0.");
|
||||
}
|
||||
|
||||
@ -80,57 +80,57 @@ TEST_CASE("[Curve] Custom curve with free tangents") {
|
||||
"Custom free curve should contain the expected number of points.");
|
||||
|
||||
CHECK_MESSAGE(
|
||||
Math::is_zero_approx(curve->interpolate(-0.1)),
|
||||
Math::is_zero_approx(curve->sample(-0.1)),
|
||||
"Custom free curve should return the expected value at offset 0.1.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate(0.1), (real_t)0.352),
|
||||
Math::is_equal_approx(curve->sample(0.1), (real_t)0.352),
|
||||
"Custom free curve should return the expected value at offset 0.1.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate(0.4), (real_t)0.352),
|
||||
Math::is_equal_approx(curve->sample(0.4), (real_t)0.352),
|
||||
"Custom free curve should return the expected value at offset 0.1.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate(0.7), (real_t)0.896),
|
||||
Math::is_equal_approx(curve->sample(0.7), (real_t)0.896),
|
||||
"Custom free curve should return the expected value at offset 0.1.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate(1), 1),
|
||||
Math::is_equal_approx(curve->sample(1), 1),
|
||||
"Custom free curve should return the expected value at offset 0.1.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate(2), 1),
|
||||
Math::is_equal_approx(curve->sample(2), 1),
|
||||
"Custom free curve should return the expected value at offset 0.1.");
|
||||
|
||||
CHECK_MESSAGE(
|
||||
Math::is_zero_approx(curve->interpolate_baked(-0.1)),
|
||||
Math::is_zero_approx(curve->sample_baked(-0.1)),
|
||||
"Custom free curve should return the expected baked value at offset 0.1.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate_baked(0.1), (real_t)0.352),
|
||||
Math::is_equal_approx(curve->sample_baked(0.1), (real_t)0.352),
|
||||
"Custom free curve should return the expected baked value at offset 0.1.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate_baked(0.4), (real_t)0.352),
|
||||
Math::is_equal_approx(curve->sample_baked(0.4), (real_t)0.352),
|
||||
"Custom free curve should return the expected baked value at offset 0.1.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate_baked(0.7), (real_t)0.896),
|
||||
Math::is_equal_approx(curve->sample_baked(0.7), (real_t)0.896),
|
||||
"Custom free curve should return the expected baked value at offset 0.1.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate_baked(1), 1),
|
||||
Math::is_equal_approx(curve->sample_baked(1), 1),
|
||||
"Custom free curve should return the expected baked value at offset 0.1.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate_baked(2), 1),
|
||||
Math::is_equal_approx(curve->sample_baked(2), 1),
|
||||
"Custom free curve should return the expected baked value at offset 0.1.");
|
||||
|
||||
curve->remove_point(1);
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate(0.1), 0),
|
||||
Math::is_equal_approx(curve->sample(0.1), 0),
|
||||
"Custom free curve should return the expected value at offset 0.1 after removing point at index 1.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate_baked(0.1), 0),
|
||||
Math::is_equal_approx(curve->sample_baked(0.1), 0),
|
||||
"Custom free curve should return the expected baked value at offset 0.1 after removing point at index 1.");
|
||||
|
||||
curve->clear_points();
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate(0.6), 0),
|
||||
Math::is_equal_approx(curve->sample(0.6), 0),
|
||||
"Custom free curve should return the expected value at offset 0.6 after clearing all points.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate_baked(0.6), 0),
|
||||
Math::is_equal_approx(curve->sample_baked(0.6), 0),
|
||||
"Custom free curve should return the expected baked value at offset 0.6 after clearing all points.");
|
||||
}
|
||||
|
||||
@ -169,51 +169,51 @@ TEST_CASE("[Curve] Custom curve with linear tangents") {
|
||||
"Custom linear curve should contain the expected number of points.");
|
||||
|
||||
CHECK_MESSAGE(
|
||||
Math::is_zero_approx(curve->interpolate(-0.1)),
|
||||
Math::is_zero_approx(curve->sample(-0.1)),
|
||||
"Custom linear curve should return the expected value at offset -0.1.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate(0.1), (real_t)0.4),
|
||||
Math::is_equal_approx(curve->sample(0.1), (real_t)0.4),
|
||||
"Custom linear curve should return the expected value at offset 0.1.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate(0.4), (real_t)0.4),
|
||||
Math::is_equal_approx(curve->sample(0.4), (real_t)0.4),
|
||||
"Custom linear curve should return the expected value at offset 0.4.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate(0.7), (real_t)0.8),
|
||||
Math::is_equal_approx(curve->sample(0.7), (real_t)0.8),
|
||||
"Custom linear curve should return the expected value at offset 0.7.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate(1), 1),
|
||||
Math::is_equal_approx(curve->sample(1), 1),
|
||||
"Custom linear curve should return the expected value at offset 1.0.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate(2), 1),
|
||||
Math::is_equal_approx(curve->sample(2), 1),
|
||||
"Custom linear curve should return the expected value at offset 2.0.");
|
||||
|
||||
CHECK_MESSAGE(
|
||||
Math::is_zero_approx(curve->interpolate_baked(-0.1)),
|
||||
Math::is_zero_approx(curve->sample_baked(-0.1)),
|
||||
"Custom linear curve should return the expected baked value at offset -0.1.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate_baked(0.1), (real_t)0.4),
|
||||
Math::is_equal_approx(curve->sample_baked(0.1), (real_t)0.4),
|
||||
"Custom linear curve should return the expected baked value at offset 0.1.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate_baked(0.4), (real_t)0.4),
|
||||
Math::is_equal_approx(curve->sample_baked(0.4), (real_t)0.4),
|
||||
"Custom linear curve should return the expected baked value at offset 0.4.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate_baked(0.7), (real_t)0.8),
|
||||
Math::is_equal_approx(curve->sample_baked(0.7), (real_t)0.8),
|
||||
"Custom linear curve should return the expected baked value at offset 0.7.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate_baked(1), 1),
|
||||
Math::is_equal_approx(curve->sample_baked(1), 1),
|
||||
"Custom linear curve should return the expected baked value at offset 1.0.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate_baked(2), 1),
|
||||
Math::is_equal_approx(curve->sample_baked(2), 1),
|
||||
"Custom linear curve should return the expected baked value at offset 2.0.");
|
||||
|
||||
ERR_PRINT_OFF;
|
||||
curve->remove_point(10);
|
||||
ERR_PRINT_ON;
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate(0.7), (real_t)0.8),
|
||||
Math::is_equal_approx(curve->sample(0.7), (real_t)0.8),
|
||||
"Custom free curve should return the expected value at offset 0.7 after removing point at invalid index 10.");
|
||||
CHECK_MESSAGE(
|
||||
Math::is_equal_approx(curve->interpolate_baked(0.7), (real_t)0.8),
|
||||
Math::is_equal_approx(curve->sample_baked(0.7), (real_t)0.8),
|
||||
"Custom free curve should return the expected baked value at offset 0.7 after removing point at invalid index 10.");
|
||||
}
|
||||
|
||||
@ -228,8 +228,8 @@ TEST_CASE("[Curve2D] Linear sampling should return exact value") {
|
||||
CHECK(len == baked_length);
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
Vector2 pos = curve->interpolate_baked(i);
|
||||
CHECK_MESSAGE(pos.x == i, "interpolate_baked should return exact value");
|
||||
Vector2 pos = curve->sample_baked(i);
|
||||
CHECK_MESSAGE(pos.x == i, "sample_baked should return exact value");
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,8 +244,8 @@ TEST_CASE("[Curve3D] Linear sampling should return exact value") {
|
||||
CHECK(len == baked_length);
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
Vector3 pos = curve->interpolate_baked(i);
|
||||
CHECK_MESSAGE(pos.x == i, "interpolate_baked should return exact value");
|
||||
Vector3 pos = curve->sample_baked(i);
|
||||
CHECK_MESSAGE(pos.x == i, "sample_baked should return exact value");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user