Skip to content

Fix the order of principal curvature#1767

Merged
jdumas merged 1 commit intolibigl:mainfrom
chaoli95:main
Apr 9, 2021
Merged

Fix the order of principal curvature#1767
jdumas merged 1 commit intolibigl:mainfrom
chaoli95:main

Conversation

@chaoli95
Copy link
Copy Markdown
Contributor

@chaoli95 chaoli95 commented Mar 28, 2021

principle_curvature returns PD1, PV1 as minimal curvature direction and value, PD2, PV2 as maximum curvature direction and value.
The order is not the same as described in the docs(https://libigl.github.io/libigl-python-bindings/igl_docs/#principal_curvature) and the comments in the header file:

// Outputs:
// PD1 #V by 3 maximal curvature direction for each vertex.
// PD2 #V by 3 minimal curvature direction for each vertex.
// PV1 #V by 1 maximal curvature value for each vertex.
// PV2 #V by 1 minimal curvature value for each vertex.

Here's the code (using python bindings) and screenshot to demonstrate this bug:

v, f = igl.cylinder(20, 20)
# pd1, pv1: maximal
# pd2, pv2: minimal
pd1, pd2, pv1, pv2 = igl.principal_curvature(v, f)
print(np.all(pv1<=pv2)) # printing true means pv2 is actually maximal curvature value

p = meshplot.plot(v, f, shading={"wireframe": False}, return_plot=True)
avg = igl.avg_edge_length(v, f) / 2
# red segments should be parallel to the maximal curvature direction
p.add_lines(v + pd1 * avg, v - pd1 * avg, shading={"line_color": "red"})
# blue segments should be parallel to the minimal curvature direction
p.add_lines(v + pd2 * avg, v - pd2 * avg, shading={"line_color": "blue"})

Screen Shot 2021-03-28 at 2 14 55 PM

The red lines are actually parallel to the minimal curvature direction.

I wrote unit test to simply make sure that max curvature is no less than min curvature.

I also fix the corresponding tutorial.

Checklist

  • All changes meet libigl style-guidelines.
  • Adds new .cpp file.
  • Adds corresponding unit test.
  • This is a minor change.

@jdumas jdumas added this to the v3.0.0 milestone Mar 28, 2021
@jdumas jdumas added the bug label Mar 28, 2021
@jdumas
Copy link
Copy Markdown
Collaborator

jdumas commented Mar 28, 2021

@danielepanozzo can you confirm this was a bug?

@jdumas jdumas requested a review from danielepanozzo March 28, 2021 17:53
Copy link
Copy Markdown
Contributor

@danielepanozzo danielepanozzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this was indeed a bug, thank you for the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants