Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion from CubicHermite to Bezier is wrong #625

Open
MFridlyand opened this issue Jul 28, 2023 · 0 comments
Open

Conversion from CubicHermite to Bezier is wrong #625

MFridlyand opened this issue Jul 28, 2023 · 0 comments

Comments

@MFridlyand
Copy link

Following snippet demontsrates the issue
TEST_CASE("Hermite to Bezier")
{
Magnum::Vector2 t1(0.1f, 0.3f);
Magnum::Vector2 p1(1.0f, 1.0f);
Magnum::Vector2 t2(0.5f, 0.5f);
Magnum::Vector2 p2(2.0f, 7.0f);
Magnum::CubicHermite2D a(t1, p1, t1);
Magnum::CubicHermite2D b(t2, p2, t2);
using CubicBezier2 = Magnum::Math::CubicBezier<2, Magnum::Float>;
auto bezier = CubicBezier2::fromCubicHermite(a, b);
std::vector params = { 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f };
for (auto t : params)
{
Magnum::Vector2 hermite_value = Magnum::Math::splerp(a, b, t);
Magnum::Vector2 bezier_value = bezier.value(t);
if (fabs(hermite_value.x() - bezier_value.x()) > 0.1f || fabs(hermite_value.y() - bezier_value.y()) > 0.1f)
CHECK(false); // t = 0.1 hermite = [1.03, 1.18] bezier = [0.55, 0.70]
}
}

Also fromCubicHermite is not enabled for CubicHermite1D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant