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

How to compute a surface point half way of two others in Geometry Central? #151

Open
dpar39 opened this issue Apr 8, 2023 · 1 comment

Comments

@dpar39
Copy link

dpar39 commented Apr 8, 2023

Say I have SurfacePoint p1 and p2 defined in two edges of the same triangular face. How can I compute a SurfacePoint p that lies in the face and it is half-way between p1 and p2?
I can use SurfacePoint::interpolate(geometry.vertexPositions) to compute the 3D coordinate vector, but how can I translate the mid point back to the face's barycentric coordinates so that I can initialize SurfacePoint p(faceId, faceCoords);?

@nzfeng
Copy link
Collaborator

nzfeng commented Sep 5, 2024

Hope late is better than never :). You can do something like

Face commonFace = sharedFace(p1, p2);
SurfacePoint pA = p1.inFace(commonFace);
SurfacePoint pB = p2.inFace(commonFace);
SurfacePoint midpoint(commonFace, 0.5 * (pA.faceCoords + pB.faceCoords));

which is nicer than doing some computations with extrinsic coordinates.

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

2 participants