Evaluate distance along a (curved) line
-
somebody recently asked for a snippet to compute the distance between two points along a curved line (a "wire body" Entity).
import XCoreModeling import XCoreMath Vec3 = XCoreModeling.Vec3 Body = XCoreModeling.Body def geodesic_distance_curve(wire_body: Body, p1: Vec3, p2: Vec3): wires = XCoreModeling.GetWires(wire_body) assert len(wires) == 1 curve = wires[0].GetGeometry(transform_to_model_space=True) u1 = curve.MinDistParameter(p1) u2 = curve.MinDistParameter(p2) return abs(curve.Length(u1, u2))And here is an example how to use it:
if __name__ == "__main__": ent = XCoreModeling.CreateSpline([Vec3(0), Vec3(1, 1, 0), Vec3(2, 0, 0), Vec3(3, 1, 0), Vec3(4, 0, 0)]) d = geodesic_distance_curve(ent, Vec3(1, 1, 0), Vec3(3, 1, 0)) print(f"{d} != 2")
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login