geometry-central icon indicating copy to clipboard operation
geometry-central copied to clipboard

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

Open dpar39 opened this issue 2 years ago • 1 comments

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);?

dpar39 avatar Apr 08 '23 01:04 dpar39

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.

nzfeng avatar Sep 05 '24 02:09 nzfeng